Skip to content

const GRAPH_KINDS: readonly ["compressed-sparse-row", "adjacency-list", "adjacency-matrix"]

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

The storage layouts this package constructs, in the order the README and the capability record recommend them.

compressed-sparse-row is first: an edge set known up front is the common case, and it is smaller than the adjacency list. At degree 10 it takes 4.2 bytes per stored arc undirected and 4.4 directed, against the list’s 4.6 and 5.2, and a directed list stores every edge twice. Search speed no longer separates the two: in the package’s breadth-first-search benchmark at 100,000 vertices, the median adjacency-list search ran within 1.3 times of packed rows at degrees 1.3, 10, and 100 on JSC and V8, and within 1.11 times from degree 10 up. adjacency-list is the one mutable kind, for edges that arrive after construction. adjacency-matrix is for a small, dense, simple graph probed with hasEdge. floydWarshall runs on every layout, so an all-pairs question does not pick one.