Beefy Boxes and Bandwidth Generously Provided by pair Networks
go ahead... be a heretic
 
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 musing on the Monastery: (9)
As of 2014-12-18 06:58 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    Is guessing a good strategy for surviving in the IT business?





    Results (44 votes), past polls