---
title: "init(fromGridStartingAt:width:height:diagonalsAllowed:)"
framework: gameplaykit
role: symbol
role_heading: Initializer
path: "gameplaykit/gkgridgraph/init(fromgridstartingat:width:height:diagonalsallowed:)"
---

# init(fromGridStartingAt:width:height:diagonalsAllowed:)

Initializes a graph that describes an integer grid with the specified dimensions.

## Declaration

```swift
init(fromGridStartingAt position: vector_int2, width: Int32, height: Int32, diagonalsAllowed: Bool)
```

## Parameters

- `position`: The lowest x- and y-coordinates to appear in the grid.
- `width`: The number of possible x-coordinates in the grid.
- `height`: The number of possible y-coordinates in the grid.
- `diagonalsAllowed`: doc://com.apple.documentation/documentation/Swift/true to connect nodes in the grid to their diagonal neighbors; doc://com.apple.documentation/documentation/Swift/false to connect nodes only to their horizontal and vertical neighbors.

## Return Value

Return Value A new grid graph.

## Discussion

Discussion All connections created through this method are bidirectional.

## See Also

### Creating a Graph

- [init(fromGridStartingAt:width:height:diagonalsAllowed:nodeClass:)](gameplaykit/gkgridgraph/init(fromgridstartingat:width:height:diagonalsallowed:nodeclass:).md)
