Beefy Boxes and Bandwidth Generously Provided by pair Networks
XP is just a number
 
PerlMonks  

Re: (Golf) Shortest Graph Distance

by chipmunk (Parson)
on May 12, 2001 at 00:15 UTC ( #79834=note: print w/replies, xml ) Need Help??

Help for this page

Select Code to Download


  1. or download this
    sub path {
    (*g,$f,$t)=@_;@s=map[$f,$_,$r{$_}],keys%{*r=$g{$f}};
    push@s,map[@p,$_,$d+$r{$_}],keys%{*r=$g{$n}}
    while(@s=sort{$b->[-1]<=>$a->[-1]}@s),$d=pop@{*p=pop@s},
    ($n=$p[-1])ne$t;@p
    }
    
  2. or download this
    sub path {
    (*g,$f,$t)=@_;@s=[$f,0];
    push@s,map[@p,$_,$d+$r{$_}],keys%{*r=$g{$n}}
    while(@s=sort{$b->[-1]<=>$a->[-1]}@s),$d=pop@{*p=pop@s},
    ($n=$p[-1])ne$t;@p
    }
    

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: note [id://79834]
help
Chatterbox?
[toolic]: Did you try more than once?
[choroba]: any URLs in the question?
[Copacetic]: I tried last night, and also this afternoon. I did include a link to CPAN originally, but I tried without it both times.
[choroba]: Can you copy the text to Copacetic's scratchpad ?

How do I use this? | Other CB clients
Other Users?
Others browsing the Monastery: (7)
As of 2017-05-26 14:53 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?