http://qs1969.pair.com?node_id=79911


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