#

Note

This documents the development version of NetworkX. Documentation for the current release can be found here.

#

networkx.classes.graphviews.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

G (networkx.DiGraph)

Returns

graph

Return type

networkx.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)])