Skip to content

Commit ebeb7a2

Browse files
author
Release Manager
committed
gh-37145: Add matroid attribute girth() <!-- ^^^^^ Please provide a concise, informative and self-explanatory title. Don't put issue numbers in there, do this in the PR body below. For example, instead of "Fixes #1234" use "Introduce new method to calculate 1+1" --> <!-- Describe your changes here in detail --> Added a function `girth()` to the main matroid class. This is a standard notion which corresponds to the size of the smallest circuit of the matroid. A similar notion exists for graphs. <!-- Why is this change required? What problem does it solve? --> <!-- If this PR resolves an open issue, please link to it here. For example "Fixes #12345". --> <!-- If your change requires a documentation PR, please link it appropriately. --> ### 📝 Checklist <!-- Put an `x` in all the boxes that apply. --> <!-- If your change requires a documentation PR, please link it appropriately --> <!-- If you're unsure about any of these, don't hesitate to ask. We're here to help! --> <!-- Feel free to remove irrelevant items. --> - [x] The title is concise, informative, and self-explanatory. - [x] The description explains in detail what this PR is about. - [x] I have created tests covering the changes. - [x] I have updated the documentation accordingly. URL: #37145 Reported by: gmou3 Reviewer(s): Travis Scrimshaw
2 parents 27448fe + 58521e5 commit ebeb7a2

File tree

2 files changed

+30
-0
lines changed

2 files changed

+30
-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: 29 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,34 @@ 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+
+Infinity
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+
from sage.rings.infinity import infinity
6006+
return infinity
6007+
59796008
# representability
59806009

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

0 commit comments

Comments
 (0)