Ticket #13192: trac_13192-cleanup-v2.patch

File trac_13192-cleanup-v2.patch, 1.9 KB (added by kcrisman, 9 years ago)
  • sage/graphs/graph.py

    # HG changeset patch
    # User Birk Eisermann <eisermbi@fastmail.fm>
    # Date 1341211294 -28800
    # Node ID cae7e294f818349f4d1a7bd803836c672401945b
    # Parent  ebcb32d56c55140e250b797c3952af0013a69ea6
    trac 13192 code clean up in graph.py
    
    diff --git a/sage/graphs/graph.py b/sage/graphs/graph.py
    a b  
    15661566            edges = self.edges(labels=False)
    15671567            for i in range(len(edges)): # replace edge labels with natural numbers (by index in vertices)
    15681568                edges[i] = (vertices.index(edges[i][0]),vertices.index(edges[i][1]))
    1569             # order edges
    1570             edges.sort(compare_edges)
     1569            # order edges 'reverse lexicographically', that is, for
     1570            # edge (a,b) and edge (c,d) first compare b and d, then a and c;
     1571            edges.sort(key=lambda e: (e[1],e[0]))
    15711572
    15721573            # encode bit vector
    15731574            from math import ceil
     
    50535054
    50545055def compare_edges(x, y):
    50555056    """
     5057    This function has been deprecated.
     5058
    50565059    Compare edge x to edge y, return -1 if x y, 1 if x y, else 0.
    50575060   
    5058     EXAMPLES::
     5061    TEST::
    50595062   
    50605063        sage: G = graphs.PetersenGraph()
    50615064        sage: E = G.edges()
    50625065        sage: from sage.graphs.graph import compare_edges
    50635066        sage: compare_edges(E[0], E[2])
     5067        doctest:...: DeprecationWarning: compare_edges(x,y) is deprecated.  Use statement 'cmp(x[1],y[1]) or cmp(x[0],y[0])' instead.
     5068        See http://trac.sagemath.org/13192 for details.
    50645069        -1
    5065         sage: compare_edges(E[0], E[1])
    5066         -1
    5067         sage: compare_edges(E[0], E[0])
    5068         0
    5069         sage: compare_edges(E[1], E[0])
    5070         1
     5070
    50715071    """
     5072    from sage.misc.superseded import deprecation
     5073    deprecation(13192, "compare_edges(x,y) is deprecated.  Use statement 'cmp(x[1],y[1]) or cmp(x[0],y[0])' instead.")
    50725074    if x[1] < y[1]:
    50735075        return -1
    50745076    elif x[1] > y[1]: