pub fn is_connected<T, S>(graph: &S, directed: bool) -> SparseResult<bool>
Expand description
Check if a graph is connected
§Arguments
graph
- The graph as a sparse matrixdirected
- Whether the graph is directed
§Returns
True if the graph is connected, false otherwise
§Examples
use scirs2_sparse::csgraph::is_connected;
use scirs2_sparse::csr_array::CsrArray;
// Create a connected graph
let rows = vec![0, 1, 1, 2];
let cols = vec![1, 0, 2, 1];
let data = vec![1.0, 1.0, 1.0, 1.0];
let graph = CsrArray::from_triplets(&rows, &cols, &data, (3, 3), false).unwrap();
assert!(is_connected(&graph, false).unwrap());