# Ticket #11584: trac_11584-doc.patch

File trac_11584-doc.patch, 3.5 KB (added by ncohen, 9 years ago)
• ## sage/combinat/degree_sequences.pyx

# HG changeset patch
# User Nathann Cohen <nathann.cohen@gmail.com>
# Date 1331996297 -3600
# Node ID c76681cfa6209f9c8e8a88847b17872f7a28d202
# Parent  2919de5ae8d8362c2b6f89703b9cfdc242b1f108
DegreeSequences class -- additions in the documentation

diff --git a/sage/combinat/degree_sequences.pyx b/sage/combinat/degree_sequences.pyx
 a degree sequence if and only if* \forall i .. MATH:: \sum_{j\leq i}d_j \leq j(j-1) + \sum_{j>i}min(d_j,i) \sum_{j\leq i}d_j \leq j(j-1) + \sum_{j>i}\min(d_j,i) Alternatively, a degree sequence can be defined recursively : As soon as the yield keyword is available in Cython this should be changed. Updating the code does not require more than a couple of minutes. """ ############################################################################## #                  http://www.gnu.org/licenses/ ############################################################################## from sage.libs.gmp.all cimport mpz_t from sage.libs.gmp.all cimport * from sage.rings.integer cimport Integer from sage.libs.gmp.all cimport mpz_t from sage.libs.gmp.all cimport * from sage.rings.integer cimport Integer include '../../../../devel/sage/sage/ext/stdsage.pxi' include '../ext/cdefs.pxi' include '../ext/cdefs.pxi' include "../ext/interrupt.pxi" def __init__(self, n): r""" Constructor Degree Sequences TEST:: An instance of this class represents the degree sequences of graphs on a given number n of vertices. It can be used to list and count them, as well as to test whether a sequence is a degree sequence. For more information, please refer to the documentation of the :mod:DegreeSequence module. sage: DegreeSequences(6) Degree sequences on 6 elements EXAMPLE:: sage: DegreeSequences(8) Degree sequences on 8 elements sage: [3,3,2,2,2,2,2,2] in DegreeSequences(8) True """ self._n = n cdef int n = self._n if len(seq)!=n: return False cdef int S = sum(seq) # Partial represents the left side of Erdos and Gallai's inequality, """ if seq != NULL: free(seq) cdef init(int n): """ Initializes the memory and starts the enumeration algorithm. cdef inline add_seq(): """ This function is called whenever a sequence is found. This function is called whenever a sequence is found. Build the degree sequence corresponding to the current state of the algorithm and adds it to the sequences list. for 0<= j < seq[i]: s.append(i) sequences.append(s) sequences.append(s) cdef void enum(int k, int M): """ n_current_box = seq[current_box] n_previous_box = seq[current_box-1] # Note to self, and others : # # Note to self, and others : # # In the following lines, there are many incrementation/decrementation # that *may* be replaced by only +1 and -1 and save some # instructions. This would involve adding several "if", and I feared it