Struct ReversedGraph<TNode>
A reversed edge representation of a graph. Used by the ALT heuristic provider for directed graphs.
Namespace: AnyPath.Native
Assembly: AnyPath.dll
Syntax
public struct ReversedGraph<TNode> : IGraph<TNode>, IDisposable where TNode : unmanaged, IEquatable<TNode>
Type Parameters
| Name | Description |
|---|---|
| TNode |
Constructors
ReversedGraph(Allocator)
Construct a container for the reversed graph. Which can then be populated using ScheduleCompute<TGraph, TEnumerator>(TGraph, TEnumerator, JobHandle) or Compute<TGraph, TEnumerator>(TGraph, TEnumerator, Allocator).
Declaration
public ReversedGraph(Allocator allocator)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | allocator |
Methods
Compute<TGraph, TEnumerator>(TGraph, TEnumerator)
Computes the reversed graph of a source graph immediately
Declaration
public void Compute<TGraph, TEnumerator>(TGraph source, TEnumerator nodeEnumerator) where TGraph : struct, IGraph<TNode> where TEnumerator : struct, IEnumerator<TNode>
Parameters
| Type | Name | Description |
|---|---|---|
| TGraph | source | The source graph |
| TEnumerator | nodeEnumerator | Enumerator that yields all nodes in the graph |
Type Parameters
| Name | Description |
|---|---|
| TGraph | Type of graph to construct a reverse graph for |
| TEnumerator | The type of enumerator, this can be a struct enumerator used on Unity's native collections |
Compute<TGraph, TEnumerator>(TGraph, TEnumerator, Allocator)
Computes the reversed graph of a source graph. That is, all the edges will be reversed. This is useful for directed graphs where you want to run Dijkstra's algorithm to know the shortest path from every node in the graph to a certain location. The ALT heuristic for directed graph needs this information for preprocessing.
Declaration
public static ReversedGraph<TNode> Compute<TGraph, TEnumerator>(TGraph source, TEnumerator nodeEnumerator, Allocator allocator) where TGraph : struct, IGraph<TNode> where TEnumerator : struct, IEnumerator<TNode>
Parameters
| Type | Name | Description |
|---|---|---|
| TGraph | source | The source graph |
| TEnumerator | nodeEnumerator | Enumerator that yields all nodes in the graph |
| Allocator | allocator | Allocator for the reversed graph |
Returns
| Type | Description |
|---|---|
| ReversedGraph<TNode> | A reversed edge representation of the source graph |
Type Parameters
| Name | Description |
|---|---|
| TGraph | Type of graph to construct a reverse graph for |
| TEnumerator | The type of enumerator, this can be a struct enumerator used on Unity's native collections |
Remarks
This method is not burst compiled. If your source graph is large, it might be benificial to pre-allocate the ReversedGraph structure and populate it using ScheduleCompute<TGraph, TEnumerator>(TGraph, TEnumerator, JobHandle) or Compute<TGraph, TEnumerator>(TGraph, TEnumerator, Allocator)
ScheduleCompute<TGraph, TEnumerator>(TGraph, TEnumerator, JobHandle)
Schedules a job that computes the reversed graph of a source graph. That is, all the edges will be reversed. This is useful for directed graphs where you want to run Dijkstra's algorithm to know the shortest path from every node in the graph to a certain location. The ALT heuristic for directed graph needs this information for preprocessing.
Declaration
public JobHandle ScheduleCompute<TGraph, TEnumerator>(TGraph source, TEnumerator nodeEnumerator, JobHandle dependsOn = default) where TGraph : struct, IGraph<TNode> where TEnumerator : struct, IEnumerator<TNode>
Parameters
| Type | Name | Description |
|---|---|---|
| TGraph | source | The source graph |
| TEnumerator | nodeEnumerator | Enumerator that yields all nodes in the graph |
| JobHandle | dependsOn |
Returns
| Type | Description |
|---|---|
| JobHandle |
Type Parameters
| Name | Description |
|---|---|
| TGraph | Type of graph to construct a reverse graph for |
| TEnumerator | The type of enumerator, this can be a struct enumerator used on Unity's native collections |