#14535: Mutability of Graphs
------------------------------------+---------------------------------------
Reporter: SimonKing | Owner: jason, ncohen, rlm
Type: enhancement | Status: needs_info
Priority: major | Milestone: sage-5.10
Component: graph theory | Resolution:
Keywords: mutability graph | Work issues:
Report Upstream: N/A | Reviewers:
Authors: Simon King | Merged in:
Dependencies: #14524 | Stopgaps:
------------------------------------+---------------------------------------
Comment (by SimonKing):
Here are two more timings, this time using `DenseGraph` (hence, not using
the decorator) and hash:
Without patch:
{{{
sage: from sage.graphs.base.dense_graph import DenseGraph
sage: D = DenseGraph(nverts=10, extra_vertices=10)
sage: def test(g):
....: for i in xrange(100):
....: g.add_vertex(i)
....: for i in xrange(100):
....: for j in xrange(100):
....: g.add_arc(i,j)
....: for i in xrange(100):
....: g.del_vertex(i)
....:
sage: %timeit test(D)
100 loops, best of 3: 2.59 ms per loop
sage: K12 = graphs.CompleteGraph(12)
sage: K12._immutable = True
sage: hash(K12)
-1604610596753853799
sage: %timeit hash(K12)
1000 loops, best of 3: 212 us per loop
}}}
With the patch:
{{{
...
sage: %timeit test(D)
100 loops, best of 3: 2.72 ms per loop
sage: (2.72-2.59)/2.59*100 # 5% slowdown
5.01930501930503
sage: K12 = graphs.CompleteGraph(12)
sage: K12.set_immutable()
sage: %timeit hash(K12)
1000 loops, best of 3: 216 us per loop
}}}
Anyway, I presume that in ''real'' use cases, faster unsafe methods
would/could/should be used internally.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/14535#comment:6>
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 unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/sage-trac?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.