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

Connect nodes with ports.

Show ports in dot file.
parent 7c3b0d9c
No related branches found
No related tags found
No related merge requests found
...@@ -31,12 +31,29 @@ mod test { ...@@ -31,12 +31,29 @@ mod test {
#[test] #[test]
fn new() { fn new() {
let light = Light::new("test1", "test2"); let light = Light::new("test1", "test2");
assert_eq!(light.src_port, "test1".to_owned()); assert_eq!(light.src_port, "test1");
assert_eq!(light.target_port, "test2".to_owned()); assert_eq!(light.target_port, "test2");
} }
#[test] #[test]
fn src_port() { fn src_port() {
let light = Light::new("test1", "test2"); let light = Light::new("test1", "test2");
assert_eq!(light.src_port(), "test1".to_owned()); assert_eq!(light.src_port(), "test1");
}
#[test]
fn target_port() {
let light = Light::new("test1", "test2");
assert_eq!(light.target_port(), "test2");
}
#[test]
fn set_src_port() {
let mut light = Light::new("test1", "test2");
light.set_src_port("test3".into());
assert_eq!(light.src_port, "test3");
}
#[test]
fn set_target_port() {
let mut light = Light::new("test1", "test2");
light.set_target_port("test3".into());
assert_eq!(light.target_port, "test3");
} }
} }
...@@ -126,11 +126,14 @@ impl OpticScenery { ...@@ -126,11 +126,14 @@ impl OpticScenery {
dot_string += &node.to_dot(&format!("i{}", node_idx.index())); dot_string += &node.to_dot(&format!("i{}", node_idx.index()));
} }
for edge in self.g.edge_indices() { for edge in self.g.edge_indices() {
let light=self.g.edge_weight(edge).unwrap();
let end_nodes = self.g.edge_endpoints(edge).unwrap(); let end_nodes = self.g.edge_endpoints(edge).unwrap();
dot_string.push_str(&format!( dot_string.push_str(&format!(
" i{} -> i{}\n", " i{} -> i{} [label=\"{}->{}\"]\n",
end_nodes.0.index(), end_nodes.0.index(),
end_nodes.1.index() end_nodes.1.index(),
light.src_port(),
light.target_port()
)); ));
} }
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