[英]Finding all Circular path for undirected graph created using networkx
I am creating a undirected graph using networkx. 我正在使用networkx创建无向图。 I want to find all the possible circular path for specific nodes? 我想找到特定节点的所有可能循环路径吗? Is there any way to get those because I am unable to find a way? 有什么方法可以得到这些,因为我找不到方法?
Try: 尝试:
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)
Output: 输出:
[(0, 1), (1, 2), (2, 3), (3, 0)]
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.