Skip to content

Commit 22c3976

Browse files
authored
Change degree sequences from lists to tuples
Updated degree sequences representation to use tuples instead of lists for consistency and improved performance.
1 parent a4804a5 commit 22c3976

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

src/sage/combinat/degree_sequences.pyx

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,17 @@ With the object ``DegreeSequences(n)``, one can:
2121
2222
sage: for seq in DegreeSequences(4):
2323
....: print(seq)
24-
[0, 0, 0, 0]
25-
[1, 1, 0, 0]
26-
[2, 1, 1, 0]
27-
[3, 1, 1, 1]
28-
[1, 1, 1, 1]
29-
[2, 2, 1, 1]
30-
[2, 2, 2, 0]
31-
[3, 2, 2, 1]
32-
[2, 2, 2, 2]
33-
[3, 3, 2, 2]
34-
[3, 3, 3, 3]
24+
(0, 0, 0, 0)
25+
(1, 1, 0, 0)
26+
(2, 1, 1, 0)
27+
(3, 1, 1, 1)
28+
(1, 1, 1, 1)
29+
(2, 2, 1, 1)
30+
(2, 2, 2, 0)
31+
(3, 2, 2, 1)
32+
(2, 2, 2, 2)
33+
(3, 3, 2, 2)
34+
(3, 3, 3, 3)
3535
3636
.. NOTE::
3737
@@ -323,13 +323,13 @@ class DegreeSequences:
323323
:issue:`21824`::
324324
325325
sage: [d for d in DegreeSequences(0)]
326-
[[]]
326+
[()]
327327
sage: [d for d in DegreeSequences(1)]
328-
[[0]]
328+
[(0,)]
329329
sage: [d for d in DegreeSequences(3)]
330-
[[0, 0, 0], [1, 1, 0], [2, 1, 1], [2, 2, 2]]
330+
[(0, 0, 0), (1, 1, 0), (2, 1, 1), (2, 2, 2)]
331331
sage: [d for d in DegreeSequences(1)]
332-
[[0]]
332+
[(0,)]
333333
"""
334334
cdef int n = self._n
335335
if len(seq) != n:
@@ -418,7 +418,7 @@ cdef build_current_seq():
418418
for 0 <= j < seq[i]:
419419
s.append(i)
420420

421-
return s
421+
return tuple(s)
422422

423423

424424
def init(int n):
@@ -431,10 +431,10 @@ def init(int n):
431431
global N
432432

433433
if n == 0:
434-
yield []
434+
yield ()
435435
return
436436
elif n == 1:
437-
yield [0]
437+
yield (0,)
438438
return
439439

440440
seq = <unsigned char *>check_calloc(n + 1, sizeof(unsigned char))

0 commit comments

Comments
 (0)