Skip to main content

reachable_from_sources

Function reachable_from_sources 

Source
pub fn reachable_from_sources(
    graph: &Graph,
    sources: &[u32],
) -> SortedIntView<'static>
Expand description

Returns the nodes reachable from at least one of sources, in ascending order and with the sources included - Java’s overload reachableFrom(Graph, IntList).

The search follows the edges in their direction; for the nodes from which a source is reachable, search the transposed graph, as shown at BiAdjacentGraph::transposed. A source given twice counts once, and with no sources, no node is reachable. Being sorted, the result goes straight into NodeMapping::for_subgraph_sorted for the subgraph of the reachable nodes, as shown at remapped. For distances and shortest paths, use BfsDistances.

Time: O(sources.len() + node_count + edge_count). Memory: 4 bytes per reachable node for the result; while it runs, 1 bit per node and briefly up to 12 bytes per reachable node.

§Panics

With an index out of bounds message if a source is not in 0..node_count.