zing has asked for the wisdom of the Perl Monks concerning the following question:
------------OUTPUT----------------------Code my @a=qw(a b d); my @b=qw(c c e); my $g = Graph->new( undirected => 1 ); for (my $r = 0; $r <= 2; $r++) { $g->add_edge($a[$r], $b[$r]); } my @subgraphs = $g->connected_components; my $V = $g->vertices; print "\n$V\n"; print "----connected components------------"; use YAML; print Dump \@subgraphs;
My question is how do I access only one of the connected components? I.e. either C-A-B or D-E . Also how do I find the total number of connected components.5 ----connected components--------------- - - c - a - b - - e - d
|
|---|
| Replies are listed 'Best First'. | |
|---|---|
|
Re: Finding connected components in a graph.
by choroba (Cardinal) on Oct 02, 2012 at 18:20 UTC | |
by zing (Beadle) on Oct 03, 2012 at 15:50 UTC | |
by choroba (Cardinal) on Oct 03, 2012 at 15:56 UTC | |
by zing (Beadle) on Oct 03, 2012 at 16:04 UTC | |
|
Re: Finding connected components in a graph.
by SuicideJunkie (Vicar) on Oct 02, 2012 at 18:15 UTC | |
by zing (Beadle) on Oct 02, 2012 at 18:25 UTC | |
by SuicideJunkie (Vicar) on Oct 02, 2012 at 18:32 UTC | |
|
Re: Finding connected components in a graph.
by remiah (Hermit) on Oct 02, 2012 at 20:57 UTC | |
by zing (Beadle) on Oct 03, 2012 at 15:55 UTC |