我有一个有向多重加权图。
我想找到a->;b->;c->;a的循环
我的图表样本。我希望它清楚:
v1 -> v2
v2 -> v3
v3 -> v1
v1 -> v4
v2 -> v5
如何只迭代目标节点?
这是我的鞋
^{pr2}$
我认为应该通过使用Gython语法来做出决定,这是Jython教程的摘录:
v1 -> v2 (or v2 <- v1): selects the directed edge from node v1 to node v2.
我的最终结果应该是:
results = [[v1,v2,v3]]
Tags:
当然有些图形库会带来这个功能。如果你想用手来做,也许这个片段(又快又脏,Dijkstra会杀了我)可能会给你一些提示:
(为了得到不止一个周期,我从v5添加了另一个顶点到v2)
相关问题 更多 >
编程相关推荐