|
9 | 9 |
|
10 | 10 | use problemreductions::rules::unitdiskmapping::{ |
11 | 11 | _internal::{ |
12 | | - create_copylines, mis_overhead_copyline, mis_overhead_copyline_triangular, CopyLine, |
13 | | - MappingGrid, |
| 12 | + CopyLine, MappingGrid, create_copylines, mis_overhead_copyline, |
| 13 | + mis_overhead_copyline_triangular, |
14 | 14 | }, |
15 | 15 | ksg, triangular, |
16 | 16 | }; |
@@ -110,21 +110,21 @@ fn extract_grid_nodes(grid: &MappingGrid) -> Vec<GridNodeExport> { |
110 | 110 | let (rows, cols) = grid.size(); |
111 | 111 | for r in 0..rows { |
112 | 112 | for c in 0..cols { |
113 | | - if let Some(cell) = grid.get(r, c) { |
114 | | - if !cell.is_empty() { |
115 | | - let state = match cell { |
116 | | - CellState::Occupied { .. } => "O", |
117 | | - CellState::Doubled { .. } => "D", |
118 | | - CellState::Connected { .. } => "C", |
119 | | - CellState::Empty => ".", |
120 | | - }; |
121 | | - nodes.push(GridNodeExport { |
122 | | - row: r as i64, // 0-indexed - DO NOT change! |
123 | | - col: c as i64, // 0-indexed - DO NOT change! |
124 | | - weight: cell.weight(), |
125 | | - state: state.to_string(), |
126 | | - }); |
127 | | - } |
| 113 | + if let Some(cell) = grid.get(r, c) |
| 114 | + && !cell.is_empty() |
| 115 | + { |
| 116 | + let state = match cell { |
| 117 | + CellState::Occupied { .. } => "O", |
| 118 | + CellState::Doubled { .. } => "D", |
| 119 | + CellState::Connected { .. } => "C", |
| 120 | + CellState::Empty => ".", |
| 121 | + }; |
| 122 | + nodes.push(GridNodeExport { |
| 123 | + row: r as i64, // 0-indexed - DO NOT change! |
| 124 | + col: c as i64, // 0-indexed - DO NOT change! |
| 125 | + weight: cell.weight(), |
| 126 | + state: state.to_string(), |
| 127 | + }); |
128 | 128 | } |
129 | 129 | } |
130 | 130 | } |
@@ -159,21 +159,20 @@ fn crossat_triangular( |
159 | 159 |
|
160 | 160 | fn get_vertex_order_from_julia(graph_name: &str) -> Option<Vec<usize>> { |
161 | 161 | let path = format!("tests/data/{}_triangular_trace.json", graph_name); |
162 | | - if let Ok(content) = fs::read_to_string(&path) { |
163 | | - if let Ok(data) = serde_json::from_str::<serde_json::Value>(&content) { |
164 | | - if let Some(copy_lines) = data["copy_lines"].as_array() { |
165 | | - let mut lines: Vec<_> = copy_lines |
166 | | - .iter() |
167 | | - .filter_map(|cl| { |
168 | | - let vertex = cl["vertex"].as_u64()? as usize; |
169 | | - let vslot = cl["vslot"].as_u64()? as usize; |
170 | | - Some((vertex - 1, vslot)) // Convert to 0-indexed |
171 | | - }) |
172 | | - .collect(); |
173 | | - lines.sort_by_key(|(_, vslot)| *vslot); |
174 | | - return Some(lines.into_iter().map(|(v, _)| v).collect()); |
175 | | - } |
176 | | - } |
| 162 | + if let Ok(content) = fs::read_to_string(&path) |
| 163 | + && let Ok(data) = serde_json::from_str::<serde_json::Value>(&content) |
| 164 | + && let Some(copy_lines) = data["copy_lines"].as_array() |
| 165 | + { |
| 166 | + let mut lines: Vec<_> = copy_lines |
| 167 | + .iter() |
| 168 | + .filter_map(|cl| { |
| 169 | + let vertex = cl["vertex"].as_u64()? as usize; |
| 170 | + let vslot = cl["vslot"].as_u64()? as usize; |
| 171 | + Some((vertex - 1, vslot)) // Convert to 0-indexed |
| 172 | + }) |
| 173 | + .collect(); |
| 174 | + lines.sort_by_key(|(_, vslot)| *vslot); |
| 175 | + return Some(lines.into_iter().map(|(v, _)| v).collect()); |
177 | 176 | } |
178 | 177 | None |
179 | 178 | } |
|
0 commit comments