in reply to Knowledge of the Graph distribution

I would also recommend the Wolf book for the Graph module. With respect to your question Reducing HoH to AoA yesterday, here is a program to compute strongly connected components:
use Graph::Directed; my $g = Graph::Directed->new(); # Each pair is a pair of vertices qw|a b| indicating # a directed edge from a to b # graph: lineitem <-> invioce <-> claim <-> insurer $g->add_edges( qw| lineitem invoice invoice lineitem invoice claim insurer claim claim invoice claim insurer|); print "Strongly connected components: ", $g->strongly_connected_graph, + "\n";
Now when I run this, I get
Strongly connected components:
Which doesn't seem right; the graph above clearly has one strongly connected component. If I take out the invoice->claim edge, I get
Strongly connected components: insurer+claim-lineitem+invoice
which makes sense to me. Adding edges cannot reduce the connectivity of a graph, so Graph looks buggy to me.

Do others concur?

-Mark

Replies are listed 'Best First'.
Re: Re: Knowledge of the Graph distribution
by dragonchild (Archbishop) on Apr 02, 2004 at 17:44 UTC
    I'm also running into an infinite loop when I have a graph where not all the vertices are connected and I try to use SSSP_Dijkstra() on a vertex without edges.

    ------
    We are the carpenters and bricklayers of the Information Age.

    Then there are Damian modules.... *sigh* ... that's not about being less-lazy -- that's about being on some really good drugs -- you know, there is no spoon. - flyingmoose

Re: Re: Knowledge of the Graph distribution
by toma (Vicar) on Apr 04, 2004 at 15:10 UTC
    It looks to me like the Graph module has a bug in it. Since all the vertices in your example graph are strongly connected, a graph with a single vertex and no edges should be returned. However, it looks like the graph computed by strongly_connected_graph() is created by adding edges. There needs to be some logic added to copy the single vertex if there are no edges.

    The strongly_connected_components() method does return all four vertices.

    I have sent Jarkko a suggestion for how to fix this, msg me if you need a copy.

    Update:
    Keep asking, and you will receive.
    Jarkko has just released Graph-0.20102, a bug-fix release, which includes the fix mentioned above and others.

    Update #2:
    Jarkko notes that he does not claim that the module is bug-free as of now.

    It should work perfectly the first time! - toma