in reply to Reducing HoH to AoA

Since you did not give the algorithm or example code for conversion, its hard to know exactly what you want. I'll take a guess.

What you have is an adjacency list representation of a graph, and it looks like you want to find all the connected components of that graph and put them into a list. If that is so, then the second example is ok, since you can get to all the nodes by following the links from 'lineitem'.

If you see a problem with the second example, perhaps you are looking for the strongly connected components of a graph, with each element of a component connected to every other component of the graph.

The easiest way to approach this is to use the perl module Graph:

use Graph::Directed; $G = new Graph::Directed; # ... add vertices, edges @S = $G->strongly_connected_components; # Returns the strongly connected components @S of the # graph $G as a list of anonymous lists of vertices, # each anonymous list containing the vertices #belonging to one strongly connected component.

-Mark

Replies are listed 'Best First'.
Re: Re: Reducing HoH to AoA
by dragonchild (Archbishop) on Apr 01, 2004 at 16:35 UTC
    Heh. I used Graph to come up with the HoH. I didn't even think of using Graph to generate the AoA I needed. (The documentation is not that easy to work through if you don't have a good grasp of Graph Theory already ...)

    Thank you very much.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose