( mutable: MutableGraph<N, E, T> )
| 637 | * @since 3.18.0 |
| 638 | */ |
| 639 | export const endMutation = <N, E, T extends Kind = "directed">( |
| 640 | mutable: MutableGraph<N, E, T> |
| 641 | ): Graph<N, E, T> => { |
| 642 | assertMutable(mutable) |
| 643 | const source = graphImpl(mutable) |
| 644 | |
| 645 | const graph: Mutable<GraphImpl<N, E, T>> = Object.create(ProtoGraph) |
| 646 | graph.type = source.type |
| 647 | graph.nodes = new Map(source.nodes) |
| 648 | graph.edges = new Map(source.edges) |
| 649 | graph.adjacency = cloneAdjacency(source.adjacency) |
| 650 | graph.reverseAdjacency = cloneAdjacency(source.reverseAdjacency) |
| 651 | graph.nextNodeIndex = source.nextNodeIndex |
| 652 | graph.nextEdgeIndex = source.nextEdgeIndex |
| 653 | graph.acyclic = source.acyclic |
| 654 | graph.mutable = false |
| 655 | source.mutable = false |
| 656 | |
| 657 | return graph as unknown as Graph<N, E, T> |
| 658 | } |
| 659 | |
| 660 | /** @internal */ |
| 661 | const mutateScoped = <N, E, T extends Kind>( |
no test coverage detected