Return a deep copy of the graph. Returns ------- copy : easygraph.Graph A deep copy of the original graph. Examples -------- *G2* is a deep copy of *G1* >>> G2 = G1.copy()
(self)
| 1291 | return False |
| 1292 | |
| 1293 | def copy(self): |
| 1294 | """Return a deep copy of the graph. |
| 1295 | |
| 1296 | Returns |
| 1297 | ------- |
| 1298 | copy : easygraph.Graph |
| 1299 | A deep copy of the original graph. |
| 1300 | |
| 1301 | Examples |
| 1302 | -------- |
| 1303 | *G2* is a deep copy of *G1* |
| 1304 | |
| 1305 | >>> G2 = G1.copy() |
| 1306 | |
| 1307 | """ |
| 1308 | G = self.__class__() |
| 1309 | G.graph.update(self.graph) |
| 1310 | for node, node_attr in self._node.items(): |
| 1311 | G.add_node(node, **node_attr) |
| 1312 | for u, nbrs in self._adj.items(): |
| 1313 | for v, edge_data in nbrs.items(): |
| 1314 | G.add_edge(u, v, **edge_data) |
| 1315 | |
| 1316 | return G |
| 1317 | |
| 1318 | def nodes_subgraph(self, from_nodes: list): |
| 1319 | """Returns a subgraph of some nodes |