M = matroid(E, B)
M = matroid(E, C, EntryMode => "circuits")
M = matroid(E, N, r)
M = matroid(B)
M = matroid(A)
M = matroid(G)
M = matroid(I)
The default representation of a matroid in this package is by its ground set and list of bases.


One can create a matroid by specifying its circuits or nonbases instead, using the option EntryMode. Regardless of the value of EntryMode, the bases are automatically computed in the process of creation.




If no ground set is provided, the ground set is taken to be the (sorted) union of the bases/nonbases/circuits.


If an integer n is the first argument, the ground set is taken to be {0, ..., n1}.
The nonspanning circuits, together with the target rank, may also be specified.

If a matrix is provided, then the realizable matroid on the columns of the matrix is returned. The ground set consists of columns of the matrix, and independence is determined by the method rank (which allows flexibility over general rings understood by M2).


If a graph is provided, then the graphic matroid is returned. The ground set consists of edges in the graph, and circuits are precisely the (minimal) cycles in the graph.


One can use the optional arguments Loops and ParallelEdges to specify loops and parallel edges for the graph, respectively (as the Graphs package does not currently provide functionality for loops or parallel edges). These options are intended only for use with graphic matroids. ParallelEdges should be given as a list of edges (which are twoelement sets of the form set$\{i,j\}$ where i, j are vertices in G), and Loops should be given as a list of vertices where the loops are based.



If a squarefree monomial ideal is provided, corresponding to a simplicial complex $\Delta$ via the StanleyReisner correspondence, then the matroid with independence complex $\Delta$ is returned. The ground set consists of the variables in the ring of the ideal.




This function does not check if (E,B) defines a matroid  see isWellDefined.
The bases are not stored as sets of elements of M  rather, the indices (with respect to the ground set) are stored instead. For more, see groundSet.
The object matroid is a method function with options.