pub fn has_path<T, S>(
graph: &S,
source: usize,
target: usize,
directed: bool,
) -> SparseResult<bool>
Expand description
Check if there is a path between two vertices
§Arguments
graph
- The graph as a sparse matrixsource
- Source vertextarget
- Target vertexdirected
- Whether the graph is directed
§Returns
True if there is a path from source to target, false otherwise
§Examples
use scirs2_sparse::csgraph::has_path;
use scirs2_sparse::csr_array::CsrArray;
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!(has_path(&graph, 0, 2, false).unwrap());