in reply to Graphical structure problem

Looking at your parentchildrelationship sub, I can't see how it's defining a tree of any kind. Either 'a' has two parents or 'b' has two parents.

It would help us to know what kind of output you're expecting. One thing I notice is that you print $nodeparents, but that's an array reference. You might want to look at Data::Dumper to see the contents of it.

Replies are listed 'Best First'.
Re^2: Tree structure problem
by newbio (Beadle) on May 08, 2007 at 17:50 UTC

    Parent child relationship is defined in sub parentchildrelationship in hash %parentchild as 'a'=>['b','d'], where node 'a' has two parents, 'b','d'.

    Result for the first foreach iteration, ie for $nodes[\0] is shown below (and this result is correct). The first line is the header with names of the nodes (target node here is 'a' and its parents are 'd' and 'b'). All other remaining lines represent combinations of all different values that the nodes can assume. However, I am getting incorrect results for $nodes[\1], $nodes[\2], and others. Please remove backslash from the array elements because I cannot figure out how to correctly write $nodes[\0] without a backslash. Wow, formatting appears a huge task here...any reason to make it complex. I hope this formatting works out..:)

    Output:
    d b a =>1
    abv f r=>1
    abv t r=>1
    abv f q=>1
    avb t q=>1
    avb t p=>1
    avb f p=>1
    avb f r=>1
    abv t q=>1
    abv t p=>1
    avb t r=>1
    vab t r=>1
    vab f r=>1
    vab f q=>1
    vab t p=>1
    abv f p=>1
    avb f q=>1
    vab f p=>1
    vab t q=>1