Skip to content

Commit

Permalink
Add girth()
Browse files Browse the repository at this point in the history
  • Loading branch information
gmou3 committed Jan 22, 2024
1 parent 3dd953c commit d3abe5a
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 0 deletions.
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')

# representability

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

0 comments on commit d3abe5a

Please sign in to comment.