| 256 | } |
| 257 | |
| 258 | pub fn format_tgf(writer: &mut BufWriter<Box<dyn Write>>, graph: GraphType) -> eyre::Result<()> { |
| 259 | // let (nodes, edges) = graph.into_nodes_edges(); |
| 260 | for idx in graph.node_indices() { |
| 261 | let particle = graph |
| 262 | .node_weight(idx) |
| 263 | .ok_or_else(|| eyre::eyre!("Got index {idx:?} to nonexistent node"))?; |
| 264 | let label = idx.index(); |
| 265 | writeln!( |
| 266 | writer, |
| 267 | "{label}\tPOINT({} {})", |
| 268 | particle.coordinates[0], particle.coordinates[1] |
| 269 | )?; |
| 270 | } |
| 271 | writeln!(writer, "#")?; |
| 272 | for edge in graph.edge_references() { |
| 273 | writeln!( |
| 274 | writer, |
| 275 | "{}\t {}", |
| 276 | edge.source().index(), |
| 277 | edge.target().index() |
| 278 | )?; |
| 279 | } |
| 280 | Ok(()) |
| 281 | } |
| 282 | |
| 283 | pub fn format_wkt(writer: &mut BufWriter<Box<dyn Write>>, graph: GraphType) -> eyre::Result<()> { |
| 284 | for idx in graph.node_indices() { |