|
113 | 113 | import sage.matroids.basis_exchange_matroid
|
114 | 114 | from .rank_matroid import RankMatroid
|
115 | 115 | from .circuits_matroid import CircuitsMatroid
|
| 116 | +from .flats_matroid import FlatsMatroid |
116 | 117 | from .circuit_closures_matroid import CircuitClosuresMatroid
|
117 | 118 | from .basis_matroid import BasisMatroid
|
118 | 119 | from .linear_matroid import LinearMatroid, RegularMatroid, BinaryMatroid, TernaryMatroid, QuaternaryMatroid
|
@@ -180,6 +181,7 @@ def Matroid(groundset=None, data=None, **kwds):
|
180 | 181 | - ``circuits`` -- The list of circuits of the matroid.
|
181 | 182 | - ``nonspanning_circuits`` -- The list of nonspanning_circuits of the
|
182 | 183 | matroid.
|
| 184 | + - ``flats`` -- The dictionary of flats indexed by their rank. |
183 | 185 | - ``graph`` -- A graph, whose edges form the elements of the matroid.
|
184 | 186 | - ``matrix`` -- A matrix representation of the matroid.
|
185 | 187 | - ``reduced_matrix`` -- A reduced representation of the matroid: if
|
@@ -698,8 +700,9 @@ def Matroid(groundset=None, data=None, **kwds):
|
698 | 700 | key = None
|
699 | 701 | if data is None:
|
700 | 702 | 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']: |
703 | 706 | if k in kwds:
|
704 | 707 | data = kwds.pop(k)
|
705 | 708 | key = k
|
@@ -791,6 +794,16 @@ def Matroid(groundset=None, data=None, **kwds):
|
791 | 794 | nsc_defined=True
|
792 | 795 | )
|
793 | 796 |
|
| 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 | + |
794 | 807 | # Graphs:
|
795 | 808 | elif key == 'graph':
|
796 | 809 | from sage.graphs.graph import Graph
|
|
0 commit comments