找到适合无向图中所有的圆弧路径使用networkx创建

问题描述 投票:0回答:1

我使用networkx创造一个无向图。我想找到的所有特定的节点可能圆形路径?有没有什么办法让那些因为我无法找到一个方法?

python-3.x networkx
1个回答
0
投票

尝试:

import pandas as pd
import networkx as nx

df = pd.DataFrame({'Source':[0,1,2,0,16,17,18,0,16,19,1,2],'Target':[1,2,3,3,17,18,19,16,19,3,17,18]})

G = nx.from_pandas_edgelist(df, 'Source', 'Target')

nx.cycles.find_cycle(G)

输出:

[(0, 1), (1, 2), (2, 3), (3, 0)]
© www.soinside.com 2019 - 2024. All rights reserved.