Function rs_graph::algorithms::is_connected
source · pub fn is_connected<G>(g: &G) -> boolwhere
G: IndexGraph,
Expand description
Determines if a graph is connected.
The empty graph is connected.
Example
use rs_graph::{LinkedListGraph, Graph, Buildable, Builder, classes, algorithms};
let mut g: LinkedListGraph = classes::cycle(5);
assert!(algorithms::is_connected(&g));
let g = LinkedListGraph::<usize>::new_with(|b| {
let nodes = b.add_nodes(5);
for i in 0..5 {
b.add_edge(nodes[i], nodes[(i + 1) % 5]);
}
b.add_node();
});
assert!(!algorithms::is_connected(&g));