Skip to main content

ValueFn

Trait ValueFn 

pub trait ValueFn {
    type Weight: EdgeObservableRead + Send;
    type Value: Clone + PartialOrd + Send + Sync;

    // Required methods
    fn initial_value(&self) -> Self::Value;
    fn min_value(&self) -> Option<Self::Value>;
    fn into_value_fn(
        self,
    ) -> Arc<dyn Fn(Self::Value, &Self::Weight, usize) -> Self::Value + Sync + Send>;
}
Expand description

A fold-like value function for graph traversal path scoring.

A value function produces scores where higher is better (to be maximized), as opposed to a cost function where lower is better (to be minimized). The accumulated value is folded over each edge in the path: edges that improve the path increase the value, while poor-quality edges decrease it. Paths whose value drops below min_value are discarded.

Required Associated Types§

Required Methods§

fn initial_value(&self) -> Self::Value

The initial value that will be modified by the value function.

fn min_value(&self) -> Option<Self::Value>

The minimum value, below which the value function will force discard upon traversal.

fn into_value_fn( self, ) -> Arc<dyn Fn(Self::Value, &Self::Weight, usize) -> Self::Value + Sync + Send>

The value function accepting graph properties to establish the final value.

Implementors§

§

impl<C, W> ValueFn for EdgeValueFn<C, W>
where C: Clone + PartialOrd + Send + Sync + 'static, W: EdgeObservableRead + Send + 'static,

§

type Value = C

§

type Weight = W