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

Method reverse

easygraph/classes/directed_multigraph.py:395–417  ·  view source on GitHub ↗

Returns the reverse of the graph. The reverse is a graph with the same nodes and edges but with the directions of the edges reversed. Parameters ---------- copy : bool optional (default=True) If True, return a new DiGraph holding the reversed edg

(self, copy=True)

Source from the content-addressed store, hash-verified

393 return G
394
395 def reverse(self, copy=True):
396 """Returns the reverse of the graph.
397
398 The reverse is a graph with the same nodes and edges
399 but with the directions of the edges reversed.
400
401 Parameters
402 ----------
403 copy : bool optional (default=True)
404 If True, return a new DiGraph holding the reversed edges.
405 If False, the reverse graph is created using a view of
406 the original graph.
407 """
408 if copy:
409 H = self.__class__()
410 H.graph.update(deepcopy(self.graph))
411 H.add_nodes_from((n, deepcopy(d)) for n, d in self._node.items())
412 H.add_edges_from(
413 (v, u, k, deepcopy(d))
414 for u, v, k, d in self.edges(keys=True, data=True)
415 )
416 return H
417 return eg.graphviews.reverse_view(self)

Callers 3

get_community_kernelFunction · 0.80

Calls 4

edgesMethod · 0.95
updateMethod · 0.80
add_nodes_fromMethod · 0.45
add_edges_fromMethod · 0.45

Tested by

no test coverage detected