# AdjacencyMatrixGraph

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

The `adjacency-matrix` layout: an immutable dense matrix, what `adjacencyMatrixGraph` returns.

## Extends

* `GraphSurface`

## 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

`GraphSurface.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

`GraphSurface.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

`GraphSurface.forEachNeighbor`

***

### weighted

> `readonly` **weighted**: `boolean`

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

Whether every edge stores a weight.

#### Inherited from

`GraphSurface.weighted`

***

### parallelEdges

> `readonly` **parallelEdges**: `boolean`

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

Whether repeated edges between the same endpoints are kept as separate copies.

#### Inherited from

`GraphSurface.parallelEdges`

***

### selfLoops

> `readonly` **selfLoops**: `boolean`

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

Whether an edge may join a vertex to itself.

#### Inherited from

`GraphSurface.selfLoops`

***

### edgeCount

> `readonly` **edgeCount**: `number`

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

Number of stored edges, each undirected edge and each self-loop counted once.

#### Inherited from

`GraphSurface.edgeCount`

***

### hasEdge

> `readonly` **hasEdge**: (`from`, `to`) => `boolean`

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

Whether an edge runs from `from` to `to`. Total: returns `false` for an endpoint outside the graph instead of throwing.

#### Parameters

##### from

`number`

##### to

`number`

#### Returns

`boolean`

#### Inherited from

`GraphSurface.hasEdge`

***

### outDegree

> `readonly` **outDegree**: (`vertex`) => `number`

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

How many stored edges leave `vertex`, parallel copies included and a self-loop counted once.

#### Parameters

##### vertex

`number`

#### Returns

`number`

#### Throws

With code `INVALID_VERTEX` when `vertex` is outside the graph.

#### Inherited from

`GraphSurface.outDegree`

***

### inDegree

> `readonly` **inDegree**: (`vertex`) => `number`

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

How many stored edges enter `vertex`. Equal to [outDegree](/reference/knotkit/graph/interfaces/adjacencymatrixgraph/#outdegree) on an undirected graph.

#### Parameters

##### vertex

`number`

#### Returns

`number`

#### Throws

With code `INVALID_VERTEX` when `vertex` is outside the graph.

#### Inherited from

`GraphSurface.inDegree`

***

### forEachPredecessor

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

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

Call `visit(predecessor, weight)` once per stored edge into `vertex`, in ascending predecessor id. On an undirected graph this walks the same row as [forEachNeighbor](/reference/knotkit/graph/interfaces/adjacency/#foreachneighbor).

#### Parameters

##### vertex

`number`

##### visit

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

#### Returns

`void`

#### Throws

With code `INVALID_VERTEX` when `vertex` is outside the graph.

#### Inherited from

`GraphSurface.forEachPredecessor`

***

### neighbors

> `readonly` **neighbors**: (`vertex`) => `Int32Array`

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

The neighbors of `vertex` as a fresh `Int32Array`, in the order [forEachNeighbor](/reference/knotkit/graph/interfaces/adjacency/#foreachneighbor) visits them. Writing to it never changes the graph.

#### Parameters

##### vertex

`number`

#### Returns

`Int32Array`

#### Throws

With code `INVALID_VERTEX` when `vertex` is outside the graph.

#### Inherited from

`GraphSurface.neighbors`

***

### edges

> `readonly` **edges**: () => [`GraphEdges`](/reference/knotkit/graph/interfaces/graphedges/)

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

Every edge as fresh columns, ordered by source and then by row order. An undirected edge appears once, with `source <= target`.

#### Returns

[`GraphEdges`](/reference/knotkit/graph/interfaces/graphedges/)

#### Inherited from

`GraphSurface.edges`

***

### kind

> `readonly` **kind**: `"adjacency-matrix"`

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

The storage layout: `'adjacency-list'`, `'compressed-sparse-row'`, or `'adjacency-matrix'`.

#### Overrides

`GraphSurface.kind`
