next | previous | forward | backward | up | index | toc

# groundSet -- (internal) ground set

## Synopsis

• Usage:
groundSet M
M.groundSet
• Inputs:
• M, ,
• Outputs:
• a set, of integers starting from 0

## Description

Returns the internal representation of the ground set.

Important: read the following if you encounter warnings/errors when specifying subsets of a matroid (e.g. restriction/deletion/contraction, ranks of subset, etc.)

For a matroid M, there are 2 main differences between M.groundSet and the elements of M (given by M_*). First is data types: M.groundSet is a Set, and M_* is a List. Second, M.groundSet always consists of integers from 0 to n-1, where n is the number of elements of M; on the other hand, the elements of M themselves can be arbitrary (e.g. symbols, matrices, edges in a graph, etc.).

Thus, one can think of M.groundSet as the set of indices of the elements in the list M_*: the first element of M has index 0, corresponding to the element 0 in M.groundSet; the second element of M has index 1, etc.

The key point is that all sets associated to the structure of a matroid - bases, circuits, flats, etc. - are subsets of M.groundSet (not M_*). In particular, they are also of class Set (although a collection of them is usually a List), and are also indexed from 0 to n-1. (An exception here is loops and coloops, which are given as a list of indices, rather than single-element sets).

A recommended way to circumvent this distinction between indices and elements is to use $\{0, ..., n-1\}$ as the actual elements of M, in which case an element is equal to its index in M.groundSet. Most methods in this package will accept either a list of elements or a set of indices, and if the elements of M are $\{0, ..., n-1\}$, then functionally there will be no difference between inputting lists or sets.

In summary: lists are used for elements in M, and given as sublists of M_*, while sets are used for indices, and given as subsets of M.groundSet.

 i1 : M = matroid({a,b,c,d},{{a,b},{a,c}}) o1 = a "matroid" of rank 2 on 4 elements o1 : Matroid i2 : peek M o2 = Matroid{bases => {set {0, 1}, set {0, 2}}} cache => CacheTable{...1...} groundSet => set {0, 1, 2, 3} rank => 2 i3 : M.groundSet o3 = set {0, 1, 2, 3} o3 : Set i4 : M_* o4 = {a, b, c, d} o4 : List i5 : bases M o5 = {set {0, 1}, set {0, 2}} o5 : List i6 : (bases M)#0 o6 = set {0, 1} o6 : Set i7 : circuits M o7 = {set {1, 2}, set {3}} o7 : List i8 : flats M o8 = {set {3}, set {1, 2, 3}, set {0, 3}, set {0, 1, 2, 3}} o8 : List i9 : loops M o9 = {3} o9 : List i10 : coloops M o10 = {0} o10 : List

Note in particular the types of the various outputs above.

The following illustrates how to perform operations with a specified subset of M.groundSet. In the final example, a list of indices is given, which goes against the conventions above, but the elements of the list are treated (correctly) as indices, and if debugLevel is greater than 0, then a warning is printed.

 i11 : N1 = M | {a,c,d} o11 = a "matroid" of rank 2 on 3 elements o11 : Matroid i12 : N2 = M | set{0,2,3} o12 = a "matroid" of rank 2 on 3 elements o12 : Matroid i13 : N1 == N2 o13 = true i14 : debugLevel = 1 o14 = 1 i15 : N3 = M | {0,2,3} -- gives a warning, but attempts to treat 0 as an index -- indicesOf: 0 is not a member of {a, b, c, d}. Treating 0 as an index (cf. 'help groundSet')... o15 = a "matroid" of rank 2 on 3 elements o15 : Matroid i16 : N3 == N2 o16 = true