Skip to content

Commit 2e4020a

Browse files
committed
Add class FlatsMatroid
1 parent 30b3d78 commit 2e4020a

File tree

4 files changed

+605
-2
lines changed

4 files changed

+605
-2
lines changed

src/sage/matroids/constructor.py

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,7 @@
113113
import sage.matroids.basis_exchange_matroid
114114
from .rank_matroid import RankMatroid
115115
from .circuits_matroid import CircuitsMatroid
116+
from .flats_matroid import FlatsMatroid
116117
from .circuit_closures_matroid import CircuitClosuresMatroid
117118
from .basis_matroid import BasisMatroid
118119
from .linear_matroid import LinearMatroid, RegularMatroid, BinaryMatroid, TernaryMatroid, QuaternaryMatroid
@@ -180,6 +181,7 @@ def Matroid(groundset=None, data=None, **kwds):
180181
- ``circuits`` -- The list of circuits of the matroid.
181182
- ``nonspanning_circuits`` -- The list of nonspanning_circuits of the
182183
matroid.
184+
- ``flats`` -- The dictionary of flats indexed by their rank.
183185
- ``graph`` -- A graph, whose edges form the elements of the matroid.
184186
- ``matrix`` -- A matrix representation of the matroid.
185187
- ``reduced_matrix`` -- A reduced representation of the matroid: if
@@ -698,8 +700,9 @@ def Matroid(groundset=None, data=None, **kwds):
698700
key = None
699701
if data is None:
700702
for k in ['bases', 'independent_sets', 'circuits',
701-
'nonspanning_circuits', 'graph', 'matrix', 'reduced_matrix',
702-
'rank_function', 'revlex', 'circuit_closures', 'matroid']:
703+
'nonspanning_circuits', 'flats', 'graph', 'matrix',
704+
'reduced_matrix', 'rank_function', 'revlex',
705+
'circuit_closures', 'matroid']:
703706
if k in kwds:
704707
data = kwds.pop(k)
705708
key = k
@@ -791,6 +794,16 @@ def Matroid(groundset=None, data=None, **kwds):
791794
nsc_defined=True
792795
)
793796

797+
# Flats
798+
elif key == 'flats':
799+
# Determine groundset
800+
if groundset is None:
801+
groundset = set()
802+
for i in data:
803+
for F in data[i]:
804+
groundset.update(F)
805+
M = FlatsMatroid(groundset=groundset, flats=data)
806+
794807
# Graphs:
795808
elif key == 'graph':
796809
from sage.graphs.graph import Graph

src/sage/matroids/flats_matroid.pxd

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
from sage.matroids.matroid cimport Matroid
2+
3+
cdef class FlatsMatroid(Matroid):
4+
cdef frozenset _groundset # _E
5+
cdef int _matroid_rank # _R
6+
cdef dict _F # flats
7+
cpdef groundset(self) noexcept
8+
cpdef _rank(self, X) noexcept
9+
cpdef full_rank(self) noexcept
10+
cpdef _is_independent(self, F) noexcept
11+
12+
# enumeration
13+
cpdef flats(self, k) noexcept
14+
cpdef whitney_numbers2(self) noexcept
15+
16+
# isomorphism
17+
cpdef _is_isomorphic(self, other, certificate=*) noexcept
18+
19+
# verification
20+
cpdef is_valid(self) noexcept

0 commit comments

Comments
 (0)