Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add matroid attribute girth() #37145

Merged
merged 2 commits into from
Feb 2, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions src/sage/matroids/matroid.pxd
Original file line number Diff line number Diff line change
Expand Up @@ -177,6 +177,7 @@ cdef class Matroid(SageObject):
cpdef _is_3connected_BC_recursion(self, basis, fund_cocircuits) noexcept
cpdef is_paving(self) noexcept
cpdef is_sparse_paving(self) noexcept
cpdef girth(self) noexcept

# representability
cpdef _local_binary_matroid(self, basis=*) noexcept
Expand Down
28 changes: 28 additions & 0 deletions src/sage/matroids/matroid.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -111,6 +111,7 @@ additional functionality (e.g. linear extensions).
- :meth:`connectivity() <sage.matroids.matroid.Matroid.connectivity>`
- :meth:`is_paving() <sage.matroids.matroid.Matroid.is_paving>`
- :meth:`is_sparse_paving() <sage.matroids.matroid.Matroid.is_sparse_paving>`
- :meth:`girth() <sage.matroids.matroid.Matroid.girth>`

- Representation
- :meth:`binary_matroid() <sage.matroids.matroid.Matroid.binary_matroid>`
Expand Down Expand Up @@ -5976,6 +5977,33 @@ cdef class Matroid(SageObject):
return False
return True

cpdef girth(self) noexcept:
r"""
Return the girth of the matroid.

The girth is the size of the smallest circuit. In case the matroid has
no circuits the girth is `\infty`.

EXAMPLES::

sage: matroids.Uniform(5,5).girth()
inf
sage: matroids.catalog.K4().girth()
3
sage: matroids.catalog.Vamos().girth()
4

REFERENCES:

[Oxl2011]_, p. 327.
"""
for k in range(self.rank() + 2):
for X in combinations(self.groundset(), k):
X = frozenset(X)
if self._is_circuit(X):
return k
return float('inf')
gmou3 marked this conversation as resolved.
Show resolved Hide resolved

# representability

cpdef _local_binary_matroid(self, basis=None) noexcept:
Expand Down
Loading