#13192: some code clean up for sage/graphs/graph.py
----------------------------------+-----------------------------------------
       Reporter:  eisermbi        |         Owner:  jason, ncohen, rlm
           Type:  defect          |        Status:  needs_info        
       Priority:  major           |     Milestone:  sage-5.2          
      Component:  graph theory    |    Resolution:                    
       Keywords:  sparse6_string  |   Work issues:                    
Report Upstream:  N/A             |     Reviewers:  Nathann Cohen     
        Authors:  Birk Eisermann  |     Merged in:                    
   Dependencies:                  |      Stopgaps:                    
----------------------------------+-----------------------------------------

Comment (by eisermbi):

 Okay, okay, - you are making me learn python... ;-)  I took some
 information from http://wiki.python.org/moin/HowTo/Sorting/


 How about my following one liner? (included in recent patch)
 {{{
 edges.sort(key=lambda e: (e[1],e[0]))
 }}}

 This needs Python version >= 2.4 . Is this dependency okay for sage?


 Otherwise, we could write
 {{{
 edges.sort(cmp=lambda e,f: cmp(e[1],f[1]) or cmp(e[0],f[0]))
 }}}

 which seems Python 3.x '''incompatible''' though not an issue yet.

 For testing, I run
 {{{
 sage -c "for g in graphs(8): print g.sparse6_string()" > gr8-old.out
 }}}
 for all three version (old, key-version, cmp-verison) and the output was
 the same.


 Now, how about giving up the 30 lines of compare_edges() with a good
 feeling?

 Birk

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/13192#comment:5>
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.

Reply via email to