| 1414 | assertSameKind(self, that) |
| 1415 | return make(self.type)<N, E>((mutable) => { |
| 1416 | const copyInto = (graph: Graph<N, E, T>) => { |
| 1417 | const impl = graphImpl(graph) |
| 1418 | const indexMap = new Map<NodeIndex, NodeIndex>() |
| 1419 | |
| 1420 | for (const [oldIndex, data] of impl.nodes) { |
| 1421 | indexMap.set(oldIndex, addNode(mutable, data)) |
| 1422 | } |
| 1423 | |
| 1424 | for (const edge of impl.edges.values()) { |
| 1425 | const sourceIndex = indexMap.get(edge.source) |
| 1426 | const targetIndex = indexMap.get(edge.target) |
| 1427 | if (sourceIndex !== undefined && targetIndex !== undefined) { |
| 1428 | addEdge(mutable, sourceIndex, targetIndex, edge.data) |
| 1429 | } |
| 1430 | } |
| 1431 | } |
| 1432 | |
| 1433 | copyInto(self) |
| 1434 | copyInto(that) |