#7966: Giving some punch to distance computations
----------------------------+-----------------------------------------------
Reporter: ncohen | Owner: rlm
Type: enhancement | Status: new
Priority: major | Milestone: sage-4.3.1
Component: graph theory | Keywords:
Work_issues: | Author:
Upstream: N/A | Reviewer:
Merged: |
----------------------------+-----------------------------------------------
This patch creates a function shortest_path_all_vertices in c_graphs
which, given a vertex v, computes a shortest path for each other vertex.
With small other modifications, it improves the speed of many functions (
which were all calling each other )
Before :
{{{
sage: g = graphs.RandomGNP(50,.3)
sage: %timeit g.shortest_path_lengths(0)
100 loops, best of 3: 3.72 ms per loop
sage: %timeit g.average_distance()
10 loops, best of 3: 383 ms per loop
sage: %timeit g.wiener_index()
10 loops, best of 3: 384 ms per loop
sage: %timeit g.szeged_index()
10 loops, best of 3: 325 ms per loop
sage: %timeit g.eccentricity()
10 loops, best of 3: 189 ms per loop
sage: g.sparse6_string()
':q_OW_CCBb?WcOL@@`_{c...@pcgif``@[WQK_`?w_QIDoo_WSJEBWGOKIDbG?CZ?@@ow...@?o_somba@x...@`opkhbb@p...@caq@yaacap...@b@po...@`?o_]qiegowmgdcqheedb@pxma...@gscyloo__qjebaxcvbecapwqynq`gwgtkerx}?@@@@gg[qhd...@?baa@wmyngwo[olfcqhqclfcrpky]poow_slgcrhw...@_w_slhcq`_u[ogg?gedbap_{iujebiykgcbpp_qymfbyliea``woymfca`skxmgs[?mifcahgw\\np`ww]vlfsskymhdapcs[nhsy`r?a@pokwm...@oy]tjggkojiebh|qjuoox?mwleryhih___woar...@cu[mhtauccba@Gk]PHdax_w]NhCq\\Sm'
}}}
After
{{{
sage: %timeit g.shortest_path_lengths(0)
10 loops, best of 3: 430 µs per loop
sage: %timeit g.average_distance()
10 loops, best of 3: 22 ms per loop
sage: %timeit g.wiener_index()
10 loops, best of 3: 22.1 ms per loop
sage: %timeit g.szeged_index()
10 loops, best of 3: 41.5 ms per loop
sage: %timeit g.eccentricity()
10 loops, best of 3: 22 ms per loop
}}}
Nathann
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/7966>
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.