laziness, impatience, and hubris PerlMonks

### Re: Finding connected components in a graph.

by choroba (Bishop)
 on Oct 02, 2012 at 18:20 UTC ( #996889=note: print w/replies, xml ) Need Help??

in reply to Finding connected components in a graph.

```print "Number: ", scalar @subgraphs, "\n";
print "First: ", @{ \$subgraphs[0] }, "\n";
Update: If you also want to generate the subgraphs corresponding to the components, you can use the following code:
```my @subg;
for my \$component (0 .. @subgraphs - 1) {
\$subg[\$component] = Graph::Undirected->new;
for my \$i (0 .. \$#a) {
if grep \$_ eq \$a[\$i], @{ \$subgraphs[\$component] };
}
}
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ

Replies are listed 'Best First'.
Re^2: Finding connected components in a graph.
by zing (Beadle) on Oct 03, 2012 at 15:50 UTC
Hi guys, I have this code which takes in input in the form of triplets of vertices(see DATA)
```use strict;
use warnings;
use Data::Dumper;

my @S;
while (<DATA>) {
push @S, [split];
}
print "-----TRIPLETS-------\n";
print Dumper \@S;

__DATA__
b c a
a c d
d e b
What Im stuck with is this :: Suppose I have these points=(a,b,c,d); Then I want to find the set of triplets induced by these 4 vertices. For example for above four points the induced triplets should be:
```b c a
a c d
Whereas for vertices=(d,e,a) there isn't any triplet in the data.

Similarly for vertices=(b,e,d) there is a triplet (d e b) in the data(the last one).

This is barely related to the post you replied to. Please, if you have a new question, start a new thread. It can bring you more attention.
لսႽ† ᥲᥒ⚪⟊Ⴙᘓᖇ Ꮅᘓᖇ⎱ Ⴙᥲ𝇋ƙᘓᖇ
Thanks for the suggestion choroba.

Create A New User
Node Status?
node history
Node Type: note [id://996889]
help
Chatterbox?
and all is quiet...

How do I use this? | Other CB clients
Other Users?
Others drinking their drinks and smoking their pipes about the Monastery: (8)
As of 2018-03-19 17:27 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
When I think of a mole I think of:

Results (245 votes). Check out past polls.

Notices?