#13665: New implementation of the blocks_and_cut_vertices method
---------------------------------+------------------------------------------
Reporter: dcoudert | Owner: jason, ncohen, rlm
Type: enhancement | Status: needs_review
Priority: major | Milestone: sage-5.5
Component: graph theory | Resolution:
Keywords: | Work issues:
Report Upstream: N/A | Reviewers:
Authors: David Coudert | Merged in:
Dependencies: | Stopgaps:
---------------------------------+------------------------------------------
Changes (by dcoudert):
* cc: ncohen (added)
* status: new => needs_review
Old description:
> This patch implements the {{{blocks_and_cut_vertices}}} method as
> proposed by Tarjan in 1972. The time complexity is in O(|V|+|E|). The
> running time improvement is significant compared to previous
> implementation.
>
> Before:
> {{{
> sage:
> }}}
>
> After:
> {{{
> }}}
New description:
This patch implements the {{{blocks_and_cut_vertices}}} method as proposed
by Tarjan in 1972. The time complexity is now in O(|V|+|E|). The running
time improvement is significant compared to previous implementation, in
particular on large-scale graphs with many blocks.
Before:
{{{
sage: GP = graphs.PathGraph(6)
sage: %timeit B,C = GP.blocks_and_cut_vertices()
625 loops, best of 3: 167 µs per loop
sage: import networkx
sage: Gbig = Graph(networkx.read_edgelist('/PATHTOFILE/as-
rel.20120601.edgelist'))
sage: Gbig.num_verts(),G.num_edges()
(41203, 121309)
sage: %timeit B,C = G.blocks_and_cut_vertices()
5 loops, best of 3: 44.1 s per loop
}}}
After:
{{{
sage: %timeit B,C = GP.blocks_and_cut_vertices()
625 loops, best of 3: 152 µs per loop
sage: %timeit B,C = Gbig.blocks_and_cut_vertices()
5 loops, best of 3: 1.61 s per loop
}}}
--
Comment:
In fact the time complexity is more than O(|V|+|E|) since I'm sorting the
lists, but the extra computation time is negligible. This can be removed.
I'm using a try...except to test the end of iterations. This could be
replaced with a more appropriate test, if any.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13665#comment:1>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica,
and MATLAB
--
You received this message because you are subscribed to the Google Groups
"sage-trac" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sage-trac?hl=en.