---
title: "init(_:)"
framework: gameplaykit
role: symbol
role_heading: Initializer
path: "gameplaykit/gkgraph/init(_:)"
---

# init(_:)

Initializes a graph with the specified list of nodes.

## Declaration

```swift
init(_ nodes: [GKGraphNode])
```

## Parameters

- `nodes`: An array of graph node objects—instances of doc://com.apple.gameplaykit/documentation/GameplayKit/GKGraphNode or of one of its subclasses containing geometry information.

## Return Value

Return Value A new graph object.

## Discussion

Discussion The nodes in the array need not already be connected—you can connect nodes after adding them to the graph using the connectToLowestCostNode(node:bidirectional:) method on the graph itself or the addConnection:bidirectional: method on individual nodes. Using the findPath(from:to:) method requires connections between nodes. For more information, see GameplayKit Programming Guide.
