[英]Finding all paths in graph, Python
I have a graph, represented in a way of a dictionary with pairs key|value - A node|Edges to other nodes
. 我有一个图,用字典的方式表示,
key|value - A node|Edges to other nodes
对是一对key|value - A node|Edges to other nodes
。 Example: 例:
{'5': '1 2 3 W', '0': '1 2 3 W', '2': '0 4 5 L', '1': '0 4 5 L', '4': '1 2 3 W', '3': '0 4 5 L'}
( W
and L
are the marks of the nodes) (
W
和L
是节点的标记)
What is the best approach to find all the paths WLWL
or LWLW
? 找到所有路径
WLWL
或LWLW
的最佳方法是什么? (Python 3.+) (Python 3. +)
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.