Union of matroids¶
- class sage.matroids.union_matroid.MatroidSum¶
Bases:
MatroidMatroid Sum.
The matroid sum of a list of matroids \((E_1,I_1),\ldots,(E_n,I_n)\) is a matroid \((E,I)\) where \(E= \bigsqcup_{i=1}^n E_i\) and \(I= \bigsqcup_{i=1}^n I_i\).
INPUT:
matroids– iterator of matroids
OUTPUT:
A
MatroidSuminstance, it’s a matroid sum of all matroids inmatroids.- groundset()¶
Return the groundset of the matroid.
The groundset is the set of elements that comprise the matroid.
OUTPUT: set
EXAMPLES:
sage: from sage.matroids.union_matroid import * sage: M = MatroidSum([matroids.Uniform(2,4),matroids.Uniform(2,4)]) sage: sorted(M.groundset()) [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3)]
>>> from sage.all import * >>> from sage.matroids.union_matroid import * >>> M = MatroidSum([matroids.Uniform(Integer(2),Integer(4)),matroids.Uniform(Integer(2),Integer(4))]) >>> sorted(M.groundset()) [(0, 0), (0, 1), (0, 2), (0, 3), (1, 0), (1, 1), (1, 2), (1, 3)]
- class sage.matroids.union_matroid.MatroidUnion¶
Bases:
MatroidMatroid Union.
The matroid union of a set of matroids \(\{(E_1,I_1),\ldots,(E_n,I_n)\}\) is a matroid \((E,I)\) where \(E= \bigcup_{i=1}^n E_i\) and
\(I= \{\bigcup_{i=1}^n J_i | J_i \in I_i \}\).
EXAMPLES:
sage: M1 = matroids.Uniform(3,3) sage: M2 = Matroid(bases = [frozenset({3}), frozenset({4})]) sage: M = M1.union(M2); M Matroid of rank 4 on 5 elements as matroid union of Matroid of rank 3 on 3 elements with circuit-closures {} Matroid of rank 1 on 2 elements with 2 bases sage: M.bases() SetSystem of 2 sets over 5 elements sage: list(M.circuits()) [frozenset({3, 4})]
>>> from sage.all import * >>> M1 = matroids.Uniform(Integer(3),Integer(3)) >>> M2 = Matroid(bases = [frozenset({Integer(3)}), frozenset({Integer(4)})]) >>> M = M1.union(M2); M Matroid of rank 4 on 5 elements as matroid union of Matroid of rank 3 on 3 elements with circuit-closures {} Matroid of rank 1 on 2 elements with 2 bases >>> M.bases() SetSystem of 2 sets over 5 elements >>> list(M.circuits()) [frozenset({3, 4})]
INPUT:
matroids– iterator
OUTPUT: a
MatroidUnioninstance; a matroid union of all matroids inmatroids- groundset()¶
Return the groundset of the matroid.
The groundset is the set of elements that comprise the matroid.
OUTPUT: set
EXAMPLES:
sage: from sage.matroids.union_matroid import * sage: M = MatroidUnion([matroids.Uniform(2,4),matroids.Uniform(5,8)]) sage: sorted(M.groundset()) [0, 1, 2, 3, 4, 5, 6, 7]
>>> from sage.all import * >>> from sage.matroids.union_matroid import * >>> M = MatroidUnion([matroids.Uniform(Integer(2),Integer(4)),matroids.Uniform(Integer(5),Integer(8))]) >>> sorted(M.groundset()) [0, 1, 2, 3, 4, 5, 6, 7]
- class sage.matroids.union_matroid.PartitionMatroid¶
Bases:
MatroidPartition Matroid.
Given a set of disjoint sets \(S=\{S_1,\ldots,S_n\}\), the partition matroid on \(S\) is \((E,I)\) where \(E=\bigcup_{i=1}^n S_i\) and
\(I= \{X| |X\cap S_i|\leq 1,X\subset E \}\).
INPUT:
partition– iterator of disjoint sets
OUTPUT:
A
PartitionMatroidinstance, it’s partition matroid of thepartition.- groundset()¶
Return the groundset of the matroid.
The groundset is the set of elements that comprise the matroid.
OUTPUT: set
EXAMPLES:
sage: from sage.matroids.union_matroid import * sage: M = PartitionMatroid([[1,2,3],[4,5,6]]) sage: sorted(M.groundset()) [1, 2, 3, 4, 5, 6]
>>> from sage.all import * >>> from sage.matroids.union_matroid import * >>> M = PartitionMatroid([[Integer(1),Integer(2),Integer(3)],[Integer(4),Integer(5),Integer(6)]]) >>> sorted(M.groundset()) [1, 2, 3, 4, 5, 6]