pub fn priority_first_search<N, E, Ix, P, F>(
graph: &Graph<N, E, Ix>,
source: &N,
priority_fn: F,
) -> Result<Vec<N>>where
N: Node + Debug + Clone,
E: EdgeWeight,
Ix: IndexType,
P: PartialOrd + Clone + Copy,
F: Fn(&N) -> P,Expand description
Performs priority-first search from a given starting node
This is a generalized graph traversal algorithm where nodes are visited in order of a priority function. When the priority function represents distance, this becomes Dijkstra’s algorithm. When all priorities are equal, this becomes breadth-first search.
§Arguments
graph- The graph to traversesource- The source nodepriority_fn- Function that assigns priority to each node (lower values visited first)
§Returns
Result<Vec<N>>- The nodes visited in priority order