Skip to content

Defined in: packages/graph/src/graph.ts:168

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

  • GraphSurface

readonly vertexCount: number

Defined in: packages/graph/src/graph.ts:49

Vertices are the integers 0 … vertexCount - 1.

GraphSurface.vertexCount


readonly directed: boolean

Defined in: packages/graph/src/graph.ts:51

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

GraphSurface.directed


readonly forEachNeighbor: (vertex, visit) => void

Defined in: packages/graph/src/graph.ts:61

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.

number

(neighbor, weight) => void

void

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

GraphSurface.forEachNeighbor


readonly weighted: boolean

Defined in: packages/graph/src/graph.ts:115

Whether every edge stores a weight.

GraphSurface.weighted


readonly parallelEdges: boolean

Defined in: packages/graph/src/graph.ts:117

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

GraphSurface.parallelEdges


readonly selfLoops: boolean

Defined in: packages/graph/src/graph.ts:119

Whether an edge may join a vertex to itself.

GraphSurface.selfLoops


readonly edgeCount: number

Defined in: packages/graph/src/graph.ts:121

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

GraphSurface.edgeCount


readonly hasEdge: (from, to) => boolean

Defined in: packages/graph/src/graph.ts:126

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

number

number

boolean

GraphSurface.hasEdge


readonly outDegree: (vertex) => number

Defined in: packages/graph/src/graph.ts:133

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

number

number

With code INVALID_VERTEX when vertex is outside the graph.

GraphSurface.outDegree


readonly inDegree: (vertex) => number

Defined in: packages/graph/src/graph.ts:139

How many stored edges enter vertex. Equal to outDegree on an undirected graph.

number

number

With code INVALID_VERTEX when vertex is outside the graph.

GraphSurface.inDegree


readonly forEachPredecessor: (vertex, visit) => void

Defined in: packages/graph/src/graph.ts:147

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.

number

(predecessor, weight) => void

void

With code INVALID_VERTEX when vertex is outside the graph.

GraphSurface.forEachPredecessor


readonly neighbors: (vertex) => Int32Array

Defined in: packages/graph/src/graph.ts:154

The neighbors of vertex as a fresh Int32Array, in the order forEachNeighbor visits them. Writing to it never changes the graph.

number

Int32Array

With code INVALID_VERTEX when vertex is outside the graph.

GraphSurface.neighbors


readonly edges: () => GraphEdges

Defined in: packages/graph/src/graph.ts:159

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

GraphEdges

GraphSurface.edges


readonly kind: "adjacency-matrix"

Defined in: packages/graph/src/graph.ts:169

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

GraphSurface.kind