Hyperlinkv0.8.0-beta.28

Graph

Graph.endMutationconsteffect/Graph.ts:525
<N, E, T extends Kind = "directed">(
  mutable: MutableGraph<N, E, T>
): Graph<N, E, T>

Converts a mutable graph back to an immutable graph, ending the mutation scope.

Example (Ending a mutation scope)

import { Graph } from "effect"

const graph = Graph.directed<string, number>()
const mutable = Graph.beginMutation(graph)
// ... perform mutations on mutable ...
const newGraph = Graph.endMutation(mutable)
mutations
Source effect/Graph.ts:52516 lines
export const endMutation = <N, E, T extends Kind = "directed">(
  mutable: MutableGraph<N, E, T>
): Graph<N, E, T> => {
  const graph: Mutable<Graph<N, E, T>> = Object.create(ProtoGraph)
  graph.type = mutable.type
  graph.nodes = new Map(mutable.nodes)
  graph.edges = new Map(mutable.edges)
  graph.adjacency = mutable.adjacency
  graph.reverseAdjacency = mutable.reverseAdjacency
  graph.nextNodeIndex = mutable.nextNodeIndex
  graph.nextEdgeIndex = mutable.nextEdgeIndex
  graph.acyclic = mutable.acyclic
  graph.mutable = false

  return graph
}
Referenced by 3 symbols