Skip to content

Graph

Since 1.4.0

Graph type using adjacency list.

Signature

typescript
type Graph<Adjacency extends Record<string, string[]>> = {
  [K in keyof Adjacency]: GraphNode<K & string, Adjacency[K]>
}

Parameters

ParameterDescription
AdjacencyAdjacency list mapping nodes to edges

Description

Represents a graph structure using adjacency list representation.

Examples

Basic Usage

typescript
import type { Graph } from 'uni-types'

type MyGraph = Graph<{
  a: ['b', 'c']
  b: ['c']
  c: []
}>

Released under the MIT License.