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

by remiah (Hermit)
 on Oct 02, 2012 at 20:57 UTC ( #996918=note: print w/replies, xml ) Need Help??

in reply to Finding connected components in a graph.

Hello zing

I was looking at the same Graph module for several days...
I want to ask the same question for directed graph. I wonder if this module lacks for 'list all path', or whether I miss something.

You can list all shortest path in your graph, if you do like this.

```use strict;
use warnings;
use Graph;

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++) {
}

#get path from apsp
my \$apsp=\$g->APSP_Floyd_Warshall();

#...with all pattern using glob
my @v=\$g->vertices;
my \$ptn=join(",", @v);
for (glob "{\$ptn},{\$ptn}"){
my(\$u,\$v)=split(/,/, \$_);
next if( \$u eq \$v );    #skip same combination, or ignore self cyc
+le
my @p=\$apsp->path_vertices(\$u,\$v);
if (@p){
print join(',', @p), "\n";
}
}
So, for just listing all path, it may be faster if I do recursive call by myself. I am feeling missing something.

I would like to ask for a good way, if you find one.
regards.

Replies are listed 'Best First'.
Re^2: Finding connected components in a graph.
by zing (Beadle) on Oct 03, 2012 at 15:55 UTC
Dear remiah, I'll certainly look into that(as I do need what you are doing) and will let you know when i cross over your problem and a solution for the same very soon.

Create A New User
Node Status?
node history
Node Type: note [id://996918]
help
Chatterbox?
 [shmem]: stevieb: thanks! new thing learned, done for today ;-) [stevieb]: hahaha! Some days I wish I could quit after learning one new thing. Often that happens before I'm one my first coffee ;) [MidLifeXis]: OHHHH. Mea culpa - I read that as coderef (facepalm) [stevieb]: mlx: That's easy to have done in that context. For those who don't know, it converts itself into the current sub name, much like __PACKAGE__ translates into the current package name (or class)

How do I use this? | Other CB clients
Other Users?
Others wandering the Monastery: (12)
As of 2017-05-24 17:32 GMT
Sections?
Information?
Find Nodes?
Leftovers?
Voting Booth?
My favorite model of computation is ...

Results (185 votes). Check out past polls.