Tag: 图 理论

find两个给定节点之间的path?

假设我有以下方式连接的节点,我如何到达给定点之间存在的path数目以及path细节? 1,2 //node 1 and 2 are connected 2,3 2,5 4,2 5,11 11,12 6,7 5,6 3,6 6,8 8,10 8,9 find从1到7的path: 答:find2条path 1,2,3,6,7 1,2,5,6,7 在这里find的实现很好,我将使用相同的 这里是上面的链接在Python中的片段 # a sample graph graph = {'A': ['B', 'C','E'], 'B': ['A','C', 'D'], 'C': ['D'], 'D': ['C'], 'E': ['F','D'], 'F': ['C']} class MyQUEUE: # just an implementation of a queue def […]