<!--
{
  "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/findPath(from:)",
  "metadataVersion" : "0.1.0",
  "role" : "Instance Method",
  "symbol" : {
    "kind" : "Instance Method",
    "modules" : [
      "GameplayKit"
    ],
    "preciseIdentifier" : "c:objc(cs)GKGraphNode(im)findPathFromNode:"
  },
  "title" : "findPath(from:)"
}
-->

# findPath(from:)

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

```
func findPath(from startNode: GKGraphNode) -> [GKGraphNode]
```

## Parameters

`startNode`

The origin node from which to attempt traversal of the graph.

## Return Value

An array of nodes representing a path through the graph in start to end order, or an empty array if no path exists between the specified nodes.

## Discussion

This method is equivalent to the [`findPath(to:)`](/documentation/GameplayKit/GKGraphNode/findPath(to:)) method, but finds a path from the specified node to this node, rather than the other way around. Connections in a graph are directional—that is, a connection from Node A to Node B indicates only that travel is possible from A to B, and indicating that travel from B to A is also possible requires a separate connection. Therefore, calling the [`findPath(to:)`](/documentation/GameplayKit/GKGraphNode/findPath(to:)) and [`findPath(from:)`](/documentation/GameplayKit/GKGraphNode/findPath(from:)) methods with the same pair of nodes might not always return the same paths.

---

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)