Function fera_graph::min_by_prop

source ·
pub fn min_by_prop<I, P, K>(prop: P, iter: I) -> Option<I::Item>where
    I: IntoIterator,
    I::Item: Copy + IntoOwned<K>,
    P: PropGet<K>,
    P::Output: Ord,
Expand description

Returns the iterator’s item with minimum property value or None if the iterator is empty.

If several items have equally minimum property value, the first item with minimum property value is returned.

Example

use fera_graph::prelude::*;
use fera_graph::min_by_prop;

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