MCPcopy Create free account
hub / github.com/easy-graph/Easy-Graph / copy

Method copy

easygraph/classes/graph.py:1293–1316  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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

Callers 15

cloneMethod · 0.95
_relabel_copyFunction · 0.45
add_nodes_fromMethod · 0.45
graph_to_d_atleast2Function · 0.45
k_coreFunction · 0.45
hull_layoutFunction · 0.45
simulateMethod · 0.45
_node_repulsionMethod · 0.45
_edge_repulsionMethod · 0.45
FloydFunction · 0.45
PrimFunction · 0.45
KruskalFunction · 0.45

Calls 3

updateMethod · 0.80
add_nodeMethod · 0.45
add_edgeMethod · 0.45

Tested by 1