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

Method copy

easygraph/classes/directed_graph.py:1050–1073  ·  view source on GitHub ↗

Return a deep copy of the graph. Returns ------- copy : easygraph.DiGraph 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

1048 return False
1049
1050 def copy(self):
1051 """Return a deep copy of the graph.
1052
1053 Returns
1054 -------
1055 copy : easygraph.DiGraph
1056 A deep copy of the original graph.
1057
1058 Examples
1059 --------
1060 *G2* is a deep copy of *G1*
1061
1062 >>> G2 = G1.copy()
1063
1064 """
1065 G = self.__class__()
1066 G.graph.update(self.graph)
1067 for node, node_attr in self._node.items():
1068 G.add_node(node, **node_attr)
1069 for u, nbrs in self._adj.items():
1070 for v, edge_data in nbrs.items():
1071 G.add_edge(u, v, **edge_data)
1072
1073 return G
1074
1075 def nodes_subgraph(self, from_nodes: list):
1076 """Returns a subgraph of some nodes

Callers 1

add_nodes_fromMethod · 0.45

Calls 3

updateMethod · 0.80
add_nodeMethod · 0.45
add_edgeMethod · 0.45

Tested by

no test coverage detected