Skip to content

Commit fa51817

Browse files
committed
Correct method sparse_paving
1 parent dc99dc8 commit fa51817

File tree

1 file changed

+19
-7
lines changed

1 file changed

+19
-7
lines changed

src/sage/matroids/matroid.pyx

Lines changed: 19 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -6212,33 +6212,45 @@ cdef class Matroid(SageObject):
62126212
False
62136213
"""
62146214
if self.rank() >= 2:
6215-
for X in combinations(self.groundset(), self.rank() - 1):
6216-
if not self._is_independent(frozenset(X)):
6217-
return False
6215+
for _ in self.dependent_sets_iterator(self.rank() - 1):
6216+
return False
62186217
return True
62196218

62206219
cpdef bint is_sparse_paving(self) noexcept:
62216220
"""
62226221
Return if ``self`` is sparse-paving.
62236222
6224-
A matroid is sparse-paving if the symmetric difference of every pair
6225-
of circuits is greater than 2.
6223+
A matroid is sparse-paving if it is paving and its dual is paving.
62266224
62276225
OUTPUT: boolean
62286226
6227+
ALGORITHM:
6228+
6229+
First, check that the matroid is paving. Then, verify that the
6230+
symmetric difference of every pair of distinct `r`-circuits is greater
6231+
than 2.
6232+
62296233
EXAMPLES::
62306234
62316235
sage: M = matroids.catalog.Vamos()
62326236
sage: M.is_sparse_paving()
6237+
True
6238+
sage: M = matroids.catalog.N1()
6239+
sage: M.is_sparse_paving()
62336240
False
6234-
sage: M = matroids.catalog.Fano()
6241+
6242+
TESTS::
6243+
6244+
sage: M = matroids.Uniform(4, 50) # fast because we don't check M.dual().is_paving()
62356245
sage: M.is_sparse_paving()
62366246
True
6247+
sage: for M in matroids.AllMatroids(8):
6248+
....: assert M.is_sparse_paving() == (M.is_paving() and M.dual().is_paving())
62376249
"""
62386250
if not self.is_paving():
62396251
return False
62406252
from itertools import combinations
6241-
for (C1, C2) in combinations(self.circuits_iterator(), 2):
6253+
for (C1, C2) in combinations(self.nonbases_iterator(), 2):
62426254
if len(C1 ^ C2) <= 2:
62436255
return False
62446256
return True

0 commit comments

Comments
 (0)