[python] Breadth First Search

Petr Prikryl PrikrylP na skil.cz
Čtvrtek Únor 9 08:06:59 CET 2006


Please, try the English speaking mailing list 'python-list na python.org'.

pepr

> -----Original Message-----
> From: python-bounces na py.cz [mailto:python-bounces na py.cz] On 
> Behalf Of News
> Sent: Wednesday, February 08, 2006 6:41 PM
> To: python na py.cz
> Subject: [python] Breadth First Search
> 
> 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