On Apr 9, 8:12 pm, "A.T.Hofkamp" <[EMAIL PROTECTED]> wrote: > On 2008-04-09, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote: > > > > > > > On Apr 8, 5:45 pm, "A.T.Hofkamp" <[EMAIL PROTECTED]> wrote: > > Ok following these instructions one gets > > > def find_all_paths(graph, start, end, path=[]): > > path= path+ [start] > > > for node in graph[start]: > > > find_all_paths(graph, node, end, path) > > >> First define the input and output parameters/values of the function. > >> (ie what goes in, and what comes out) > > > Now what will be the output parameters - there is a Return statement. > > Input parameters are graph, vertexes start, node, end and path. Also > > how would you write the terminating and reduction cases after this. > > Actually i'm not clear how to proceed writing this recursive function. > > Thanks! > > Don't look at code, don't even think about it (it gives you too much confusing > details). > > Instead, have a beer, sit down in a sunny spot, and do mothing for a while. > > Think about the function as a (black) box. You don't know what is in it (it is > not important yet). That box is the function (many people prefer to draw a > rectangular shape on a sheet of paper, and consider that to be the function). > What data does the box need to do its work, and what does it produce after > it has done its work? > > (suppose you are given the task of 'finding all paths'. What information do > you > need to acomplish this task, and what information do you write down as > result?) > > A simple example of a multiplication task: One needs 2 numbers to do the task, > and the result is another number. Note that at this stage, you don't worry > about HOW you do the task, only WHAT GOES IN AND WHAT COMES OUT. > (actually, HOW depends on INPUT. Multiplication of 2 and 5 can be done > differently from multiplication of > 230698762085269459068388639078903870385790368703879038285790 and > 5938063786093895682682968390789380834687387689762897. For this reason, > deciding > the strategy of solving the problem comes after establishing input and > output). > > Sincerely, > Albert > PS email will give you shorter response times.- Hide quoted text - > > - Show quoted text - Hello,
Thank you for the suggestion of relaxing! After that the black box function you mentioned looks like this- Output- path1 path 2 | ... path n | | | ---------------------- | | | | | function -find_ | | _all_paths() | | | ---------------------- | | | | Input - graph, start, end i.e. you give, the graph, the start and end vertices as inputs and you get the output as a listing of all the paths. This is where I got to. It would be very nice if you could kindly hint on how to proceed further. Thank you so much for your time! Thanks & Regards, Anshu -- http://mail.python.org/mailman/listinfo/python-list