connectToLowestCostNode(node:bidirectional:)
Adds a node to the graph, connecting it to the node already in the graph for which the connection has the lowest cost.
Declaration
func connectToLowestCostNode(node: GKGraphNode, bidirectional: Bool)Parameters
Discussion
This method uses the cost(to:) method of the specified node to find the node already in the graph that is most easily reached from the new node. For nodes that contain geometry information (GKGraphNode2D or GKGridGraphNode objects), cost is by default based on distance, so this method connects the new node to the geometrically closest node already in the graph. If you create a custom GKGraphNode subclass, this method selects the “closest” node according to whatever algorithm you implement in your cost(to:) method.
Using this method with an instance of the GKGraphNode base class is not recommended.