# Matroids -- a package for computations with matroids

## Description

A matroid is a combinatorial structure abstracting the notion of (linear algebraic, graph-theoretic) independence. This package provides methods to perform computations with matroids in Macaulay2.

This package provides capabilities for converting between various representations of matroids, creating linear and graphic matroids from a matrix or graph, forming and detecting existence of minors, computing Tutte polynomials, and additional functions for applications of matroids to areas like optimization and convex geometry.

Matroids are stored as pairs (E, B) of a ground set E and a list B of bases, which are maximal independent subsets of the ground set. Internally, a ground set of size n is always identified with the set $\{0, ..., n-1\}$, and thus all subsets of the ground set (e.g. bases, circuits, flats) are also treated as subsets of $\{0, ..., n-1\}$ (for more, cf. groundSet). However, the actual elements of the ground set are allowed to be arbitrary (e.g. integers, symbols, vectors, edges in a graph), and can be accessed by taking subscripts.

 i1 : M = matroid({a, matrix{{-1.2},{3.78}}, x, set{4,6}, -9}, {{a, x}, {x, -9}}) o1 = a "matroid" of rank 2 on 5 elements o1 : Matroid i2 : peek M o2 = Matroid{bases => {set {0, 2}, set {2, 4}}} cache => CacheTable{...1...} groundSet => set {0, 1, 2, 3, 4} rank => 2 i3 : M_{0,1,4} o3 = {a, | -1.2 |, -9} | 3.78 | o3 : List i4 : peek restriction(M, set{1,2,3}) o4 = Matroid{bases => {set {1}} } cache => CacheTable{...1...} groundSet => set {0, 1, 2} rank => 1 i5 : circuits M o5 = {set {1}, set {3}, set {0, 4}} o5 : List i6 : netList flats M +-------------------+ o6 = |set {1, 3} | +-------------------+ |set {0, 1, 3, 4} | +-------------------+ |set {1, 2, 3} | +-------------------+ |set {0, 1, 2, 3, 4}| +-------------------+ i7 : tuttePolynomial M 2 2 3 o7 = x y + x*y o7 : ZZ[x..y]

A matroid can be specified by its bases, nonbases, circuits, from a matrix, graph, or ideal, or via a collection of predefined matroids. For more on how to construct a matroid, see matroid.

Reference Oxley, Matroid Theory, second edition. Oxford University Press, 2011.

## Contributors

The following people have generously contributed code, improved existing code, or enhanced the documentation: Aaron Dall, Chris Eur, Matthew Mastroeni, Jason McCullough, Tianyi Zhang.

• Justin Chen

## Certification Version 0.9.7 of this package was accepted for publication in volume 9 of The Journal of Software for Algebra and Geometry on 27 September 2018, in the article Matroids: a Macaulay2 package. That version can be obtained from the journal or from the Macaulay2 source code repository.

## Version

This documentation describes version 1.6.0 of Matroids.

## Source code

The source code from which this documentation is derived is in the file Matroids.m2. The auxiliary files accompanying it are in the directory Matroids/.

## Exports

• Types
• Matroid -- the class of all matroids
• Functions and commands
• Methods
• "affineGeometry(ZZ,ZZ)" -- see affineGeometry -- affine geometry of rank n+1 over F_p
• "allMatroids(ZZ)" -- see allMatroids -- returns all n-element matroids of rank r
• "allMatroids(ZZ,ZZ)" -- see allMatroids -- returns all n-element matroids of rank r
• "allMinors(Matroid,Matroid)" -- see allMinors -- returns all minors of one matroid in another
• areIsomorphic(Matroid,Matroid) -- whether two matroids are isomorphic
• "bases(Matroid)" -- see bases -- bases of matroid
• "basisIndicatorMatrix(Matroid)" -- see basisIndicatorMatrix -- matrix of basis polytope
• characteristicPolynomial(Matroid) -- computes characteristic polynomial of a matroid
• "chromaticPolynomial(Graph)" -- see chromaticPolynomial -- computes chromatic polynomial of a graph
• "circuits(Matroid)" -- see circuits -- circuits of matroid
• "closure(Matroid,List)" -- see closure -- closure of a subset of a matroid
• "closure(Matroid,Set)" -- see closure -- closure of a subset of a matroid
• "coextension(Matroid)" -- see coextension -- the free coextension of a matroid
• "cogeneratorChowRing(Matroid)" -- see cogeneratorChowRing -- cogenerator of the Chow ring of a matroid
• "coloops(Matroid)" -- see coloops -- coloops of matroid
• components(Matroid) -- connected components of matroid
• "contraction(Matroid,List)" -- see contraction -- contraction of subset of matroid
• "contraction(Matroid,Set)" -- see contraction -- contraction of subset of matroid
• "Matroid / List" -- see contraction -- contraction of subset of matroid
• "Matroid / Set" -- see contraction -- contraction of subset of matroid
• "deletion(Matroid,List)" -- see deletion -- deletion of subset of matroid
• "deletion(Matroid,Set)" -- see deletion -- deletion of subset of matroid
• /// Matroid \ List /// -- see deletion -- deletion of subset of matroid
• /// Matroid \ Set /// -- see deletion -- deletion of subset of matroid
• dual(Matroid) -- dual matroid
• "elementaryQuotient(Matroid,List)" -- see elementaryQuotient -- associated to a modular cut or linear subclass
• "extension(Matroid)" -- see extension -- of a matroid relative to a flat or modular cut
• "extension(Matroid,List)" -- see extension -- of a matroid relative to a flat or modular cut
• "extension(Matroid,Set)" -- see extension -- of a matroid relative to a flat or modular cut
• "flats(Matroid)" -- see flats -- flats of a matroid
• "flats(Matroid,ZZ)" -- see flats -- flats of a matroid
• "flats(Matroid,ZZ,String)" -- see flats -- flats of a matroid
• "fundamentalCircuit(Matroid,List,Thing)" -- see fundamentalCircuit -- fundamental circuit of independent set
• "fundamentalCircuit(Matroid,Set,ZZ)" -- see fundamentalCircuit -- fundamental circuit of independent set
• fVector(Matroid) -- f-vector of a matroid
• "getCycles(Graph)" -- see getCycles -- find cycles of graph
• "getIsos(Matroid,Matroid)" -- see getIsos -- all isomorphisms between two matroids
• "getRepresentation(Matroid)" -- see getRepresentation -- retrieves stored representation
• "getSeparation(Matroid,ZZ)" -- see getSeparation -- finds a k-separation of a matroid
• "groundSet(Matroid)" -- see groundSet -- (internal) ground set
• "hasMinor(Matroid,Matroid)" -- see hasMinor -- whether a matroid has a given minor
• "hyperplanes(Matroid)" -- see hyperplanes -- hyperplanes of a matroid
• ideal(Matroid) -- Stanley-Reisner (circuit) ideal of matroid
• "idealChowRing(Matroid)" -- see idealChowRing -- the defining ideal of the Chow ring
• independenceComplex(Matroid) -- independence complex of matroid
• "independentSets(Matroid)" -- see independentSets(Matroid,ZZ) -- independent subsets of a matroid
• "independentSets(Matroid,List)" -- see independentSets(Matroid,ZZ) -- independent subsets of a matroid
• "independentSets(Matroid,Set)" -- see independentSets(Matroid,ZZ) -- independent subsets of a matroid
• independentSets(Matroid,ZZ) -- independent subsets of a matroid
• "indicesOf(List,List)" -- see indicesOf -- indices of a sublist
• "indicesOf(Matroid,List)" -- see indicesOf -- indices of a sublist
• "is3Connected(Matroid)" -- see is3Connected -- whether a matroid is 3-connected
• "isBinary(Matroid)" -- see isBinary -- whether a matroid is representable over F_2
• isConnected(Matroid) -- whether a matroid is connected
• "isDependent(Matroid,List)" -- see isDependent -- whether a subset is dependent
• "isDependent(Matroid,Set)" -- see isDependent -- whether a subset is dependent
• "isElementaryQuotient(Matroid,Matroid)" -- see isElementaryQuotient -- whether a matroid is an elementary quotient of another matroid
• "isLinearSubclass(Matroid,List)" -- see isLinearSubclass -- whether a list of hyperplanes of a matroid is a linear subclass
• "isModularCut(Matroid,List)" -- see isModularCut -- whether a list of flats of a matroid is a modular cut
• "isNonCrossing(List,List)" -- see isNonCrossing -- whether 2 subsets are non-crossing
• "isNonCrossing(Set,Set)" -- see isNonCrossing -- whether 2 subsets are non-crossing
• isomorphism(Matroid,Matroid) -- computes an isomorphism between isomorphic matroids
• "isPositivelyOrientable(Matroid)" -- see isPositivelyOrientable -- whether a matroid is positively orientable
• "isPositivelyOriented(Matroid)" -- see isPositivelyOriented -- whether a matroid is positively oriented
• "isQuotient(Matroid,Matroid)" -- see isQuotient -- whether a matroid is a quotient of another matroid
• isSimple(Matroid) -- whether a matroid is simple
• isWellDefined(Matroid) -- whether the input is a well-defined matroid
• "latticeOfFlats(Matroid)" -- see latticeOfFlats -- lattice of flats of a matroid
• "linearSubclass(Matroid,List)" -- see linearSubclass -- associated to an elementary quotient or modular cut
• "linearSubclass(Matroid,Matroid)" -- see linearSubclass -- associated to an elementary quotient or modular cut
• "loops(Matroid)" -- see loops -- loops of matroid
• "matroid(Graph)" -- see matroid -- constructs a matroid
• "matroid(Ideal)" -- see matroid -- constructs a matroid
• "matroid(List)" -- see matroid -- constructs a matroid
• "matroid(List,List)" -- see matroid -- constructs a matroid
• "matroid(List,MonomialIdeal)" -- see matroid -- constructs a matroid
• "matroid(Matrix)" -- see matroid -- constructs a matroid
• "matroid(ZZ,List)" -- see matroid -- constructs a matroid
• Matroid + Matroid -- union of matroids
• Matroid ++ Matroid -- direct sum of matroids
• Matroid == Matroid -- whether two matroids are equal
• Matroid _ List -- elements of matroid
• "Matroid _ Set" -- see Matroid _ List -- elements of matroid
• "Matroid _ ZZ" -- see Matroid _ List -- elements of matroid
• "Matroid _*" -- see Matroid _ List -- elements of matroid
• "maxWeightBasis(Matroid,List)" -- see maxWeightBasis -- maximum weight basis using greedy algorithm
• "minor(Matroid,List,List)" -- see minor -- minor of matroid
• "minor(Matroid,Set,Set)" -- see minor -- minor of matroid
• "modularCut(Matroid,List)" -- see modularCut -- associated to an elementary quotient or linear subclass
• "modularCut(Matroid,Matroid)" -- see modularCut -- associated to an elementary quotient or linear subclass
• "nonbases(Matroid)" -- see nonbases -- nonbases of matroid
• "parallelConnection(Matroid,Matroid)" -- see parallelConnection -- parallel connection of two matroids
• "positiveOrientation(Matroid)" -- see positiveOrientation -- a positive orientation of a matroid
• "projectiveGeometry(ZZ,ZZ)" -- see projectiveGeometry -- projective geometry of dimension n over F_p
• "quickIsomorphismTest(Matroid,Matroid)" -- see quickIsomorphismTest -- quick checks for isomorphism between matroids
• rank(Matroid) -- rank of a matroid
• "rank(Matroid,List)" -- see rank(Matroid,Set) -- rank of a subset of a matroid
• rank(Matroid,Set) -- rank of a subset of a matroid
• "relabel(Matroid)" -- see relabel -- relabel a matroid
• "relabel(Matroid,HashTable)" -- see relabel -- relabel a matroid
• "relabel(Matroid,List)" -- see relabel -- relabel a matroid
• "relaxation(Matroid)" -- see relaxation -- relaxation of matroid
• "relaxation(Matroid,List)" -- see relaxation -- relaxation of matroid
• "relaxation(Matroid,Set)" -- see relaxation -- relaxation of matroid
• "Matroid | List" -- see restriction -- restriction to subset of matroid
• "Matroid | Set" -- see restriction -- restriction to subset of matroid
• "restriction(Matroid,List)" -- see restriction -- restriction to subset of matroid
• "restriction(Matroid,Set)" -- see restriction -- restriction to subset of matroid
• "readFromFile(String)" -- see saveMatroid -- save matroid to file
• "saveMatroid(Matroid)" -- see saveMatroid -- save matroid to file
• "saveMatroid(Matroid,String)" -- see saveMatroid -- save matroid to file
• "searchRepresentation(Matroid,GaloisField)" -- see searchRepresentation -- search for a representation of a matroid over a finite field
• "seriesConnection(Matroid,Matroid)" -- see seriesConnection -- series connection of two matroids
• "setRepresentation(Matroid,Matrix)" -- see setRepresentation -- stores user-defined representation
• "simpleMatroid(Matroid)" -- see simpleMatroid -- simple matroid associated to a matroid
• "specificMatroid(String)" -- see specificMatroid -- creates built-in matroid
• "specificMatroid(Symbol)" -- see specificMatroid -- creates built-in matroid
• "binarySpike(ZZ)" -- see spike -- spike matroid
• "spike(ZZ)" -- see spike -- spike matroid
• "spike(ZZ,List)" -- see spike -- spike matroid
• "sum2(Matroid,Matroid)" -- see sum2 -- 2-sum of matroids
• "swirl(ZZ)" -- see swirl -- swirl matroid
• "thetaMatroid(ZZ)" -- see thetaMatroid -- theta matroid
• "fromSageMatroid(String)" -- see toSageMatroid -- Sage format for matroid
• "toSageMatroid(Matroid)" -- see toSageMatroid -- Sage format for matroid
• "truncate(Matroid)" -- see truncate(Set,Matroid) -- the truncation of a matroid with respect to a flat
• truncate(Set,Matroid) -- the truncation of a matroid with respect to a flat
• truncate(ZZ,Matroid) -- the truncation of a matroid with respect to a flat
• "tutteEvaluate(Matroid,Thing,Thing)" -- see tutteEvaluate -- evaluate Tutte polynomial
• tuttePolynomial(Matroid) -- Tutte polynomial of a matroid
• "tuttePolynomial(Matroid,Ring)" -- see tuttePolynomial(Matroid) -- Tutte polynomial of a matroid
• "uniformMatroid(ZZ,ZZ)" -- see uniformMatroid -- uniform matroid
• "wheel(ZZ)" -- see wheel -- wheels/whirls
• "whirl(ZZ)" -- see wheel -- wheels/whirls
• Symbols
• CheckWellDefined -- an optional argument
• "ChowRingOptions" -- see idealChowRing -- the defining ideal of the Chow ring
• "FlatOrder" -- see idealChowRing -- the defining ideal of the Chow ring
• "Presentation" -- see idealChowRing -- the defining ideal of the Chow ring
• "Loops" -- see matroid -- constructs a matroid
• "ParallelEdges" -- see matroid -- constructs a matroid
• "Attempts" -- see searchRepresentation -- search for a representation of a matroid over a finite field
• "storedRepresentation" -- see setRepresentation -- stores user-defined representation

## For the programmer

The object Matroids is .