Legend

Class
Struct
Enum
Interface
Delegate
Constructor
Method
Property
Event
Field

Static method: IEnumerable<Step<TWeight, TLabel>> Run<TWeight, TLabel>(Node<TWeight, TLabel>, TWeight, Func<TWeight, TWeight, TWeight>, out TWeight)

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
  • Must derive from: System.IComparable<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.
TWeightinitialWeight The initial weight to start with (usually zero).
Func<TWeight, TWeight, TWeight>add Function to add two weights together.
out TWeighttotalWeight 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.