effx
API reference@effx/ir

graph

API reference for @effx/ir/graph

graph.ts overview


Exports Grouped by Category


utils

GraphIndex (interface)

Working indexes over a normalized IR (ADR 0002). Never serialized. Edges whose endpoints are absent are kept in dangling so fromGraph loses nothing.

Signature

export interface GraphIndex {
  readonly graph: Graph.DirectedGraph<Node, Edge>
  readonly byId: HashMap.HashMap<StableId, Node>
  readonly indices: HashMap.HashMap<StableId, Graph.NodeIndex>
  readonly ids: Trie.Trie<StableId>
  readonly dangling: ReadonlyArray<Edge>
  readonly duplicates: ReadonlyArray<StableId>
}

MissingTarget (interface)

Signature

export interface MissingTarget {
  readonly edge: Edge
  readonly missing: ReadonlyArray<StableId>
}

cycles

Strongly connected components of size > 1, plus self-loops, as id lists.

Signature

declare const cycles: (index: GraphIndex) => ReadonlyArray<ReadonlyArray<StableId>>

fromGraph

Law: fromGraph(toGraph(x)) == normalize(x).

Signature

declare const fromGraph: (index: GraphIndex) => ApplicationIR

incoming

Incoming edges of id (including dangling ones), optionally filtered by kind.

Signature

declare const incoming: (index: GraphIndex, id: StableId, kind?: EdgeKind) => ReadonlyArray<Edge>

missingTargets

Edges that reference absent nodes — data, not a failure.

Signature

declare const missingTargets: (index: GraphIndex) => ReadonlyArray<MissingTarget>

nodeOf

Signature

declare const nodeOf: (index: GraphIndex, id: StableId) => Option.Option<Node>

outgoing

Outgoing edges of id (including dangling ones), optionally filtered by kind.

Signature

declare const outgoing: (index: GraphIndex, id: StableId, kind?: EdgeKind) => ReadonlyArray<Edge>

reachable

Ids reachable from id following edge direction (excluding id itself).

Signature

declare const reachable: (index: GraphIndex, id: StableId) => ReadonlyArray<StableId>

toGraph

Signature

declare const toGraph: (ir: ApplicationIR) => GraphIndex

withPrefix

Ids whose text starts with prefix, e.g. operation:User.. Alphabetical.

Signature

declare const withPrefix: (index: GraphIndex, prefix: string) => ReadonlyArray<StableId>

On this page