Struct AdditionalEdges<TNode>
Supports adding additional edges to any graph type. (Portals, for example). This can be used to create bridges between any two locations that aren't present in the graph itself. You can supply these to individual pathfinding requests, or use this when small changes occur in the graph so you don't have to rebuild the entire graph.
Namespace: AnyPath.Native.EdgeMods
Assembly: AnyPath.dll
Syntax
public struct AdditionalEdges<TNode> : IEdgeMod<TNode>, IDisposable where TNode : unmanaged, IEquatable<TNode>
Type Parameters
| Name | Description |
|---|---|
| TNode |
Remarks
Note that this Edge Modifier uses a Native Container which means it needs to be disposed, just as graphs. Use the DisposeSafe<TGraph>(TGraph) extension method for that.
If your use case is creating portal "shortcuts", then you should be aware of the fact that this will probably undermine the admissability of the heuristic provider. Which can cause the algorithm to not always find the truly shortest path. This may or may not be a problem for your use case.
Constructors
AdditionalEdges(Allocator, int)
Declaration
public AdditionalEdges(Allocator allocator, int capacity = 0)
Parameters
| Type | Name | Description |
|---|---|---|
| Allocator | allocator | |
| int | capacity |
Methods
AddEdge(TNode, TNode, float)
Adds an additional edge.
Declaration
public void AddEdge(TNode from, TNode to, float cost)
Parameters
| Type | Name | Description |
|---|---|---|
| TNode | from | The starting location, can be anywhere in the graph. |
| TNode | to | The end location, can be anywhere in the graph. |
| float | cost | The cost of traversing this edge. For best results, use the cost that your IHeuristicProvider<TNode> gives. If you use a cost that is lower than the actual heuristic, you are at risk of not finding the truly shortest path anymore. This may or may not be a problem for your use case. |
Remarks
It is allowed to add multiple edges that originate or go to the same node.
Note that you shouldn't modify this struct when it's in use by a pathfinder.
Clear()
Clears all edges that were added.
Declaration
public void Clear()
Remarks
Note that you shouldn't modify this struct when it's in use by a pathfinder.