reachable_vertices

Function reachable_vertices 

Source
pub fn reachable_vertices<T, S>(
    graph: &S,
    source: usize,
    directed: bool,
) -> SparseResult<Vec<usize>>
where T: Float + Debug + Copy + 'static, S: SparseArray<T>,
Expand description

Find all vertices reachable from a source vertex

§Arguments

  • graph - The graph as a sparse matrix
  • source - Source vertex
  • directed - Whether the graph is directed

§Returns

Vector of all vertices reachable from the source

§Examples

use scirs2_sparse::csgraph::reachable_vertices;
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();

let reachable = reachable_vertices(&graph, 0, false).unwrap();