Beefy Boxes and Bandwidth Generously Provided by pair Networks
Perl Monk, Perl Meditation

Comment on

( #3333=superdoc: print w/replies, xml ) Need Help??
Just FYI, this isn't much like the Travelling Salesman Problem (or TSP) as that requires a path that visits every node in the network, usually for a minimum cost (there are many variations, such as using each link only once, etc.) which is probably not what you are after. In any case you should find some valuable tools on the CPAN in Graph as Fletch advises.

Update: Graph is not so complicated, though you could argue it is overkill for this simple example:

use strict; use warnings; use Graph; my $net = Graph::Undirected->new; # links go both ways my $start = ''; my $end = ''; while(<DATA>) { chomp(my($from,$to) = (split /\s+[^\d.]+\s+/)[0,1]); if($net->has_edge($from,$to) ) { print "duplication of $from to $to\n"; # shows Graph understands u +ndirected links }else{ $net->add_edge($from, $to); print "link from $from to $to added\n"; } } print "the nodes are: ", join(', ', sort $net->vertices), "\n"; print "the links are: ",$net, "\n"; print "a shortest path from $start to $end is: ", join ' => ', $net->S +P_Dijkstra($start,$end); __DATA__ links with links with links with links with links with links with links with links with links with links with
link from to added duplication of to link from to added duplication of to link from to added duplication of to link from to added duplication of to link from to added duplication of to the nodes are:,,, the links are:,,, +=, a shortest path from to is: => => 1.2. +3.6

I'd like to be able to assign to an luser

In reply to Re: traversing a hash looking for path? by Albannach
in thread traversing a hash looking for path? by Anonymous Monk

Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post; it's "PerlMonks-approved HTML":

  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.
  • Log In?

    What's my password?
    Create A New User
    [davido]: wow, he's back again
    [prathap keerthipati]: what are the possible cases for getting 500 cannot connection issue

    How do I use this? | Other CB clients
    Other Users?
    Others drinking their drinks and smoking their pipes about the Monastery: (9)
    As of 2017-03-23 05:51 GMT
    Find Nodes?
      Voting Booth?
      Should Pluto Get Its Planethood Back?

      Results (282 votes). Check out past polls.