简体   繁体   English

查找使用networkx创建的无向图的所有循环路径

[英]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.

相关问题 在无向图中找到一个圆 - Finding a circle in an undirected graph 使用邻接表的无向加权图上的最小成本路径 - Minimum cost path on a undirected weighted graph using an adjacency list 是否可以在networkx中向图形对象添加无方向和有向边? - Is it possible to add undirected and directed edges to a graph object in networkx? 在python中的networkx图中查找最大加权边 - Finding maximum weighted edge in a networkx graph in python 如何使用python在无向图中找到所有可能的路径? - How can I find all possibly paths in undirected graph using python? 贪心图着色使用.networkx - Greedy graph coloring using networkx 无源和目标顶点的无向加权图的最短路径 - Shortest path for undirected weighted graph without source and target vertices 使用有向图与无向图的可见集 - Using a seen set for a directed graph vs. undirected graph 如何使用networkx + python枚举图中的所有*最大*集团? - How do I enumerate all *maximal* cliques in a graph using networkx + python? 如何使用 Python 中的 networkx 或 graphviz 为旅行商问题中的所有可能路径自动创建有向图? - How to automate creating directed graph using networkx or graphviz in Python for all possible paths in a travelling salesman problem?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM