<!--
{
  "availability" : [
    "iOS: 9.0.0 -",
    "iPadOS: 9.0.0 -",
    "macCatalyst: 13.1.0 -",
    "macOS: 10.11.0 -",
    "tvOS: 9.0.0 -",
    "visionOS: 1.0.0 -"
  ],
  "documentType" : "symbol",
  "framework" : "GameplayKit",
  "identifier" : "/documentation/GameplayKit/GKGraphNode",
  "metadataVersion" : "0.1.0",
  "role" : "Class",
  "symbol" : {
    "kind" : "Class",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKGraphNode"
  },
  "title" : "GKGraphNode"
}
-->

# GKGraphNode

A single node in a navigation graph for use in pathfinding.

```
class GKGraphNode
```

## Overview

A set of connected nodes form a graph that describes the navigability of a game world. Use graph nodes together with a [`GKGraph`](/documentation/GameplayKit/GKGraph) object (or one of its subclasses) to perform actions that relate to the network of nodes as a whole, such as pathfinding to determine routes through the network.

This class describes the general features of graph nodes, but does not contain geometry information that relates the graph to a game world. You can construct a graph with this class or any of its subclasses:

- On its own, the [`GKGraphNode`](/documentation/GameplayKit/GKGraphNode) class is useful for worlds such as board games, where the connections between nodes are important but their spatial position has no effect on gameplay.
- Create [`GKGridGraphNode`](/documentation/GameplayKit/GKGridGraphNode) objects (for use with the [`GKGridGraph`](/documentation/GameplayKit/GKGridGraph) class) to model worlds where movement is constrained to a two-dimensional integer grid.
- Create [`GKGraphNode2D`](/documentation/GameplayKit/GKGraphNode2D) objects to model worlds that allow full freedom of movement in a two-dimensional plane. Use these nodes together with the [`GKObstacleGraph`](/documentation/GameplayKit/GKObstacleGraph) or [`GKMeshGraph`](/documentation/GameplayKit/GKMeshGraph) class to create graphs that route around impassable obstacles.
- Create [`GKGraphNode3D`](/documentation/GameplayKit/GKGraphNode3D) objects to model worlds that allow full freedom of movement in three-dimensional space.

To learn more about graphs and pathfinding, see [Pathfinding](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/Pathfinding.html#//apple_ref/doc/uid/TP40015172-CH3) in [GameplayKit Programming Guide](https://developer.apple.com/library/archive/documentation/General/Conceptual/GameplayKit_Guide/index.html#//apple_ref/doc/uid/TP40015172).

## Topics

### Working with Connections

[`connectedNodes`](/documentation/GameplayKit/GKGraphNode/connectedNodes)

The list of other nodes connected to this node.

[`-  addConnectionsToNodes:bidirectional:`](/documentation/GameplayKit/GKGraphNode/addConnections(to:bidirectional:))

Connects this node to all nodes in the specified list.

[`-  removeConnectionsToNodes:bidirectional:`](/documentation/GameplayKit/GKGraphNode/removeConnections(to:bidirectional:))

Removes the connections from this node to the specified nodes.

### Computing Traversal Costs

[`-  costToNode:`](/documentation/GameplayKit/GKGraphNode/cost(to:))

Returns the cost to travel from this node to the specified, directly connected, node.

[`-  estimatedCostToNode:`](/documentation/GameplayKit/GKGraphNode/estimatedCost(to:))

Returns an underestimate of the cost of travel from this node to the specified node.

### Finding Paths

[`-  findPathToNode:`](/documentation/GameplayKit/GKGraphNode/findPath(to:))

Computes and returns a sequence of nodes that represents the lowest-cost graph traversal from this node to the specified node.

[`-  findPathFromNode:`](/documentation/GameplayKit/GKGraphNode/findPath(from:))

Computes and returns a sequence of nodes that represents the lowest-cost graph traversal from the specified node to this node.

## Relationships

### Inherits From

[`NSObject-swift.class`](/documentation/ObjectiveC/NSObject-swift.class)

### Conforms To

[`NSObjectProtocol`](/documentation/ObjectiveC/NSObjectProtocol)

[`CVarArg`](/documentation/Swift/CVarArg)

[`CustomDebugStringConvertible`](/documentation/Swift/CustomDebugStringConvertible)

[`NSSecureCoding`](/documentation/Foundation/NSSecureCoding)

[`Hashable`](/documentation/Swift/Hashable)

[`Equatable`](/documentation/Swift/Equatable)

[`NSCoding`](/documentation/Foundation/NSCoding)

[`CustomStringConvertible`](/documentation/Swift/CustomStringConvertible)

### Inherited By

[`GKGraphNode3D`](/documentation/GameplayKit/GKGraphNode3D)

[`GKGridGraphNode`](/documentation/GameplayKit/GKGridGraphNode)

[`GKGraphNode2D`](/documentation/GameplayKit/GKGraphNode2D)

---

Copyright &copy; 2026 Apple Inc. All rights reserved. | [Terms of Use](https://www.apple.com/legal/internet-services/terms/site.html) | [Privacy Policy](https://www.apple.com/privacy/privacy-policy)