#19583: random triangulation as simplicial complex
-------------------------------------+-------------------------------------
       Reporter:  chapoton           |        Owner:
           Type:  enhancement        |       Status:  needs_work
       Priority:  major              |    Milestone:  sage-7.1
      Component:  algebraic          |   Resolution:
  topology                           |    Merged in:
       Keywords:  random simplicial  |    Reviewers:
  complex                            |  Work issues:
        Authors:  Frédéric Chapoton  |       Commit:
Report Upstream:  N/A                |  5e465924db248460f0a20da334cd4b1f8499adc7
         Branch:  u/chapoton/19583   |     Stopgaps:
   Dependencies:                     |
-------------------------------------+-------------------------------------
Changes (by ncohen):

 * status:  needs_review => needs_work


Comment:

 > Some timings
 > {{{
 > sage: %timeit simplicial_complexes.RandomTwoSphere(1000).graph()
 > 1 loops, best of 3: 769 ms per loop
 > sage: %timeit graphs.RandomTriangulation(1000)
 > 1 loops, best of 3: 189 ms per loop
 > }}}

 Some timings:

 {{{
 sage: %timeit simplicial_complexes.RandomTwoSphere(1000)
 1 loops, best of 3: 246 ms per loop
 sage: %timeit graphs.RandomTriangulation(1000)
 1 loops, best of 3: 222 ms per loop
 }}}

 That's what happens when you replace the last line of `RandomTwoSphere`
 this way:

 {{{
 #!diff
 -    return SimplicialComplex(triangles)
 +    return triangles
 }}}

 Another timing:

 {{{
 sage: %timeit simplicial_complexes.RandomTwoSphere(1000)
 1 loops, best of 3: 269 ms per loop
 sage: %timeit graphs.RandomTriangulation(1000)
 1 loops, best of 3: 219 ms per loop
 }}}

 That's what happens when you do the following replacement instead:

 {{{
 -    return SimplicialComplex(triangles)
 +    return SimplicialComplex(triangles,maximality_check=False)
 }}}


 Once this (second) replacement is done, here is the effect on the `.graph`
 function:

 {{{
 sage: %timeit simplicial_complexes.RandomTwoSphere(1000).graph()
 1 loops, best of 3: 345 ms per loop
 sage: %timeit graphs.RandomTriangulation(1000)
 1 loops, best of 3: 222 ms per loop
 }}}

 If that is still too much for your (I assume computer-intensive) needs, it
 seems that the .graph function is unnecessarily slow

 {{{
 sage: def simplex_to_graph(S):
     g = Graph()
     for S in S._facets:
         g.add_cycle(g)
     return g
 sage: %timeit simplex_to_graph(simplicial_complexes.RandomTwoSphere(1000))
 1 loops, best of 3: 288 ms per loop
 sage: %timeit graphs.RandomTriangulation(1000)
 1 loops, best of 3: 226 ms per loop
 }}}

 So please stop messing around by moving around blocks of 5 lines, and keep
 only one of these two functions (unless you still find the speed penalty
 too big).

 Nathann

--
Ticket URL: <http://trac.sagemath.org/ticket/19583#comment:25>
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 https://groups.google.com/group/sage-trac.
For more options, visit https://groups.google.com/d/optout.

Reply via email to