reverse_view#
- reverse_view(G)[source]#
G
的边方向反转视图reverse_view
返回输入图的一个只读视图,其中边方向被反转。等同于 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)])