in reply to Graph model problem.

Having looked over your code, I think I found your problem, and I have a few other comments.

The only substantial change I made was the assignment to @nodevalues in the cpt sub. It now reads:

my @nodevalues= map { [ @{$_} ] } @{$_[2]};

The reason why that helps is that $_[2] is a reference to an array containing other array references. What my change does is copy the arrays in the main array instead of copying the references. This is important because further down in your code, you do "shift @{$temparray[$i]};", which modifies one of those arrays. Without my modification, here is what happens. Before the first call to cpt, this is what $values looks like:

$VAR1 = [ [ 'sprinkler', 't', 'f' ], [ 'cloudy', 't', 'f' ], [ 'rain', 't', 'f' ], [ 'wetgrass', 't', 'f' ] ];

After the first call to cpt, it looks like this:

$VAR1 = [ [ 't', 'f' ], [ 't', 'f' ], [ 'rain', 't', 'f' ], [ 'wetgrass', 't', 'f' ] ];

Notice that the first two arrays have been modified. The above is the output of Data::Dumper, by the way. It's a pretty good way of visualizing your data structures.

The fix I've shown will help this particular problem, but it would not have helped if the data structure involved were another level deep. For a more general solution to this kind of problem have a look at merlyn's column Deep copying, not Deep secrets.

My other comments, briefly: