Collections of matroids#

This module contains functions that access the collections of matroids in the database. Each of these functions returns an iterator over the nonparametrized matroids from the corresponding collection. These functions can be viewed by typing matroids. + Tab.

AUTHORS:

  • Giorgos Mousa (2023-12-08): initial version

sage.matroids.database_collections.AllMatroids(n, r=None, type='all')#

Return an iterator over all matroids of certain number of elements (and, optionally, of specific rank and type).

INPUT:

  • n – integer; the number of elements of the matroids

  • r – integer (optional); the rank of the matroids; \(0 \le r \le n\)

  • type – string (default: 'all'); the type of the matroids; must be one of the following:

    • 'all' – all matroids; available: (n=0-9), (n=0-12, r=0-2), (n=0-11, r=3)

    • 'unorientable' – all unorientable matroids; the rank r must be specified; available: (n=7-11, r=3), (n=7-9, r=4)

    • any other type for which there exists an is_type method; availability same as for 'all'

OUTPUT: an iterator over matroids

EXAMPLES:

sage: for M in matroids.AllMatroids(2):                                         # optional - matroid_database
....:     M
all_n02_r00_#0: Matroid of rank 0 on 2 elements with 1 bases
all_n02_r01_#0: Matroid of rank 1 on 2 elements with 2 bases
all_n02_r01_#1: Matroid of rank 1 on 2 elements with 1 bases
all_n02_r02_#0: Matroid of rank 2 on 2 elements with 1 bases
sage: for M in matroids.AllMatroids(5, 3, "simple"):                            # optional - matroid_database
....:     M
simple_n05_r03_#0: Matroid of rank 3 on 5 elements with 10 bases
simple_n05_r03_#1: Matroid of rank 3 on 5 elements with 9 bases
simple_n05_r03_#2: Matroid of rank 3 on 5 elements with 8 bases
simple_n05_r03_#3: Matroid of rank 3 on 5 elements with 6 bases
sage: # optional - matroid_database
sage: for M in matroids.AllMatroids(4, type="paving"):
....:     M
paving_n04_r00_#0: Matroid of rank 0 on 4 elements with 1 bases
paving_n04_r01_#0: Matroid of rank 1 on 4 elements with 4 bases
paving_n04_r01_#1: Matroid of rank 1 on 4 elements with 3 bases
paving_n04_r01_#2: Matroid of rank 1 on 4 elements with 2 bases
paving_n04_r01_#3: Matroid of rank 1 on 4 elements with 1 bases
paving_n04_r02_#0: Matroid of rank 2 on 4 elements with 6 bases
paving_n04_r02_#1: Matroid of rank 2 on 4 elements with 5 bases
paving_n04_r02_#2: Matroid of rank 2 on 4 elements with 4 bases
paving_n04_r02_#3: Matroid of rank 2 on 4 elements with 3 bases
paving_n04_r03_#0: Matroid of rank 3 on 4 elements with 4 bases
paving_n04_r03_#1: Matroid of rank 3 on 4 elements with 3 bases
paving_n04_r04_#0: Matroid of rank 4 on 4 elements with 1 bases
sage: # optional - matroid_database
sage: for M in matroids.AllMatroids(10, 4):
....:     M
Traceback (most recent call last):
...
ValueError: (n=10, r=4, type="all") is not available in the database
sage: for M in matroids.AllMatroids(12, 3, "unorientable"):
....:     M
Traceback (most recent call last):
...
ValueError: (n=12, r=3, type="unorientable") is not available in the database
sage: for M in matroids.AllMatroids(8, type="unorientable"):
....:     M
Traceback (most recent call last):
...
ValueError: The rank needs to be specified for type "unorientable"
sage: for M in matroids.AllMatroids(6, type="nice"):
....:     M
Traceback (most recent call last):
...
AttributeError: The type "nice" is not available. There needs to be an "is_nice()"
attribute for the type to be supported.

REFERENCES:

The underlying database was retrieved from Yoshitake Matsumoto’s Database of Matroids; see [Mat2012].

sage.matroids.database_collections.BrettellMatroids()#

Return an iterator over Brettell’s matroid collection.

EXAMPLES:

sage: BM = list(matroids.BrettellMatroids()); len(BM)
68
sage: import random
sage: M = random.choice(BM)
sage: M.is_valid()
True

See also

Matroid catalog, under Brettell's matroid collection.

sage.matroids.database_collections.OxleyMatroids()#

Return an iterator over Oxley’s matroid collection.

EXAMPLES:

sage: OM = list(matroids.OxleyMatroids()); len(OM)
44
sage: import random
sage: M = random.choice(OM)
sage: M.is_valid()
True

See also

Matroid catalog, under Oxley's matroid collection.

REFERENCES:

These matroids are the nonparametrized matroids that appear in the Appendix Some Interesting Matroids in [Oxl2011] (p. 639-64).

sage.matroids.database_collections.VariousMatroids()#

Return an iterator over various other named matroids.

EXAMPLES:

sage: VM = list(matroids.VariousMatroids()); len(VM)
16
sage: import random
sage: M = random.choice(VM)
sage: M.is_valid()
True

See also

Matroid catalog, under Collection of various matroids.