Function PointGraph.RemoveNode

RemoveNode (PointNode node)

Removes a node from the graph.

Public
void RemoveNode (

PointNode

node

)

Removes a node from the graph.

// Make sure we only modify the graph when all pathfinding threads are paused
PointNode node1 = null;
PointNode node2 = null;
AstarPath.active.AddWorkItem(() => {
// Add 2 nodes and connect them
node1 = graph.AddNode((Int3) new Vector3(1, 2, 3));
node2 = graph.AddNode((Int3) new Vector3(4, 5, 6));
var cost = (uint)(node2.position - node1.position).costMagnitude;
GraphNode.Connect(node1, node2, cost);
});

// ...

AstarPath.active.AddWorkItem(() => {
// Remove the nodes
graph.RemoveNode(node1);
graph.RemoveNode(node2);
});

Note

For larger graphs, this operation can be slow, as it is linear in the number of nodes in the graph.