in reply to breaking up undirected graphs
I'm not sure, but the bridges method may not work if the graph is not connected (the biconnectivity method computes the same information and has such a warning in the documentation).use Graph::Undirected; my $g = Graph::Undirected->new; $g->add_edges( map [ split /,/, $_ ], qw[ 1,2 1,4 2,3 3,4 4,7 7,8 7,10 8,9 9,10 ] ); my @bridges = $g->bridges; print "Found bridge(s):\n"; print " - @$_\n" for @bridges; $g->delete_edge(@$_) for @bridges; print "Resulting components:\n"; print " - @$_\n" for $g->connected_components; __END__ Found bridge(s): - 4 7 Resulting components: - 4 1 2 3 - 8 9 10 7
Update: showed how to remove bridges to obtain list of "clusters" that is induced.
blokhead
|
|---|