@@ -37,9 +37,7 @@ def AllMatroids(n, r=None, type="all"):
37
37
Either ``all``, ``unorientable``, or any other type for which there
38
38
exists an ``is_type()`` attribute.
39
39
40
- OUTPUT:
41
-
42
- an iterator over matroids
40
+ OUTPUT: an iterator over matroids
43
41
44
42
EXAMPLES::
45
43
@@ -82,14 +80,12 @@ def AllMatroids(n, r=None, type="all"):
82
80
....: M
83
81
Traceback (most recent call last):
84
82
...
85
- FileNotFoundError: (n=10, r=4, type="all") is not available in the
86
- database
83
+ FileNotFoundError: (n=10, r=4, type="all") is not available in the database
87
84
sage: for M in matroids.AllMatroids(12, 3, "unorientable"):
88
85
....: M
89
86
Traceback (most recent call last):
90
87
...
91
- FileNotFoundError: (n=12, r=3, type="unorientable") is not available
92
- in the database
88
+ FileNotFoundError: (n=12, r=3, type="unorientable") is not available in the database
93
89
sage: for M in matroids.AllMatroids(8, type="unorientable"):
94
90
....: M
95
91
Traceback (most recent call last):
@@ -100,8 +96,8 @@ def AllMatroids(n, r=None, type="all"):
100
96
....: M
101
97
Traceback (most recent call last):
102
98
...
103
- AttributeError: The type "nice" is not available. There needs to be an
104
- "is_nice()" attribute for the type to be supported.
99
+ AttributeError: The type "nice" is not available. There needs to be an "is_nice()"
100
+ attribute for the type to be supported.
105
101
106
102
REFERENCES:
107
103
@@ -116,59 +112,37 @@ def AllMatroids(n, r=None, type="all"):
116
112
....: for M in matroids.AllMatroids(i):
117
113
....: assert M.is_valid()
118
114
sage: all = [
119
- ....: [ 1, 1, 1, 1, 1, 1, 1, 1, 1,
120
- ....: 1, 1, 1, 1],
121
- ....: [ None, 1, 2, 3, 4, 5, 6, 7, 8,
122
- ....: 9, 10, 11, 12],
123
- ....: [ None, None, 1, 3, 7, 13, 23, 37, 58,
124
- ....: 87, 128, 183, 259],
125
- ....: [ None, None, None, 1, 4, 13, 38, 108, 325,
126
- ....: 1275, 10037, 298491, None],
127
- ....: [ None, None, None, None, 1, 5, 23, 108, 940,
128
- ....: 190214, None, None, None],
129
- ....: [ None, None, None, None, None, 1, 6, 37, 325,
130
- ....: 190214, None, None, None],
131
- ....: [ None, None, None, None, None, None, 1, 7, 58,
132
- ....: 1275, None, None, None],
133
- ....: [ None, None, None, None, None, None, None, 1, 8,
134
- ....: 87, 10037, None, None],
135
- ....: [ None, None, None, None, None, None, None, None, 1,
136
- ....: 9, 128, 298491, None],
137
- ....: [ None, None, None, None, None, None, None, None, None,
138
- ....: 1, 10, 183, None],
139
- ....: [ None, None, None, None, None, None, None, None, None,
140
- ....: None, 1, 11, 259],
141
- ....: [ None, None, None, None, None, None, None, None, None,
142
- ....: None, None, 1, 12],
143
- ....: [ None, None, None, None, None, None, None, None, None,
144
- ....: None, None, None, 1]
115
+ ....: [ 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
116
+ ....: [ None, 1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12],
117
+ ....: [ None, None, 1, 3, 7, 13, 23, 37, 58, 87, 128, 183, 259],
118
+ ....: [ None, None, None, 1, 4, 13, 38, 108, 325, 1275, 10037, 298491, None],
119
+ ....: [ None, None, None, None, 1, 5, 23, 108, 940, 190214, None, None, None],
120
+ ....: [ None, None, None, None, None, 1, 6, 37, 325, 190214, None, None, None],
121
+ ....: [ None, None, None, None, None, None, 1, 7, 58, 1275, None, None, None],
122
+ ....: [ None, None, None, None, None, None, None, 1, 8, 87, 10037, None, None],
123
+ ....: [ None, None, None, None, None, None, None, None, 1, 9, 128, 298491, None],
124
+ ....: [ None, None, None, None, None, None, None, None, None, 1, 10, 183, None],
125
+ ....: [ None, None, None, None, None, None, None, None, None, None, 1, 11, 259],
126
+ ....: [ None, None, None, None, None, None, None, None, None, None, None, 1, 12],
127
+ ....: [ None, None, None, None, None, None, None, None, None, None, None, None, 1]
145
128
....: ]
146
129
sage: for r in range(0, 12 + 1): # long time
147
130
....: for n in range(r, 12 + 1):
148
131
....: if all[r][n] and all[r][n] < 1000:
149
- ....: assert len(list(
150
- ....: matroids.AllMatroids(n, r)
151
- ....: )) == all[r][n]
132
+ ....: assert len(list(matroids.AllMatroids(n, r))) == all[r][n]
152
133
....: for M in matroids.AllMatroids(n, r):
153
134
....: assert M.is_valid()
154
135
sage: simple = [
155
- ....: [ 1, None, None, None, None, None, None, None, None,
156
- ....: None, None, None, None],
157
- ....: [ None, 1, None, None, None, None, None, None, None,
158
- ....: None, None, None, None],
159
- ....: [ None, None, 1, 1, 1, 1, 1, 1, 1,
160
- ....: 1, 1, 1, 1],
161
- ....: [ None, None, None, 1, 2, 4, 9, 23, 68,
162
- ....: 383, 5249, 232928, None],
163
- ....: [ None, None, None, None, 1, 3, 11, 49, 617,
164
- ....: 185981, None, None, None]
136
+ ....: [ 1, None, None, None, None, None, None, None, None, None, None, None, None],
137
+ ....: [ None, 1, None, None, None, None, None, None, None, None, None, None, None],
138
+ ....: [ None, None, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1],
139
+ ....: [ None, None, None, 1, 2, 4, 9, 23, 68, 383, 5249, 232928, None],
140
+ ....: [ None, None, None, None, 1, 3, 11, 49, 617, 185981, None, None, None]
165
141
....: ]
166
142
sage: for r in range(0, 4 + 1): # long time
167
143
....: for n in range(r, 12 + 1):
168
144
....: if simple[r][n] and simple[r][n] < 1000:
169
- ....: assert len(list(
170
- ....: matroids.AllMatroids(n, r, "simple")
171
- ....: )) == simple[r][n]
145
+ ....: assert len(list(matroids.AllMatroids(n, r, "simple"))) == simple[r][n]
172
146
....: for M in matroids.AllMatroids(n, r, "simple"):
173
147
....: assert M.is_valid() and M.is_simple()
174
148
sage: unorientable = [
@@ -178,11 +152,8 @@ def AllMatroids(n, r=None, type="all"):
178
152
sage: for r in range(0, 1 + 1): # long time
179
153
....: for n in range(0, 4 + 1):
180
154
....: if unorientable[r][n] and unorientable[r][n] < 1000:
181
- ....: assert len(list(
182
- ....: matroids.AllMatroids(n+7, r+3, "unorientable")
183
- ....: )) == unorientable[r][n]
184
- ....: for M in matroids.AllMatroids(
185
- ....: n+7, r+3, "unorientable"):
155
+ ....: assert len(list(matroids.AllMatroids(n+7, r+3, "unorientable"))) == unorientable[r][n]
156
+ ....: for M in matroids.AllMatroids(n+7, r+3, "unorientable"):
186
157
....: assert M.is_valid()
187
158
"""
188
159
from sage .matroids .constructor import Matroid
@@ -213,10 +184,7 @@ def AllMatroids(n, r=None, type="all"):
213
184
for r in rng :
214
185
if (r == 0 or r == n ) and type != "unorientable" :
215
186
M = Matroid (groundset = range (n ), bases = [range (r )])
216
- M .rename (
217
- type + "_n" + str (n ).zfill (2 ) + "_r" + str (r ).zfill (2 )
218
- + "_#" + "0" + ": " + repr (M )
219
- )
187
+ M .rename (type + "_n" + str (n ).zfill (2 ) + "_r" + str (r ).zfill (2 ) + "_#" + "0" + ": " + repr (M ))
220
188
if type == "all" :
221
189
yield M
222
190
else :
@@ -249,10 +217,7 @@ def AllMatroids(n, r=None, type="all"):
249
217
250
218
if type != "unorientable" and n - r < r :
251
219
M = M .dual ()
252
- M .rename (
253
- type + "_n" + str (n ).zfill (2 ) + "_r" + str (r ).zfill (2 )
254
- + "_#" + str (cnt ) + ": " + repr (M )
255
- )
220
+ M .rename (type + "_n" + str (n ).zfill (2 ) + "_r" + str (r ).zfill (2 ) + "_#" + str (cnt ) + ": " + repr (M ))
256
221
if type == "all" or type == "unorientable" :
257
222
yield M
258
223
cnt += 1
0 commit comments