Beefy Boxes and Bandwidth Generously Provided by pair Networks
Don't ask to ask, just ask
 
PerlMonks  

Re: (Golf) Shortest Graph Distance

by chipmunk (Parson)
on May 12, 2001 at 00:15 UTC ( [id://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
Domain Nodelet?
Node Status?
node history
Node Type: note [id://79834]
help
Chatterbox?
and the web crawler heard nothing...

How do I use this?Last hourOther CB clients
Other Users?
Others taking refuge in the Monastery: (2)
As of 2024-04-16 23:11 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?

    No recent polls found