reverse_view#

reverse_view(G)[source]#

View of G with edge directions reversed

reverse_view returns a read-only view of the input graph where edge directions are reversed.

Identical to digraph.reverse(copy=False)

Parameters:
Gnetworkx.DiGraph
Returns:
graphnetworkx.DiGraph

Examples

>>> G = nx.DiGraph()
>>> G.add_edge(1, 2)
>>> G.add_edge(2, 3)
>>> G.edges()
OutEdgeView([(1, 2), (2, 3)])
>>> view = nx.reverse_view(G)
>>> view.edges()
OutEdgeView([(2, 1), (3, 2)])