# 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

b


61  61  degree sequence if and only if* `\forall i` 
62  62  
63  63  .. MATH:: 
64   \sum_{j\leq i}d_j \leq j(j1) + \sum_{j>i}min(d_j,i) 
 64  \sum_{j\leq i}d_j \leq j(j1) + \sum_{j>i}\min(d_j,i) 
65  65  
66  66  Alternatively, a degree sequence can be defined recursively : 
67  67  
… 
… 

249  249  
250  250  As soon as the ``yield`` keyword is available in Cython this should be 
251  251  changed. Updating the code does not require more than a couple of minutes. 
252   
 252  
253  253  """ 
254  254  
255  255  ############################################################################## 
… 
… 

259  259  # http://www.gnu.org/licenses/ 
260  260  ############################################################################## 
261  261  
262   from sage.libs.gmp.all cimport mpz_t 
263   from sage.libs.gmp.all cimport * 
264   from sage.rings.integer cimport Integer 
 262  from sage.libs.gmp.all cimport mpz_t 
 263  from sage.libs.gmp.all cimport * 
 264  from sage.rings.integer cimport Integer 
265  265  include '../../../../devel/sage/sage/ext/stdsage.pxi' 
266   include '../ext/cdefs.pxi' 
 266  include '../ext/cdefs.pxi' 
267  267  include "../ext/interrupt.pxi" 
268  268  
269  269  
… 
… 

274  274  
275  275  def __init__(self, n): 
276  276  r""" 
277   Constructor 
 277  Degree Sequences 
278  278  
279   TEST:: 
 279  An instance of this class represents the degree sequences of graphs on a 
 280  given number `n` of vertices. It can be used to list and count them, as 
 281  well as to test whether a sequence is a degree sequence. For more 
 282  information, please refer to the documentation of the 
 283  :mod:`DegreeSequence<sage.combinat.degree_sequences>` module. 
280  284  
281   sage: DegreeSequences(6) 
282   Degree sequences on 6 elements 
 285  EXAMPLE:: 
 286  
 287  sage: DegreeSequences(8) 
 288  Degree sequences on 8 elements 
 289  sage: [3,3,2,2,2,2,2,2] in DegreeSequences(8) 
 290  True 
 291  
283  292  """ 
284  293  self._n = n 
285  294  
… 
… 

296  305  cdef int n = self._n 
297  306  if len(seq)!=n: 
298  307  return False 
299   
 308  
300  309  cdef int S = sum(seq) 
301  310  
302  311  # Partial represents the left side of Erdos and Gallai's inequality, 
… 
… 

364  373  """ 
365  374  if seq != NULL: 
366  375  free(seq) 
367   
 376  
368  377  cdef init(int n): 
369  378  """ 
370  379  Initializes the memory and starts the enumeration algorithm. 
… 
… 

392  401  
393  402  cdef inline add_seq(): 
394  403  """ 
395   This function is called whenever a sequence is found. 
 404  This function is called whenever a sequence is found. 
396  405  
397  406  Build the degree sequence corresponding to the current state of the 
398  407  algorithm and adds it to the sequences list. 
… 
… 

408  417  for 0<= j < seq[i]: 
409  418  s.append(i) 
410  419  
411   sequences.append(s) 
 420  sequences.append(s) 
412  421  
413  422  cdef void enum(int k, int M): 
414  423  """ 
… 
… 

481  490  n_current_box = seq[current_box] 
482  491  n_previous_box = seq[current_box1] 
483  492  
484   # Note to self, and others : 
485   # 
 493  # Note to self, and others : 
 494  # 
486  495  # In the following lines, there are many incrementation/decrementation 
487  496  # that *may* be replaced by only +1 and 1 and save some 
488  497  # instructions. This would involve adding several "if", and I feared it 