#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: Nathann Cohen
Authors: David Coudert | Merged in:
Dependencies: | Stopgaps:
---------------------------------+------------------------------------------
Changes (by dcoudert):
* status: needs_info => needs_review
Old 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
> }}}
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
}}}
Apply:
* [attachment:trac_13665_blocks_and_cuts.patch]
* [attachment:trac_13665-rev.patch]
* [attachment:trac_13665-rev2.patch]
--
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13665#comment:14>
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.