reverse#
- reverse(G, copy=True)[source]#
Returns the reverse directed graph of G.
- Parameters:
- Gdirected graph
A NetworkX directed graph
- copybool
If True, then a new graph is returned. If False, then the graph is reversed in place.
- Returns:
- Hdirected graph
The reversed G.
- Raises:
- NetworkXError
If graph is undirected.
Examples
>>> G = nx.DiGraph([(1, 2), (1, 3), (2, 3), (3, 4), (3, 5)]) >>> G_reversed = nx.reverse(G) >>> G_reversed.edges() OutEdgeView([(2, 1), (3, 1), (3, 2), (4, 3), (5, 3)]) ----