diff --git a/src/sage/matroids/matroid.pxd b/src/sage/matroids/matroid.pxd index 4644daddf1b..7d2bc60078d 100644 --- a/src/sage/matroids/matroid.pxd +++ b/src/sage/matroids/matroid.pxd @@ -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 diff --git a/src/sage/matroids/matroid.pyx b/src/sage/matroids/matroid.pyx index 6e454815caa..b2d86f1e64a 100644 --- a/src/sage/matroids/matroid.pyx +++ b/src/sage/matroids/matroid.pyx @@ -111,6 +111,7 @@ additional functionality (e.g. linear extensions). - :meth:`connectivity() ` - :meth:`is_paving() ` - :meth:`is_sparse_paving() ` + - :meth:`girth() ` - Representation - :meth:`binary_matroid() ` @@ -5976,6 +5977,34 @@ 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() + +Infinity + 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 + from sage.rings.infinity import infinity + return infinity + # representability cpdef _local_binary_matroid(self, basis=None) noexcept: