Hyperlinkv0.8.0-beta.28

Graph

Graph.Directiontypeeffect/Graph.ts:2615
Direction

Direction for graph traversal, indicating which edges to follow.

Example (Traversing by direction)

import { Graph } from "effect"

const graph = Graph.directed<string, string>((mutable) => {
  const a = Graph.addNode(mutable, "A")
  const b = Graph.addNode(mutable, "B")
  Graph.addEdge(mutable, a, b, "A->B")
})

// Follow outgoing edges (normal direction)
const outgoingNodes = Array.from(
  Graph.indices(Graph.dfs(graph, { start: [0], direction: "outgoing" }))
)

// Follow incoming edges (reverse direction)
const incomingNodes = Array.from(
  Graph.indices(Graph.dfs(graph, { start: [1], direction: "incoming" }))
)
models
Source effect/Graph.ts:26151 lines
export type Direction = "outgoing" | "incoming"
Referenced by 3 symbols