Beefy Boxes and Bandwidth Generously Provided by pair Networks
good chemistry is complicated,
and a little bit messy -LW
 
PerlMonks  

List Connection

by artist (Parson)
on Oct 16, 2008 at 11:44 UTC ( #717455=perlquestion: print w/replies, xml ) Need Help??
artist has asked for the wisdom of the Perl Monks concerning the following question:

Dear Monks
I have several lists with different items in them. In the list, the items doesn't repeat. An item can exist in the multiple list. Given 2 items, I like to find lists connecting these 2 items. There could be several path and I like to know different possibility, starting with the shortest-path.

Update: Ahh: Sorry if it looked like a homework question.( I just passed the Turing test) Certainly this is not a homework. This is for the project I am working on. I think that several CPAN modules can do the trick. Ultimately I like to find path from point A to B which can involve multiple pre-defined nodes. I also like to find out the path where given any 2 nodes to connect, the path should that should be taken have adjacent lists with maximum common elements ( rather than just one ) if possible.
Think of this as DNS routing problem. It is also close to traveling salesman problem. I like to probably learn from the other threads having similar problems.

--Artist

Replies are listed 'Best First'.
Re: List Connection
by JavaFan (Canon) on Oct 16, 2008 at 12:15 UTC
    Consider each list to be a node in a graph. Between two nodes there's an edge, if and only if both lists have an item in common.

    Now your problem can be solved by using Dijkstra's algorithm.

    Does this help with your homework?

      Ahh: Sorry if it looked like a homework question.( I just passed the Turing test) Certainly this is not a homework. This is for the project I am working on. I think that several CPAN modules can do the trick. Ultimately I like to find path from point A to B which can involve multiple pre-defined nodes. I also like to find out the path where given any 2 nodes to connect, the path should that should be taken have adjacent lists with maximum common elements ( rather than just one ) if possible.
      Think of this as DNS routing problem. It is also close to traveling salesman problem. I like to probably learn from the other threads having similar problems.

      --Artist
Re: List Connection
by svenXY (Deacon) on Oct 16, 2008 at 11:57 UTC
    smells a lot like homework...
    What have you tried yourself so far?

    Cheers, Sven

Log In?
Username:
Password:

What's my password?
Create A New User
Node Status?
node history
Node Type: perlquestion [id://717455]
Approved by svenXY
help
Chatterbox?
[Discipulus]: marto lives above Vallo Adriano, i think
[Discipulus]: Anyway many years passed, we had Perl 3 iirc.. ;=)
[1nickt]: erix looking ... which one?
[1nickt]: Ah hm, the article sction links don;t match the sections. Lowerdown there is info and a map

How do I use this? | Other CB clients
Other Users?
Others meditating upon the Monastery: (11)
As of 2017-11-21 12:15 GMT
Sections?
Information?
Find Nodes?
Leftovers?
    Voting Booth?
    In order to be able to say "I know Perl", you must have:













    Results (299 votes). Check out past polls.

    Notices?