Skip to content

Commit 3767c65

Browse files
committed
Update circuits_matroid.p*
Change 'order' to 'ordering'; use 'ordering' for consistency with matroid.p*. Add nonspanning_circuits_iterator() and improve docstrings.
1 parent 3dd366a commit 3767c65

File tree

2 files changed

+36
-10
lines changed

2 files changed

+36
-10
lines changed

src/sage/matroids/circuits_matroid.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,7 @@ cdef class CircuitsMatroid(Matroid):
1818
cpdef bases(self) noexcept
1919
cpdef circuits(self, k=*) noexcept
2020
cpdef nonspanning_circuits(self) noexcept
21+
cpdef no_broken_circuits_sets(self, ordering=*) noexcept
2122

2223
# properties
2324
cpdef girth(self) noexcept

src/sage/matroids/circuits_matroid.pyx

Lines changed: 35 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -2,15 +2,16 @@ r"""
22
Circuits matroids
33
44
Matroids are characterized by a list of circuits, which are minimal dependent
5-
sets. The CircuitsMatroid class implements matroids using this information as
6-
data.
5+
sets. The ``CircuitsMatroid`` class implements matroids using this information
6+
as data.
77
88
A ``CircuitsMatroid`` can be created from another matroid or from a list of
99
circuits. For a full description of allowed inputs, see
1010
:class:`below <sage.matroids.circuits_matroid.CircuitsMatroid>`. It is
1111
recommended to use the :func:`Matroid() <sage.matroids.constructor.Matroid>`
12-
function for a more flexible construction of a ``CircuitsMatroid``. For direct
13-
access to the ``CircuitsMatroid`` constructor, run::
12+
function for a more flexible way of constructing a ``CircuitsMatroid`` and
13+
other classes of matroids. For direct access to the ``CircuitsMatroid``
14+
constructor, run::
1415
1516
sage: from sage.matroids.circuits_matroid import CircuitsMatroid
1617
@@ -425,6 +426,10 @@ cdef class CircuitsMatroid(Matroid):
425426
"""
426427
Return the circuits of the matroid.
427428
429+
INPUT:
430+
431+
- ``k`` -- an integer (optional); the length of the circuits
432+
428433
OUTPUT: a SetSystem
429434
430435
EXAMPLES::
@@ -449,6 +454,10 @@ cdef class CircuitsMatroid(Matroid):
449454
"""
450455
Return an iterator over the circuits of the matroid.
451456
457+
INPUT:
458+
459+
- ``k`` -- an integer (optional); the length of the circuits
460+
452461
EXAMPLES::
453462
454463
sage: from sage.matroids.circuits_matroid import CircuitsMatroid
@@ -485,7 +494,23 @@ cdef class CircuitsMatroid(Matroid):
485494
NSC.append(C)
486495
return NSC
487496

488-
cpdef no_broken_circuits_sets(self, order=None) noexcept:
497+
def nonspanning_circuits_iterator(self):
498+
"""
499+
Return an iterator over the nonspanning circuits of the matroid.
500+
501+
EXAMPLES::
502+
503+
sage: from sage.matroids.circuits_matroid import CircuitsMatroid
504+
sage: M = CircuitsMatroid(matroids.Uniform(2, 4))
505+
sage: list(M.nonspanning_circuits_iterator())
506+
[]
507+
"""
508+
for i in self._k_C:
509+
if i <= self.rank():
510+
for C in self._k_C[i]:
511+
yield C
512+
513+
cpdef no_broken_circuits_sets(self, ordering=None) noexcept:
489514
r"""
490515
Return the no broken circuits (NBC) sets of ``self``.
491516
@@ -494,7 +519,7 @@ cdef class CircuitsMatroid(Matroid):
494519
495520
INPUT:
496521
497-
- ``order`` -- a total ordering of the groundset given as a list
522+
- ``ordering`` -- a total ordering of the groundset given as a list
498523
499524
OUTPUT: a list of frozensets
500525
@@ -525,16 +550,16 @@ cdef class CircuitsMatroid(Matroid):
525550
sage: C1 == C2
526551
True
527552
"""
528-
if order is None:
529-
order = sorted(self.groundset(), key=str)
553+
if ordering is None:
554+
ordering = sorted(self.groundset(), key=str)
530555
else:
531-
if frozenset(order) != self.groundset():
556+
if frozenset(ordering) != self.groundset():
532557
raise ValueError("not an ordering of the groundset")
533558

534559
# compute broken circuits
535560
cdef list BC = []
536561
for C in self._C:
537-
for e in order:
562+
for e in ordering:
538563
if e in C:
539564
BC.append(C - set([e]))
540565
break

0 commit comments

Comments
 (0)