Skip to content
Snippets Groups Projects
Commit a8aaefa7 authored by Udo Eisenbarth's avatar Udo Eisenbarth :speech_balloon:
Browse files

Add support for edges in "to_dot" function of OpticScenery

parent 11be8694
No related branches found
No related tags found
No related merge requests found
......@@ -11,7 +11,9 @@ fn main() {
scenery.set_description("OpticScenery demo".into());
println!("default opticscenery: {:?}", scenery);
println!("export to `dot` format: {}", scenery.to_dot());
scenery.add_node(OpticNode::new("my optic", Box::new(NodeDummy)));
let node1=scenery.add_node(OpticNode::new("my optic", Box::new(NodeDummy)));
let node2=scenery.add_node(OpticNode::new("my other optic", Box::new(NodeDummy)));
scenery.connect_nodes(node1, node2);
let path = "graph.dot";
let mut output = File::create(path).unwrap();
write!(output, "{}", scenery.to_dot()).unwrap();
......
......@@ -55,10 +55,12 @@ impl OpticScenery {
for node in self.g.node_weights() {
dot_string += &node.to_dot();
}
dot_string += "\n";
// for edge in self.g.edge_indices() {
// }
for edge in self.g.edge_indices() {
let end_nodes = self.g.edge_endpoints(edge).unwrap();
let node1 = self.g.node_weight(end_nodes.0).unwrap();
let node2 = self.g.node_weight(end_nodes.1).unwrap();
dot_string.push_str(&format!(" \"{}\" -> \"{}\"\n", node1.name(), node2.name()));
}
dot_string += "}";
dot_string
}
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment