Class DijkstraResult<TNode>
Managed result of a DijkstraFinder<TGraph, TNode, TMod>. This contains information about all nodes that are reachable from the starting location within a maximum cost budget. You can also obtain the shortest path from the start to every reachable node from this result.
Namespace: AnyPath.Managed.Results
Assembly: AnyPath.dll
Syntax
public class DijkstraResult<TNode> where TNode : unmanaged, IEquatable<TNode>
Type Parameters
| Name | Description |
|---|---|
| TNode | Node type of the graph this ran on |
Remarks
While you can obtain every path to a reachable destination, these paths are not stored directly for memory and performance reasons. When you call GetPath(TNode, bool), the path is reconstructed from the information contained within this object. Still however, this class can be roughly the same size as your graph, as every location that has been reached needs to be stored. If you use this often, it may be befinicial to set ReuseResult to true, to prevent unneccessary allocations.
Reconstructing a path via a Dijkstra result is slower than finding a single path using a regular PathFinder, as the reconstruction is not burst compiled. If you don't need to evaluate all possibilities but rather only a few, consider using an OptionFinder instead.
Constructors
DijkstraResult()
Declaration
public DijkstraResult()
Properties
Goals
All possible goal/destination nodes that were reachable from the start within the max cost budget
Declaration
public IEnumerable<TNode> Goals { get; }
Property Value
| Type | Description |
|---|---|
| IEnumerable<TNode> |
MaxCost
The maximum cost budget that was used for the dijkstra algorithm
Declaration
public float MaxCost { get; }
Property Value
| Type | Description |
|---|---|
| float |
Start
The starting node that was used for the dijkstra algorithm
Declaration
public TNode Start { get; }
Property Value
| Type | Description |
|---|---|
| TNode |
Methods
GetPath(Path<TNode>, TNode, bool)
Returns the path from the starting node to a goal node. Supply a result container to hydrate, so no new memory allocations have to be made.
Declaration
public void GetPath(Path<TNode> destResult, TNode goal, bool includeStart)
Parameters
| Type | Name | Description |
|---|---|---|
| Path<TNode> | destResult | The result to hydrate. |
| TNode | goal | |
| bool | includeStart |
Remarks
If no path exists from start to goal, a path is returned with HasPath set to false
It is only safe to call this method from the main thread.
GetPath(TNode, bool)
Returns the path from the starting node to a goal node
Declaration
public Path<TNode> GetPath(TNode goal, bool includeStart)
Parameters
| Type | Name | Description |
|---|---|---|
| TNode | goal | |
| bool | includeStart |
Returns
| Type | Description |
|---|---|
| Path<TNode> | The path from the start to the goal. |
Remarks
If no path exists from start to goal, a path is returned with HasPath set to false
It is only safe to call this method from the main thread.
HasPath(TNode)
Returns wether a given destination was reachable from the starting node, within the max cost budget
Declaration
public bool HasPath(TNode goal)
Parameters
| Type | Name | Description |
|---|---|---|
| TNode | goal | The destination node |
Returns
| Type | Description |
|---|---|
| bool | Wether the destination is reachable within the max cost budget |
TryGetCost(TNode, out float)
Returns the cost of going from the start to the goal, if reachable
Declaration
public bool TryGetCost(TNode goal, out float cost)
Parameters
| Type | Name | Description |
|---|---|---|
| TNode | goal | The destination to get the cost for |
| float | cost | The cost of travelling from the start to the specified goal node. Zero if the destination is not reachable |
Returns
| Type | Description |
|---|---|
| bool | Wether the destination is reachable |