Beefy Boxes and Bandwidth Generously Provided by pair Networks
Syntactic Confectionery Delight
 
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?
and the web crawler heard nothing...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (16)
As of 2014-10-30 13:50 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    For retirement, I am banking on:










    Results (208 votes), past polls