Class AStar<T>
A Graph Solver using the A* method, with a configurable GreedFactor.
Inherited Members
Namespace: PathFinder.Solvers.Generic
Assembly: PathFinder.dll
Syntax
public sealed class AStar<T> : SolverBase<T>, IGraphSolver<T>, IComparer<GraphNodeMetaData<T>> where T : IEquatable<T>
Type Parameters
Name | Description |
---|---|
T | The type of nodes to traverse. Must extend ITraversableNode<T> if traverser is null. |
Remarks
The A* method is considered the most optimal "blind" graph solver, but only in cases where the distance between arbitrary nodes can be estimated.
The GreedFactor
determines how much weight is given to the distance estimate to
the Destination
.
Constructors
| Improve this Doc View SourceAStar(T, T, INodeTraverser<T>)
Creates a solver using the AStar method.
Declaration
public AStar(T origin, T destination, INodeTraverser<T> traverser = null)
Parameters
Type | Name | Description |
---|---|---|
T | origin | |
T | destination | |
INodeTraverser<T> | traverser | The INodeTraverser<T> implementation to use when traversing the graph -or-
|
AStar(T, T, Double, INodeTraverser<T>)
Creates a solver using the AStar method.
Declaration
public AStar(T origin, T destination, double greedFactor, INodeTraverser<T> traverser = null)
Parameters
Type | Name | Description |
---|---|---|
T | origin | |
T | destination | |
System.Double | greedFactor | |
INodeTraverser<T> | traverser | The INodeTraverser<T> implementation to use when traversing the graph -or-
|
Properties
| Improve this Doc View SourceGreedFactor
How thorough the search should be.
Must be greater than or equal to 0.
Declaration
public double GreedFactor { get; set; }
Property Value
Type | Description |
---|---|
System.Double |
Remarks
Methods
| Improve this Doc View SourceProcessNeighbor(GraphNodeMetaData<T>)
Declaration
protected override void ProcessNeighbor(GraphNodeMetaData<T> neighborMetaData)
Parameters
Type | Name | Description |
---|---|---|
PathFinder.Solvers.Generic.GraphNodeMetaData<T> | neighborMetaData |
Overrides
Solve(T, T, out IList<T>, INodeTraverser<T>, Int32)
Finds a path between the origin and destination node using the AStar method.
Declaration
public static SolverState Solve(T origin, T destination, out IList<T> path, INodeTraverser<T> traverser = null, int maxTicks = 1000000)
Parameters
Type | Name | Description |
---|---|---|
T | origin | |
T | destination | |
IList<T> | path | The resulting path if Success, otherwise |
INodeTraverser<T> | traverser | The INodeTraverser<T> implementation to use when traversing the graph -or-
|
System.Int32 | maxTicks | The maximum number of ticks to run before failing. |
Returns
Type | Description |
---|---|
SolverState | The SolverState of the solver after running. |
Solve(T, T, Double, out IList<T>, INodeTraverser<T>, Int32)
Finds a path between the origin and destination node using the AStar method.
Declaration
public static SolverState Solve(T origin, T destination, double greedFactor, out IList<T> path, INodeTraverser<T> traverser = null, int maxTicks = 1000000)
Parameters
Type | Name | Description |
---|---|---|
T | origin | |
T | destination | |
System.Double | greedFactor | |
IList<T> | path | The resulting path if Success, otherwise |
INodeTraverser<T> | traverser | The INodeTraverser<T> implementation to use when traversing the graph -or-
|
System.Int32 | maxTicks | The maximum number of ticks to run before failing. |
Returns
Type | Description |
---|---|
SolverState | The SolverState of the solver after running. |