Beefy Boxes and Bandwidth Generously Provided by pair Networks
The stupid question is the question not asked
 
PerlMonks  

Re: (Golf) Shortest Graph Distance

by MeowChow (Vicar)
on May 12, 2001 at 08:28 UTC ( #79911=note: print w/ replies, xml ) Need Help??


in reply to (Golf) Shortest Graph Distance

Here's a recursive strict and -w compliant sub at 94 chars for the related problem of enumerating all possible paths (without cycles) from A to B:

sub p { my($g,$s,$e,%v)=@_;$s eq$e?[$e]:map{map[$s,@$_],p($g,$_,$e,%v,$s,1)} +grep!$v{$_},keys%{$$g{$s}} }
   MeowChow                                   
               s aamecha.s a..a\u$&owag.print


Comment on Re: (Golf) Shortest Graph Distance
Download Code

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://79911]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others scrutinizing the Monastery: (15)
As of 2015-07-28 20:12 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    The top three priorities of my open tasks are (in descending order of likelihood to be worked on) ...









    Results (258 votes), past polls