Satsuma
a delicious .NET graph library
|
Uses the A* search algorithm to find cheapest paths in a graph. More...
Public Member Functions | |
void | AddSource (Node node) |
Adds a new source node. More... | |
AStar (IGraph graph, Func< Arc, double > cost, Func< Node, double > heuristic) | |
double | GetDistance (Node node) |
Gets the cost of the cheapest path from the source nodes to a given node (that is, its distance from the sources). More... | |
IPath | GetPath (Node node) |
Gets a cheapest path from the source nodes to a given node. More... | |
Node | RunUntilReached (Node target) |
Runs the algorithm until the given node is reached. More... | |
Node | RunUntilReached (Func< Node, bool > isTarget) |
Runs the algorithm until a node satisfying the given condition is reached. More... | |
Properties | |
Func< Arc, double > | Cost [get, set] |
A non-negative arc cost function. More... | |
IGraph | Graph [get, set] |
The input graph. More... | |
Func< Node, double > | Heuristic [get, set] |
The A* heuristic function. More... | |
Uses the A* search algorithm to find cheapest paths in a graph.
AStar is essentially Dijkstra's algorithm with an optional heuristic which can speed up path search.
Usage:
Example (finding a shortest path between two nodes):
void Satsuma.AStar.AddSource | ( | Node | node | ) |
double Satsuma.AStar.GetDistance | ( | Node | node | ) |
Runs the algorithm until the given node is reached.
target | The node to reach. |
ArgumentException | Heuristic(target) is not 0. |
Runs the algorithm until a node satisfying the given condition is reached.
ArgumentException | Heuristic is not 0 for the returned node. |
|
getset |
|
getset |
The A* heuristic function.
Heuristic must be a function that is
Heuristic(u) <= Cost(uv) + Heuristic(v)
.From the above it follows that Heuristic must return 0 for all target nodes.
If Heuristic is the constant zero function, then the algorithm is equivalent to Dijkstra's algorithm.