Union of matroids

class sage.matroids.union_matroid.MatroidSum[source]

Bases: Matroid

Matroid Sum.

The matroid sum of a list of matroids (E1,I1),,(En,In) is a matroid (E,I) where E=i=1nEi and I=i=1nIi.

INPUT:

  • matroids – iterator of matroids

OUTPUT:

A MatroidSum instance, it’s a matroid sum of all matroids in matroids.

groundset()[source]

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)]
from sage.matroids.union_matroid import *
M = MatroidSum([matroids.Uniform(2,4),matroids.Uniform(2,4)])
sorted(M.groundset())
class sage.matroids.union_matroid.MatroidUnion[source]

Bases: Matroid

Matroid Union.

The matroid union of a set of matroids {(E1,I1),,(En,In)} is a matroid (E,I) where E=i=1nEi and

I={i=1nJi|JiIi}.

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})]
M1 = matroids.Uniform(3,3)
M2 = Matroid(bases = [frozenset({3}), frozenset({4})])
M = M1.union(M2); M
M.bases()
list(M.circuits())

INPUT:

  • matroids – iterator

OUTPUT: a MatroidUnion instance; a matroid union of all matroids in matroids

groundset()[source]

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]
from sage.matroids.union_matroid import *
M = MatroidUnion([matroids.Uniform(2,4),matroids.Uniform(5,8)])
sorted(M.groundset())
class sage.matroids.union_matroid.PartitionMatroid[source]

Bases: Matroid

Partition Matroid.

Given a set of disjoint sets S={S1,,Sn}, the partition matroid on S is (E,I) where E=i=1nSi and

I={X||XSi|1,XE}.

INPUT:

  • partition – iterator of disjoint sets

OUTPUT:

A PartitionMatroid instance, it’s partition matroid of the partition.

groundset()[source]

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]
from sage.matroids.union_matroid import *
M = PartitionMatroid([[1,2,3],[4,5,6]])
sorted(M.groundset())