Skip to main content

reachability

Function reachability 

Source
pub fn reachability(
    graph: &Graph,
    mode: ReachabilityMode,
) -> IgraphResult<ReachabilityResult>
Expand description

Compute per-component reachability bitsets.

Counterpart of igraph_reachability(). For directed graphs with Out mode, vertex v reaches vertex u if there is a directed path from v to u. With In mode, edges are traversed in reverse. With All mode (or undirected graphs), direction is ignored.

§Examples

use rust_igraph::{Graph, reachability, ReachabilityMode};

// Directed chain 0→1→2
let mut g = Graph::new(3, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();

let r = reachability(&g, ReachabilityMode::Out).unwrap();
assert!(r.is_reachable(0, 2));
assert!(!r.is_reachable(2, 0));
assert_eq!(r.count_from(0), 3);
assert_eq!(r.count_from(2), 1);