Set systems¶
Many matroid methods return a collection of subsets. In this module a class
SetSystem
is defined to do
just this. The class is intended for internal use, so all you can do as a user
is iterate over its members.
The class is equipped with partition refinement methods to help with matroid isomorphism testing.
AUTHORS:
Rudi Pendavingh, Stefan van Zwam (2013-04-01): initial version
Methods¶
- class sage.matroids.set_system.SetSystem¶
Bases:
object
A
SetSystem
is an enumerator of a collection of subsets of a given fixed and finite ground set. It offers the possibility to enumerate its contents. One is most likely to encounter these as output from some Matroid methods:sage: M = matroids.named_matroids.Fano() sage: M.circuits() Iterator over a system of subsets
To access the sets in this structure, simply iterate over them. The simplest way must be:
sage: from sage.matroids.set_system import SetSystem sage: S = SetSystem([1, 2, 3, 4], [[1, 2], [3, 4], [1, 2, 4]]) sage: T = list(S)
Or immediately use it to iterate:
sage: from sage.matroids.set_system import SetSystem sage: S = SetSystem([1, 2, 3, 4], [[1, 2], [3, 4], [1, 2, 4]]) sage: [min(X) for X in S] [1, 3, 1]
Note that this class is intended for runtime, so no loads/dumps mechanism was implemented.
Warning
The only guaranteed behavior of this class is that it is iterable. It is expected that M.circuits(), M.bases(), and so on will in the near future return actual iterators. All other methods (which are already hidden by default) are only for internal use by the Sage matroid code.
- is_connected()¶
Test if the
SetSystem
is connected.A
SetSystem
is connected if there is no nonempty proper subsetX
of the ground set so the each subset is either contained inX
or disjoint fromX
.EXAMPLES:
sage: from sage.matroids.set_system import SetSystem sage: S = SetSystem([1, 2, 3, 4], [[1, 2], [3, 4], [1, 2, 4]]) sage: S.is_connected() True sage: S = SetSystem([1, 2, 3, 4], [[1, 2], [3, 4]]) sage: S.is_connected() False sage: S = SetSystem([1], []) sage: S.is_connected() True
- class sage.matroids.set_system.SetSystemIterator¶
Bases:
object
Create an iterator for a SetSystem.
Called internally when iterating over the contents of a SetSystem.
EXAMPLES:
sage: from sage.matroids.set_system import SetSystem sage: S = SetSystem([1, 2, 3, 4], [[1, 2], [3, 4], [1, 2, 4]]) sage: type(S.__iter__()) <... 'sage.matroids.set_system.SetSystemIterator'>