| 1677 | assertSameKind(self, that) |
| 1678 | return make(self.type)<N, E>((mutable) => { |
| 1679 | const copyInto = (graph: Graph<N, E, T>) => { |
| 1680 | const impl = internal.toImpl(graph) |
| 1681 | const indexMap = new Map<NodeIndex, NodeIndex>() |
| 1682 | |
| 1683 | for (const [oldIndex, data] of impl.nodes) { |
| 1684 | indexMap.set(oldIndex, addNode(mutable, data)) |
| 1685 | } |
| 1686 | |
| 1687 | for (const edge of impl.edges.values()) { |
| 1688 | const sourceIndex = indexMap.get(edge.source) |
| 1689 | const targetIndex = indexMap.get(edge.target) |
| 1690 | if (sourceIndex !== undefined && targetIndex !== undefined) { |
| 1691 | addEdge(mutable, sourceIndex, targetIndex, edge.data) |
| 1692 | } |
| 1693 | } |
| 1694 | } |
| 1695 | |
| 1696 | copyInto(self) |
| 1697 | copyInto(that) |