in reply to Re: using Graph::Undirected
in thread using Graph::Undirected
btw, I do construct the graph, I just missed that in the example, trying to keep it minimal.
One clarification, my input data would look more like:
so not all the vertices are connected, and in fact what I need to get out of this are the sets that are. so what I do is:my @combos = ( [qw(black white)], [qw(red white)], [qw(cyan red)], [qw(yellow blue)], [qw(magenta green blue)], [qw(cyan periwinkle raspberry)], );
This however doesn't seem terribly elegant (or efficient), am I anywhere near what I should be doing in this case?sub r { my $g = shift; my $v = shift; my @ns = $g->neighbors($v); print $v."\n"; $g->delete_vertex($v); foreach my $n (@ns){ r($g, $n); } } while (scalar $g->vertices > 0){ print "next set:\n"; r($g, ($g->vertices)[0]); }
and thanks for your great help!
|
|---|