Trait Strategy

Source
pub trait Strategy<G: Graph>: Debug {
    type Error: Error;

    // Required method
    fn midpoint(
        &self,
        graph: &G,
        bounds: &Bounds<G::Node>,
        statuses: &IndexMap<G::Node, Status>,
    ) -> Result<Option<G::Node>, Self::Error>;
}
Expand description

A search strategy to select the next node to search in the graph.

Required Associated Types§

Source

type Error: Error

An error type.

Required Methods§

Source

fn midpoint( &self, graph: &G, bounds: &Bounds<G::Node>, statuses: &IndexMap<G::Node, Status>, ) -> Result<Option<G::Node>, Self::Error>

Return a “midpoint” for the search. Such a midpoint lies between the success bounds and failure bounds, for some meaning of “lie between”, which depends on the strategy details.

If None is returned, then the search exits.

For example, linear search would return a node immediately “after” the node(s) in success_bounds, while binary search would return the node in the middle of success_bounds and failure_bounds.`

NOTE: This must not return a value that has already been included in the success or failure bounds, since then you would search it again in a loop indefinitely. In that case, you must return None instead.

Implementors§