On Apr 8, 5:45 pm, "A.T.Hofkamp" <[EMAIL PROTECTED]> wrote:
> On 2008-04-08, [EMAIL PROTECTED] <[EMAIL PROTECTED]> wrote:
>
> [deleted a long piece of text by our BDFL about recursive graph path-finding 
> algorithm]
>
> > after first writing the inductive part ... for node in
> > graph[start] ....
> > and then by trial and error put square brackets around path in the
> > Basis part. Can someone please explain how to write this code. Thanks!
>
> The same as any other function.
> (the trick with recursive functions is not to think about recursion. Instead,
> pretend you are calling another function that happens to have the same name.)
>
> As for the actual procedure of writing a function:
>
> First define the input and output parameters/values of the function.
> (ie what goes in, and what comes out)
>
> For recursive functions, there are always two cases, a terminating case, and a
> reduction case. In the first case, you may not use the recursive function, in
> the latter function you should.
> Both cases should use the information available from the input parameters, and
> provide a result that matches with the output requirements of the function. 
> Add
> a if/then/else that distinguishes between what case you have, and you're done.
>
> Sincerely,
> Albert


OK so trying to follow your instructions I have-


def find_all_paths(graph, start, end, path=[]):


for node in graph[start]:

-- 
http://mail.python.org/mailman/listinfo/python-list

Reply via email to