<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=big5">
<META content="MSHTML 6.00.2900.2802" name=GENERATOR>
<STYLE></STYLE>
</HEAD>
<BODY bgColor=#ffffff>
<DIV><FONT face=Arial size=2>Hi,</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>I would like to implement a breadth first serach
with Python and read data from a text file with following file
format</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>File structure description</FONT></DIV>
<DIV><FONT face=Arial size=2>First line contains number of node</FONT></DIV>
<DIV><FONT face=Arial size=2>Second line contains node id(s) and distance
between node id</FONT></DIV>
<DIV><FONT face=Arial size=2>Last line is -1</FONT></DIV>
<DIV><FONT face=Arial size=2><number of node></FONT></DIV>
<DIV><FONT face=Arial size=2><N1><N2><W1> Each node or
distance is separated by space</FONT></DIV>
<DIV><FONT face=Arial size=2>-1</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>For the example below, first line represent number
of node is 10, second line contains first node id 0, second node id 1, distance
between node id 0 and node id 1 is 2</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>0 is the root (starting node), the aim of the
searching program is to find out the shortest path from 0 to a leaf node
and print out the node path and value the path distance</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Could you give me any idea how to implement this
search program with Python?</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Example:</FONT></DIV>
<DIV><FONT face=Arial size=2>10<BR>0 1 2<BR>0 5 3<BR>1 2 2<BR>1 3 4<BR>2 1
3<BR>2 3 1<BR>5 6 3<BR>5 7 1<BR>6 8 1<BR>7 8 1<BR>7 9 2<BR>9 5
3<BR>-1</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Outcome:</FONT><FONT face=Arial size=2><BR>Possible
solution:<BR>Path=0,1,2,3 length=5<BR>Path=0,5,6,8 length=5<BR>Path=0,5,7,8 length=5</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Thank you for your help.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV>
<DIV><FONT face=Arial size=2>Nicky.</FONT></DIV>
<DIV><FONT face=Arial size=2></FONT> </DIV></BODY></HTML>