Macro rs_graph::nodevec [] [src]

macro_rules! nodevec {
    ( $ g : expr ;  $ elem : expr ) => { ... };
    ( $ g : expr ,  $ vec : expr ) => { ... };
}

Create a node vector associated with a graph.

Example

Create a vector with all elements set to some value, use nodevec![g; x]

let g = peterson::<LinkedListGraph>();
let weights = nodevec![&g; 0];
assert!(g.nodes().all(|u| weights[u] == 0));

Convert an existing vector to a NodeVec, use nodevec![g, v]. Note that the size of v must be exactly g.num_nodes().

let g = peterson::<LinkedListGraph>();
let weights: Vec<_> = (0..g.num_nodes()).collect();
let weights = nodevec![&g, weights];
assert!(g.nodes().all(|u| weights[u] == g.node_id(u)));