Skip to content

Commit a77005b

Browse files
authored
Merge pull request petgraph#232 from abreis/stablegraph-contains-edge
Implement contains_edge for StableGraph
2 parents a248e8f + 2754b86 commit a77005b

File tree

1 file changed

+8
-0
lines changed
  • src/graph_impl/stable_graph

1 file changed

+8
-0
lines changed

src/graph_impl/stable_graph/mod.rs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -535,6 +535,14 @@ impl<N, E, Ty, Ix> StableGraph<N, E, Ty, Ix>
535535
}
536536
}
537537

538+
/// Lookup if there is an edge from `a` to `b`.
539+
///
540+
/// Computes in **O(e')** time, where **e'** is the number of edges
541+
/// connected to `a` (and `b`, if the graph edges are undirected).
542+
pub fn contains_edge(&self, a: NodeIndex<Ix>, b: NodeIndex<Ix>) -> bool {
543+
self.find_edge(a, b).is_some()
544+
}
545+
538546
/// Lookup an edge from `a` to `b`.
539547
///
540548
/// Computes in **O(e')** time, where **e'** is the number of edges

0 commit comments

Comments
 (0)