# GridAdjacency

Defined in: [packages/graph/src/grid-adjacency.ts:29](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/graph/src/grid-adjacency.ts#L29)

An [Adjacency](/reference/knotkit/graph/interfaces/adjacency/) over a `rows × columns` board, where cell `(row, column)` is vertex `row * columns + column`.

## Extends

* [`Adjacency`](/reference/knotkit/graph/interfaces/adjacency/)

## Properties

### vertexCount

> `readonly` **vertexCount**: `number`

Defined in: [packages/graph/src/graph.ts:49](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/graph/src/graph.ts#L49)

Vertices are the integers `0 … vertexCount - 1`.

#### Inherited from

[`Adjacency`](/reference/knotkit/graph/interfaces/adjacency/).[`vertexCount`](/reference/knotkit/graph/interfaces/adjacency/#vertexcount)

***

### directed

> `readonly` **directed**: `boolean`

Defined in: [packages/graph/src/graph.ts:51](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/graph/src/graph.ts#L51)

Whether an edge from `u` to `v` leaves `v` without a way back to `u`.

#### Inherited from

[`Adjacency`](/reference/knotkit/graph/interfaces/adjacency/).[`directed`](/reference/knotkit/graph/interfaces/adjacency/#directed)

***

### forEachNeighbor

> `readonly` **forEachNeighbor**: (`vertex`, `visit`) => `void`

Defined in: [packages/graph/src/graph.ts:61](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/graph/src/graph.ts#L61)

Call `visit(neighbor, weight)` once per stored edge out of `vertex`, in ascending neighbor id, with parallel copies in insertion order. An unweighted edge reports weight `1`. A hand-written adjacency reports a finite number: an algorithm reading it throws `INVALID_VERTEX` for a neighbor outside the graph and `INVALID_WEIGHT` for any other weight.

#### Parameters

##### vertex

`number`

##### visit

(`neighbor`, `weight`) => `void`

#### Returns

`void`

#### Throws

With code `INVALID_VERTEX` when `vertex` is not in `0 … vertexCount - 1`.

#### Inherited from

[`Adjacency`](/reference/knotkit/graph/interfaces/adjacency/).[`forEachNeighbor`](/reference/knotkit/graph/interfaces/adjacency/#foreachneighbor)

***

### rows

> `readonly` **rows**: `number`

Defined in: [packages/graph/src/grid-adjacency.ts:30](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/graph/src/grid-adjacency.ts#L30)

***

### columns

> `readonly` **columns**: `number`

Defined in: [packages/graph/src/grid-adjacency.ts:31](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/graph/src/grid-adjacency.ts#L31)

***

### cell

> `readonly` **cell**: (`row`, `column`) => `number`

Defined in: [packages/graph/src/grid-adjacency.ts:37](https://github.com/jkomyno/knotkit/blob/ef04dc6fd5182dca281abddf3e1dcb13118c15a4/packages/graph/src/grid-adjacency.ts#L37)

The vertex of the cell at `(row, column)`.

#### Parameters

##### row

`number`

##### column

`number`

#### Returns

`number`

#### Throws

With code `INVALID_VERTEX` when the position is off the board.
