Skip to content

Commit d3abe5a

Browse files
committed
Add girth()
1 parent 3dd953c commit d3abe5a

File tree

2 files changed

+29
-0
lines changed

2 files changed

+29
-0
lines changed

src/sage/matroids/matroid.pxd

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -177,6 +177,7 @@ cdef class Matroid(SageObject):
177177
cpdef _is_3connected_BC_recursion(self, basis, fund_cocircuits) noexcept
178178
cpdef is_paving(self) noexcept
179179
cpdef is_sparse_paving(self) noexcept
180+
cpdef girth(self) noexcept
180181

181182
# representability
182183
cpdef _local_binary_matroid(self, basis=*) noexcept

src/sage/matroids/matroid.pyx

Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,7 @@ additional functionality (e.g. linear extensions).
111111
- :meth:`connectivity() <sage.matroids.matroid.Matroid.connectivity>`
112112
- :meth:`is_paving() <sage.matroids.matroid.Matroid.is_paving>`
113113
- :meth:`is_sparse_paving() <sage.matroids.matroid.Matroid.is_sparse_paving>`
114+
- :meth:`girth() <sage.matroids.matroid.Matroid.girth>`
114115
115116
- Representation
116117
- :meth:`binary_matroid() <sage.matroids.matroid.Matroid.binary_matroid>`
@@ -5976,6 +5977,33 @@ cdef class Matroid(SageObject):
59765977
return False
59775978
return True
59785979

5980+
cpdef girth(self) noexcept:
5981+
r"""
5982+
Return the girth of the matroid.
5983+
5984+
The girth is the size of the smallest circuit. In case the matroid has
5985+
no circuits the girth is `\infty`.
5986+
5987+
EXAMPLES::
5988+
5989+
sage: matroids.Uniform(5,5).girth()
5990+
inf
5991+
sage: matroids.catalog.K4().girth()
5992+
3
5993+
sage: matroids.catalog.Vamos().girth()
5994+
4
5995+
5996+
REFERENCES:
5997+
5998+
[Oxl2011]_, p. 327.
5999+
"""
6000+
for k in range(self.rank() + 2):
6001+
for X in combinations(self.groundset(), k):
6002+
X = frozenset(X)
6003+
if self._is_circuit(X):
6004+
return k
6005+
return float('inf')
6006+
59796007
# representability
59806008

59816009
cpdef _local_binary_matroid(self, basis=None) noexcept:

0 commit comments

Comments
 (0)