Declaration
public static IEnumerable<Step<TWeight, TLabel>> Run<TWeight, TLabel>(
Node<TWeight, TLabel> startNode,
TWeight initialWeight,
Func<TWeight, TWeight, TWeight> add,
out TWeight totalWeight
)
Summary
Runs Dijkstra’s Algorithm (a generalization of breadth-first search) on an arbitrary graph.
Generic type parameters
TWeight |
Type of the weight (or length or any other quantity to be minimized) of each edge between nodes. |
TLabel |
Type that is used to identify edges. |
Parameters
Node<TWeight, TLabel> | startNode |
Node to start the search at. |
TWeight | initialWeight |
The initial weight to start with (usually zero). |
Func<TWeight, TWeight, TWeight> | add |
Function to add two weights together. |
out TWeight | totalWeight |
Receives the total weight of the path returned. |
Returns
The sequence of labels on the edges connecting the start node to the first node encountered that has
Node<TWeight, TLabel>.IsFinal set to true.
Exceptions
- System.InvalidOperationException
There is no path from the startNode to any final node.