( graph: Graph<N, E, T> )
| 594 | * @since 3.18.0 |
| 595 | */ |
| 596 | export const beginMutation = <N, E, T extends Kind = "directed">( |
| 597 | graph: Graph<N, E, T> |
| 598 | ): MutableGraph<N, E, T> => { |
| 599 | const source = graphImpl(graph) |
| 600 | const adjacency = cloneAdjacency(source.adjacency) |
| 601 | const reverseAdjacency = cloneAdjacency(source.reverseAdjacency) |
| 602 | |
| 603 | const mutable: Mutable<GraphImpl<N, E, T>> = Object.create(ProtoGraph) |
| 604 | mutable.type = source.type |
| 605 | mutable.nodes = new Map(source.nodes) |
| 606 | mutable.edges = new Map(source.edges) |
| 607 | mutable.adjacency = adjacency |
| 608 | mutable.reverseAdjacency = reverseAdjacency |
| 609 | mutable.nextNodeIndex = source.nextNodeIndex |
| 610 | mutable.nextEdgeIndex = source.nextEdgeIndex |
| 611 | mutable.acyclic = source.acyclic |
| 612 | mutable.mutable = true |
| 613 | |
| 614 | return Equal.byReferenceUnsafe(mutable as unknown as MutableGraph<N, E, T>) |
| 615 | } |
| 616 | |
| 617 | /** |
| 618 | * Converts a mutable graph back to an immutable graph, ending the mutation scope. |
no test coverage detected