MCPcopy Index your code
hub / github.com/networkx/networkx / reverse

Method reverse

networkx/classes/digraph.py:1344–1363  ·  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

1342 return G
1343
1344 def reverse(self, copy=True):
1345 """Returns the reverse of the graph.
1346
1347 The reverse is a graph with the same nodes and edges
1348 but with the directions of the edges reversed.
1349
1350 Parameters
1351 ----------
1352 copy : bool optional (default=True)
1353 If True, return a new DiGraph holding the reversed edges.
1354 If False, the reverse graph is created using a view of
1355 the original graph.
1356 """
1357 if copy:
1358 H = self.__class__()
1359 H.graph.update(deepcopy(self.graph))
1360 H.add_nodes_from((n, deepcopy(d)) for n, d in self.nodes.items())
1361 H.add_edges_from((v, u, deepcopy(d)) for u, v, d in self.edges(data=True))
1362 return H
1363 return nx.reverse_view(self)

Callers 15

test_reverse2Method · 0.95
test_reverse3Method · 0.95
test_reverse_copyMethod · 0.95
test_reverse_nocopyMethod · 0.95
test_reverse_hashableMethod · 0.95
test_directed_inwardMethod · 0.95
test_domrel_pngMethod · 0.95
test_boost_exampleMethod · 0.95
test_domrel_pngMethod · 0.95
test_boost_exampleMethod · 0.95
setup_classMethod · 0.95
setup_classMethod · 0.95

Calls 5

edgesMethod · 0.95
updateMethod · 0.45
add_nodes_fromMethod · 0.45
itemsMethod · 0.45
add_edges_fromMethod · 0.45

Tested by 15

test_reverse2Method · 0.76
test_reverse3Method · 0.76
test_reverse_copyMethod · 0.76
test_reverse_nocopyMethod · 0.76
test_reverse_hashableMethod · 0.76
test_directed_inwardMethod · 0.76
test_domrel_pngMethod · 0.76
test_boost_exampleMethod · 0.76
test_domrel_pngMethod · 0.76
test_boost_exampleMethod · 0.76
setup_classMethod · 0.76
setup_classMethod · 0.76