Fix edges_connecting docs
The documentation is now consistent with Edges. A new test case has been
added for the case of undirected graphs.
diff --git a/src/graph_impl/mod.rs b/src/graph_impl/mod.rs
index 6ed3d3e..c439633 100644
--- a/src/graph_impl/mod.rs
+++ b/src/graph_impl/mod.rs
@@ -854,9 +854,10 @@
}
}
- /// Return an iterator over all edges connecting `a` and `b`.
+ /// Return an iterator over all the edges connecting `a` and `b`.
///
- /// - `Directed` and `Undirected`: All edges connecting `a` and `b`.
+ /// - `Directed`: Outgoing edges from `a`.
+ /// - `Undirected`: All edges connected to `a`.
///
/// Iterator element type is `EdgeReference<E, Ix>`.
pub fn edges_connecting(&self, a: NodeIndex<Ix>, b: NodeIndex<Ix>) -> EdgesConnecting<E, Ty, Ix>
diff --git a/tests/graph.rs b/tests/graph.rs
index a3fd109..8bdc077 100644
--- a/tests/graph.rs
+++ b/tests/graph.rs
@@ -298,6 +298,7 @@
gr.add_edge(a, c, ());
gr.add_edge(c, b, ());
connecting_edges.insert(gr.add_edge(a, b, ()));
+ gr.add_edge(b, a, ());
let mut iter = gr.edges_connecting(a, b);
@@ -314,6 +315,40 @@
}
#[test]
+fn iter_multi_undirected_edges() {
+ let mut gr = Graph::new_undirected();
+ let a = gr.add_node("a");
+ let b = gr.add_node("b");
+ let c = gr.add_node("c");
+
+ let mut connecting_edges = HashSet::new();
+
+ gr.add_edge(a, a, ());
+ connecting_edges.insert(gr.add_edge(a, b, ()));
+ gr.add_edge(a, c, ());
+ gr.add_edge(c, b, ());
+ connecting_edges.insert(gr.add_edge(a, b, ()));
+ connecting_edges.insert(gr.add_edge(b, a, ()));
+
+ let mut iter = gr.edges_connecting(a, b);
+
+ let edge_id = iter.next().unwrap().id();
+ assert!(connecting_edges.contains(&edge_id));
+ connecting_edges.remove(&edge_id);
+
+ let edge_id = iter.next().unwrap().id();
+ assert!(connecting_edges.contains(&edge_id));
+ connecting_edges.remove(&edge_id);
+
+ let edge_id = iter.next().unwrap().id();
+ assert!(connecting_edges.contains(&edge_id));
+ connecting_edges.remove(&edge_id);
+
+ assert_eq!(None, iter.next());
+ assert!(connecting_edges.is_empty());
+}
+
+#[test]
fn update_edge()
{
{