Skip to main content

distances_cutoff_with_mode

Function distances_cutoff_with_mode 

Source
pub fn distances_cutoff_with_mode(
    graph: &Graph,
    source: VertexId,
    cutoff: Option<u32>,
    mode: DistancesCutoffMode,
) -> IgraphResult<Vec<Option<u32>>>
Expand description

Mode-aware distances_cutoff. For undirected graphs mode is ignored.

ยงExamples

use rust_igraph::{Graph, distances_cutoff_with_mode, DistancesCutoffMode};

// Directed: 0โ†’1โ†’2โ†’3
let mut g = Graph::new(4, true).unwrap();
g.add_edge(0, 1).unwrap();
g.add_edge(1, 2).unwrap();
g.add_edge(2, 3).unwrap();

let d = distances_cutoff_with_mode(&g, 0, Some(1), DistancesCutoffMode::Out).unwrap();
assert_eq!(d, vec![Some(0), Some(1), None, None]);

let d_in = distances_cutoff_with_mode(&g, 3, Some(2), DistancesCutoffMode::In).unwrap();
assert_eq!(d_in, vec![None, Some(2), Some(1), Some(0)]);