0

Well i have store into a dictionary a graph.The graph has no cycles and looks like:

G={1:[2,3,4],2:[1],3:[1],4:[1,5],5:[4]}

So in the above example node 1 is connected to node 2,3,4, node 2 is connectes to node 1 etc.. Note that any graph G is undirected!

Now, let's have one specific node and let's call them node K. I want to make a dictionary to save for any node which is the path that connect this node and node K.

Also, i want to save in one dictionary for any node how many nodes have path connection to node K, and this path includes this node.

I believe for the first problem it's not necessary to run Dijkstra's algorithm because the graph is acyclic with no cost.

Any advice would be usefull, Thx in advance

Chris P
  • 2,059
  • 4
  • 34
  • 68
  • possible duplicate of http://stackoverflow.com/questions/2606018/python-path-between-two-nodes and . . http://stackoverflow.com/questions/3278481/list-of-all-paths-from-source-to-sink-in-directed-acyclic-graph – namit Apr 27 '13 at 11:36
  • Duplicate after saying "use [`networkx`](http://networkx.github.io/)" ;) – Felipe Apr 27 '13 at 12:56

0 Answers0