Ticket #13192: trac_13192-cleanup-v3.patch

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

    # HG changeset patch
    # User Birk Eisermann <eisermbi@fastmail.fm>
    # Date 1341211294 -28800
    # Node ID e9cb4282e2539be6c6b98586f063c2452f3fe824
    # Parent  5f2b67ffd844b6437e6f407bc6e4af2fa8c44982
    trac 13192 code clean up in graph.py
    
    diff --git a/sage/graphs/graph.py b/sage/graphs/graph.py
    a b  
    15731573            edges = self.edges(labels=False)
    15741574            for i in range(len(edges)): # replace edge labels with natural numbers (by index in vertices)
    15751575                edges[i] = (vertices.index(edges[i][0]),vertices.index(edges[i][1]))
    1576             # order edges
    1577             edges.sort(compare_edges)
     1576            # order edges 'reverse lexicographically', that is, for
     1577            # edge (a,b) and edge (c,d) first compare b and d, then a and c;
     1578            edges.sort(key=lambda e: (e[1],e[0]))
    15781579
    15791580            # encode bit vector
    15801581            from math import ceil
     
    50705071
    50715072def compare_edges(x, y):
    50725073    """
     5074    This function has been deprecated.
     5075
    50735076    Compare edge x to edge y, return -1 if x y, 1 if x y, else 0.
    50745077
    5075     EXAMPLES::
     5078    TEST::
    50765079
    50775080        sage: G = graphs.PetersenGraph()
    50785081        sage: E = G.edges()
    50795082        sage: from sage.graphs.graph import compare_edges
    50805083        sage: compare_edges(E[0], E[2])
     5084        doctest:...: DeprecationWarning: compare_edges(x,y) is deprecated.  Use statement 'cmp(x[1],y[1]) or cmp(x[0],y[0])' instead.
     5085        See http://trac.sagemath.org/13192 for details.
    50815086        -1
    5082         sage: compare_edges(E[0], E[1])
    5083         -1
    5084         sage: compare_edges(E[0], E[0])
    5085         0
    5086         sage: compare_edges(E[1], E[0])
    5087         1
    50885087    """
     5088    from sage.misc.superseded import deprecation
     5089    deprecation(13192, "compare_edges(x,y) is deprecated.  Use statement 'cmp(x[1],y[1]) or cmp(x[0],y[0])' instead.")
    50895090    if x[1] < y[1]:
    50905091        return -1
    50915092    elif x[1] > y[1]: