Creates a new Dijsktra's algorithm.
Optional
weight: ((edge: BaseEdge.Class<BaseEdge.Data, BaseEdge.ScratchData>) => number)A function that returns the weight of an edge. Must not return negative values. By default, all edges have a weight of 1.
Optional
propagate: ((edge: BaseEdge.Class<BaseEdge.Data, BaseEdge.ScratchData>) => boolean)A function that determines whether to propagate a given edge.
Whether the search is to be considered directed or undirected.
A function that determines whether to propagate a given edge.
A function that returns the weight of an edge. Must not return negative values.
Starts a search from a given root node. This method is a generator, so it is usually implemented like:
export default class MySearch implements Node.Search {
*search(root: BaseNode.Class): Generator<SearchVisit> {
// Your implementation here
}
}
And uses the yield
keyword to return values.
A generator that yields each visit, so that it can be lazily iterated over.
Performs Dijsktra's algorithm lazily, yielding one node visit at a time.
Can have a custom propagation function to determine which edges to follow, effectively pruning the search tree.
Can be set to be undirected, in which case it will also use incoming edges to traverse the graph, disregarding edge direction.
Weights must be non-negative.