Function fera_graph::sum_prop [] [src]

pub fn sum_prop<P, K, O, I>(prop: P, iter: I) -> O where
    I: IntoIterator,
    I::Item: IntoOwned<K>,
    P: PropGet<K>,
    O: Sum<P::Output>, 

Returns the sum of the property values of the iterator's items.

Example

use fera_graph::prelude::*;
use fera_graph::sum_prop;

let g = CompleteGraph::new(3);
let mut w = g.default_vertex_prop(0u32);
w[0] = 5;
w[1] = 10;
w[2] = 4;
assert_eq!(19u32, sum_prop(&w, g.vertices()));
assert_eq!(0u32, sum_prop(&w, g.vertices().take(0)));
assert_eq!(15u32, sum_prop(&w, &[1, 0]));