For direct access to the methods newlabel(), setprint() and get_nonisomorphic_matroids(), type:
sage: from sage.matroids.advanced import *
See also sage.matroids.advanced.
AUTHORS:
Return non-isomorphic members of the matroids in set MSet.
For direct access to get_nonisomorphic_matroids, run:
sage: from sage.matroids.advanced import *
INPUT:
OUTPUT:
A list containing one representative of each isomorphism class of members of MSet.
EXAMPLES:
sage: from sage.matroids.advanced import *
sage: L = matroids.Uniform(3, 5).extensions()
sage: len(list(L))
32
sage: len(get_nonisomorphic_matroids(L))
5
Attempt to construct a regular representation of a matroid.
INPUT:
OUTPUT:
Return a -matrix over the integers such that, if the input is
a regular matroid, then the output is a totally unimodular matrix
representing that matroid.
EXAMPLES:
sage: from sage.matroids.utilities import make_regular_matroid_from_matroid
sage: make_regular_matroid_from_matroid(
....: matroids.CompleteGraphic(6)).is_isomorphic(
....: matroids.CompleteGraphic(6))
True
Create a new element label different from the labels in groundset.
INPUT:
OUTPUT:
A string not in the set groundset.
For direct access to newlabel, run:
sage: from sage.matroids.advanced import *
ALGORITHM:
EXAMPLES:
sage: from sage.matroids.advanced import newlabel
sage: S = set(['a', 42, 'b'])
sage: newlabel(S) in S
False
sage: S = set('abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789')
sage: t = newlabel(S)
sage: len(t)
63
sage: t[0]
'e'
Return a fixed version of sets contractions and deletions.
INPUT:
OUTPUT:
An independent set C and a coindependent set D such that
matroid / contractions \ deletions == matroid / C \ D
Raise an error if either is not a subset of the groundset of matroid or if they are not disjoint.
This function is used by the Matroid.minor() method.
EXAMPLES:
sage: from sage.matroids.utilities import setprint
sage: from sage.matroids.utilities import sanitize_contractions_deletions
sage: M = matroids.named_matroids.Fano()
sage: setprint(sanitize_contractions_deletions(M, 'abc', 'defg'))
[{'a', 'b', 'c'}, {'d', 'e', 'f', 'g'}]
sage: setprint(sanitize_contractions_deletions(M, 'defg', 'abc'))
[{'d', 'e', 'g'}, {'a', 'b', 'c', 'f'}]
sage: setprint(sanitize_contractions_deletions(M, [1, 2, 3], 'efg'))
Traceback (most recent call last):
...
ValueError: input contractions is not a subset of the groundset.
sage: setprint(sanitize_contractions_deletions(M, 'efg', [1, 2, 3]))
Traceback (most recent call last):
...
ValueError: input deletions is not a subset of the groundset.
sage: setprint(sanitize_contractions_deletions(M, 'ade', 'efg'))
Traceback (most recent call last):
...
ValueError: contraction and deletion sets are not disjoint.
Print nested data structures nicely.
Python’s data structures set and frozenset do not print nicely. This function can be used as replacement for print to overcome this. For direct access to setprint, run:
sage: from sage.matroids.advanced import *
Note
This function will be redundant when Sage moves to Python 3, since the default print will suffice then.
INPUT:
OUTPUT:
None. However, the function prints a nice representation of X.
EXAMPLES:
Output looks much better:
sage: from sage.matroids.advanced import setprint
sage: L = [{1, 2, 3}, {1, 2, 4}, {2, 3, 4}, {4, 1, 3}]
sage: print(L)
[set([1, 2, 3]), set([1, 2, 4]), set([2, 3, 4]), set([1, 3, 4])]
sage: setprint(L)
[{1, 2, 3}, {1, 2, 4}, {2, 3, 4}, {1, 3, 4}]
Note that for iterables, the effect can be undesirable:
sage: from sage.matroids.advanced import setprint
sage: M = matroids.named_matroids.Fano().delete('efg')
sage: M.bases()
Iterator over a system of subsets
sage: setprint(M.bases())
[{'a', 'b', 'c'}, {'a', 'c', 'd'}, {'a', 'b', 'd'}]
An exception was made for subclasses of SageObject:
sage: from sage.matroids.advanced import setprint
sage: G = graphs.PetersenGraph()
sage: list(G)
[0, 1, 2, 3, 4, 5, 6, 7, 8, 9]
sage: setprint(G)
Petersen graph: Graph on 10 vertices
Create the string for use by setprint().
INPUT:
OUTPUT:
A string representation of the object, with nice notation for sets and frozensets.
EXAMPLES:
sage: from sage.matroids.utilities import setprint_s
sage: L = [{1, 2, 3}, {1, 2, 4}, {2, 3, 4}, {4, 1, 3}]
sage: setprint_s(L)
'[{1, 2, 3}, {1, 2, 4}, {2, 3, 4}, {1, 3, 4}]'
The toplevel argument only affects strings, to mimic print‘s behavior:
sage: X = 'abcd'
sage: setprint_s(X)
"'abcd'"
sage: setprint_s(X, toplevel=True)
'abcd'