Adds a node to the graph, connecting it to the node already in the graph for which the connection has the lowest cost.
- iOS 9.0+
- macOS 10.11+
- Mac Catalyst 13.0+
- tvOS 9.0+
A graph node object.
trueto create connections in both directions;
falseto create just a single connection from the nearest node to the newly added node.
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 (
GKGrid 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
GKGraph subclass, this method selects the “closest” node according to whatever algorithm you implement in your
Using this method with an instance of the
GKGraph base class is not recommended.