Skip to main content

filter_nodes

Function filter_nodes 

Source
pub fn filter_nodes<N, E, P>(
    graph: &AttributedGraph<N, E>,
    predicate: P,
) -> Vec<NodeId>
where P: Fn(&N) -> bool,
Expand description

Filter nodes by a predicate on their data, returning matching NodeIds.

ยงExample

use scirs2_graph::attributed_graph::{AttributedGraph, filter_nodes};

let mut g = AttributedGraph::<i32, ()>::new();
g.add_node(10);
g.add_node(20);
g.add_node(30);

let big = filter_nodes(&g, |v| *v > 15);
assert_eq!(big.len(), 2);