[python] Breadth First Search
News
nickyncy na yahoo.com.hk
Středa Únor 8 18:41:22 CET 2006
I am going to implement breadth first search with Python and data will be
read from a text file where the structure of the file structure as follow
Could you give me any idea how to implement the program?
<total number of nodes>
<first node><second node><distance from first node to second node>
...
<end of file represented by -1>
The aims is to find out the shortest path(s) for the leaf node(s)
Example:
10
0 1 2
0 5 3
1 2 2
1 3 4
2 1 3
2 3 1
5 6 3
5 7 1
6 8 -1
7 8 1
7 9 2
9 5 3
-1
Possible solution:
Path=0,1,2,3 length=5
Path=0,5,6,8 length=5
Path=0,5,7,8 length=5
Thanks a lot!
Nicky.
Další informace o konferenci Python