Returns a copy of the graph with the given list of nodes (and connecting edges). The layout will be reset.
(self, nodes=ALL)
| 561 | if k not in ("node1", "node2")) |
| 562 | |
| 563 | def copy(self, nodes=ALL): |
| 564 | """ Returns a copy of the graph with the given list of nodes (and connecting edges). |
| 565 | The layout will be reset. |
| 566 | """ |
| 567 | g = Graph(layout=None, distance=self.distance) |
| 568 | g.layout = self.layout.copy(graph=g) |
| 569 | for n in (nodes==ALL and self.nodes or (isinstance(n, Node) and n or self[n] for n in nodes)): |
| 570 | g._add_node_copy(n, root=self.root==n) |
| 571 | for e in self.edges: |
| 572 | g._add_edge_copy(e) |
| 573 | return g |
| 574 | |
| 575 | #--- GRAPH LAYOUT ---------------------------------------------------------------------------------- |
| 576 | # Graph drawing or graph layout, as a branch of graph theory, |