passagemath-graphs 10.5.10__cp39-cp39-macosx_14_0_arm64.whl → 10.5.43__cp39-cp39-macosx_14_0_arm64.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (140) hide show
  1. {passagemath_graphs-10.5.10.dist-info → passagemath_graphs-10.5.43.dist-info}/METADATA +126 -30
  2. passagemath_graphs-10.5.43.dist-info/RECORD +256 -0
  3. {passagemath_graphs-10.5.10.dist-info → passagemath_graphs-10.5.43.dist-info}/WHEEL +2 -1
  4. passagemath_graphs.dylibs/libgmp.10.dylib +0 -0
  5. sage/all__sagemath_graphs.py +5 -0
  6. sage/combinat/abstract_tree.py +1 -1
  7. sage/combinat/binary_tree.py +1 -1
  8. sage/combinat/cluster_algebra_quiver/all.py +1 -1
  9. sage/combinat/cluster_algebra_quiver/cluster_seed.py +28 -24
  10. sage/combinat/cluster_algebra_quiver/interact.py +4 -0
  11. sage/combinat/designs/MOLS_handbook_data.py +5 -5
  12. sage/combinat/designs/bibd.py +10 -9
  13. sage/combinat/designs/covering_array.py +3 -3
  14. sage/combinat/designs/covering_design.py +2 -1
  15. sage/combinat/designs/database.py +11 -10
  16. sage/combinat/designs/designs_pyx.cpython-39-darwin.so +0 -0
  17. sage/combinat/designs/designs_pyx.pyx +13 -45
  18. sage/combinat/designs/difference_family.py +6 -6
  19. sage/combinat/designs/difference_matrices.py +1 -1
  20. sage/combinat/designs/evenly_distributed_sets.cpython-39-darwin.so +0 -0
  21. sage/combinat/designs/evenly_distributed_sets.pyx +15 -22
  22. sage/combinat/designs/ext_rep.py +9 -14
  23. sage/combinat/designs/gen_quadrangles_with_spread.cpython-39-darwin.so +0 -0
  24. sage/combinat/designs/gen_quadrangles_with_spread.pyx +1 -1
  25. sage/combinat/designs/group_divisible_designs.py +1 -1
  26. sage/combinat/designs/incidence_structures.py +8 -8
  27. sage/combinat/designs/latin_squares.py +1 -1
  28. sage/combinat/designs/orthogonal_arrays_build_recursive.py +8 -7
  29. sage/combinat/designs/orthogonal_arrays_find_recursive.cpython-39-darwin.so +0 -0
  30. sage/combinat/designs/resolvable_bibd.py +1 -1
  31. sage/combinat/designs/steiner_quadruple_systems.py +1 -1
  32. sage/combinat/designs/subhypergraph_search.cpython-39-darwin.so +0 -0
  33. sage/combinat/designs/subhypergraph_search.pyx +9 -9
  34. sage/combinat/finite_state_machine_generators.py +2 -2
  35. sage/combinat/graph_path.py +3 -3
  36. sage/combinat/interval_posets.py +10 -10
  37. sage/combinat/ordered_tree.py +1 -1
  38. sage/combinat/posets/cartesian_product.py +1 -1
  39. sage/combinat/posets/d_complete.py +1 -1
  40. sage/combinat/posets/forest.py +1 -1
  41. sage/combinat/posets/hasse_cython.cpython-39-darwin.so +0 -0
  42. sage/combinat/posets/hasse_diagram.py +8 -6
  43. sage/combinat/posets/incidence_algebras.py +8 -8
  44. sage/combinat/posets/lattices.py +28 -4
  45. sage/combinat/posets/linear_extension_iterator.cpython-39-darwin.so +0 -0
  46. sage/combinat/posets/linear_extension_iterator.pyx +2 -0
  47. sage/combinat/posets/linear_extensions.py +7 -16
  48. sage/combinat/posets/moebius_algebra.py +1 -1
  49. sage/combinat/posets/poset_examples.py +1 -1
  50. sage/combinat/posets/posets.py +54 -56
  51. sage/combinat/rooted_tree.py +3 -3
  52. sage/combinat/tamari_lattices.py +1 -1
  53. sage/ext_data/kenzo/CP2.txt +45 -0
  54. sage/ext_data/kenzo/CP3.txt +349 -0
  55. sage/ext_data/kenzo/CP4.txt +4774 -0
  56. sage/ext_data/kenzo/README.txt +49 -0
  57. sage/ext_data/kenzo/S4.txt +20 -0
  58. sage/graphs/asteroidal_triples.cpython-39-darwin.so +0 -0
  59. sage/graphs/base/boost_graph.cpython-39-darwin.so +0 -0
  60. sage/graphs/base/boost_graph.pxd +1 -1
  61. sage/graphs/base/boost_graph.pyx +1 -1
  62. sage/graphs/base/c_graph.cpython-39-darwin.so +0 -0
  63. sage/graphs/base/c_graph.pxd +4 -4
  64. sage/graphs/base/c_graph.pyx +270 -184
  65. sage/graphs/base/dense_graph.cpython-39-darwin.so +0 -0
  66. sage/graphs/base/graph_backends.cpython-39-darwin.so +0 -0
  67. sage/graphs/base/sparse_graph.cpython-39-darwin.so +0 -0
  68. sage/graphs/base/static_dense_graph.cpython-39-darwin.so +0 -0
  69. sage/graphs/base/static_sparse_backend.cpython-39-darwin.so +0 -0
  70. sage/graphs/base/static_sparse_backend.pyx +93 -6
  71. sage/graphs/base/static_sparse_graph.cpython-39-darwin.so +0 -0
  72. sage/graphs/base/static_sparse_graph.pyx +1 -1
  73. sage/graphs/bipartite_graph.py +0 -1
  74. sage/graphs/centrality.cpython-39-darwin.so +0 -0
  75. sage/graphs/centrality.pyx +0 -0
  76. sage/graphs/comparability.cpython-39-darwin.so +0 -0
  77. sage/graphs/comparability.pyx +172 -138
  78. sage/graphs/connectivity.cpython-39-darwin.so +0 -0
  79. sage/graphs/connectivity.pyx +194 -18
  80. sage/graphs/convexity_properties.cpython-39-darwin.so +0 -0
  81. sage/graphs/digraph_generators.py +118 -74
  82. sage/graphs/distances_all_pairs.cpython-39-darwin.so +0 -0
  83. sage/graphs/distances_all_pairs.pyx +145 -27
  84. sage/graphs/edge_connectivity.cpython-39-darwin.so +0 -0
  85. sage/graphs/generators/basic.py +471 -130
  86. sage/graphs/generators/distance_regular.cpython-39-darwin.so +0 -0
  87. sage/graphs/generators/distance_regular.pyx +12 -12
  88. sage/graphs/generators/families.py +2 -2
  89. sage/graphs/generators/random.py +8 -13
  90. sage/graphs/generators/smallgraphs.py +12 -11
  91. sage/graphs/generic_graph.py +687 -265
  92. sage/graphs/generic_graph_pyx.cpython-39-darwin.so +0 -0
  93. sage/graphs/genus.cpython-39-darwin.so +0 -0
  94. sage/graphs/graph.py +12 -46
  95. sage/graphs/graph_coloring.cpython-39-darwin.so +0 -0
  96. sage/graphs/graph_database.py +1 -1
  97. sage/graphs/graph_decompositions/bandwidth.cpython-39-darwin.so +0 -0
  98. sage/graphs/graph_decompositions/clique_separators.cpython-39-darwin.so +0 -0
  99. sage/graphs/graph_decompositions/cutwidth.cpython-39-darwin.so +0 -0
  100. sage/graphs/graph_decompositions/fast_digraph.cpython-39-darwin.so +0 -0
  101. sage/graphs/graph_decompositions/graph_products.cpython-39-darwin.so +0 -0
  102. sage/graphs/graph_decompositions/modular_decomposition.cpython-39-darwin.so +0 -0
  103. sage/graphs/graph_decompositions/slice_decomposition.cpython-39-darwin.so +0 -0
  104. sage/graphs/graph_decompositions/tree_decomposition.cpython-39-darwin.so +0 -0
  105. sage/graphs/graph_decompositions/vertex_separation.cpython-39-darwin.so +0 -0
  106. sage/graphs/graph_generators.py +110 -55
  107. sage/graphs/graph_generators_pyx.cpython-39-darwin.so +0 -0
  108. sage/graphs/graph_latex.py +1 -1
  109. sage/graphs/graph_list.py +2 -3
  110. sage/graphs/graph_plot.py +225 -30
  111. sage/graphs/hyperbolicity.cpython-39-darwin.so +0 -0
  112. sage/graphs/independent_sets.cpython-39-darwin.so +0 -0
  113. sage/graphs/isgci.py +3 -8
  114. sage/graphs/isoperimetric_inequalities.cpython-39-darwin.so +0 -0
  115. sage/graphs/line_graph.cpython-39-darwin.so +0 -0
  116. sage/graphs/matching.py +14 -25
  117. sage/graphs/matching_covered_graph.py +871 -60
  118. sage/graphs/orientations.py +190 -134
  119. sage/graphs/path_enumeration.cpython-39-darwin.so +0 -0
  120. sage/graphs/path_enumeration.pyx +25 -25
  121. sage/graphs/spanning_tree.cpython-39-darwin.so +0 -0
  122. sage/graphs/strongly_regular_db.cpython-39-darwin.so +0 -0
  123. sage/graphs/strongly_regular_db.pyx +54 -52
  124. sage/graphs/traversals.cpython-39-darwin.so +0 -0
  125. sage/graphs/traversals.pyx +114 -46
  126. sage/graphs/trees.cpython-39-darwin.so +0 -0
  127. sage/graphs/views.cpython-39-darwin.so +0 -0
  128. sage/graphs/weakly_chordal.cpython-39-darwin.so +0 -0
  129. sage/groups/perm_gps/partn_ref/refinement_graphs.cpython-39-darwin.so +0 -0
  130. sage/knots/free_knotinfo_monoid.py +2 -3
  131. sage/knots/knot.py +1 -1
  132. sage/knots/knotinfo.py +4 -4
  133. sage/knots/link.py +58 -57
  134. sage/sandpiles/sandpile.py +2 -3
  135. sage/topology/cell_complex.py +1 -1
  136. sage/topology/cubical_complex.py +7 -7
  137. sage/topology/delta_complex.py +4 -4
  138. sage/topology/simplicial_complex.py +7 -22
  139. passagemath_graphs-10.5.10.dist-info/RECORD +0 -251
  140. {passagemath_graphs-10.5.10.dist-info → passagemath_graphs-10.5.43.dist-info}/top_level.txt +0 -0
@@ -16,12 +16,12 @@ The following methods are implemented in this module
16
16
  :widths: 30, 70
17
17
  :delim: |
18
18
 
19
- :meth:`~is_comparability_MILP` | Test whether the graph is a comparability graph (MILP)
20
- :meth:`~greedy_is_comparability` | Test whether the graph is a comparability graph (greedy algorithm)
21
- :meth:`~greedy_is_comparability_with_certificate` | Test whether the graph is a comparability graph and returns certificates (greedy algorithm)
22
- :meth:`~is_comparability` | Test whether the graph is a comparability graph
23
- :meth:`~is_permutation` | Test whether the graph is a permutation graph.
24
- :meth:`~is_transitive` | Test whether the digraph is transitive.
19
+ :meth:`~is_comparability_MILP` | Check whether the graph is a comparability graph (MILP)
20
+ :meth:`~greedy_is_comparability` | Check whether the graph is a comparability graph (greedy algorithm)
21
+ :meth:`~greedy_is_comparability_with_certificate` | Check whether the graph is a comparability graph and returns certificates (greedy algorithm)
22
+ :meth:`~is_comparability` | Check whether the graph is a comparability graph
23
+ :meth:`~is_permutation` | Check whether the graph is a permutation graph.
24
+ :meth:`~is_transitive` | Check whether the digraph is transitive.
25
25
 
26
26
  Author:
27
27
 
@@ -211,7 +211,7 @@ from copy import copy
211
211
 
212
212
  def greedy_is_comparability(g, no_certificate=False, equivalence_class=False):
213
213
  r"""
214
- Test whether the graph is a comparability graph (greedy algorithm).
214
+ Check whether the graph is a comparability graph (greedy algorithm).
215
215
 
216
216
  This method only returns no-certificates.
217
217
 
@@ -220,6 +220,8 @@ def greedy_is_comparability(g, no_certificate=False, equivalence_class=False):
220
220
 
221
221
  INPUT:
222
222
 
223
+ - ``g`` -- a graph
224
+
223
225
  - ``no_certificate`` -- whether to return a *no*-certificate when the graph
224
226
  is not a comparability graph. This certificate is an odd cycle of edges,
225
227
  each of which implies the next. It is set to ``False`` by default.
@@ -240,23 +242,33 @@ def greedy_is_comparability(g, no_certificate=False, equivalence_class=False):
240
242
 
241
243
  The Petersen Graph is not transitively orientable::
242
244
 
243
- sage: from sage.graphs.comparability import greedy_is_comparability as is_comparability
244
- sage: g = graphs.PetersenGraph()
245
- sage: is_comparability(g)
246
- False
247
- sage: is_comparability(g, no_certificate=True)
248
- (False, [2, 1, 0, 4, 3, 2])
245
+ sage: from sage.graphs.comparability import greedy_is_comparability as is_comparability
246
+ sage: g = graphs.PetersenGraph()
247
+ sage: is_comparability(g)
248
+ False
249
+ sage: is_comparability(g, no_certificate=True)
250
+ (False, [2, 1, 0, 4, 3, 2])
249
251
 
250
252
  But the Bull graph is::
251
253
 
252
- sage: g = graphs.BullGraph()
253
- sage: is_comparability(g)
254
- True
254
+ sage: g = graphs.BullGraph()
255
+ sage: is_comparability(g)
256
+ True
257
+
258
+ TESTS:
259
+
260
+ Check that the method is working even when vertices are of incomparable
261
+ types::
262
+
263
+ sage: from sage.graphs.comparability import greedy_is_comparability
264
+ sage: G = Graph([('a', 1), (1, 2), (2, 3)])
265
+ sage: greedy_is_comparability(G, equivalence_class=True)
266
+ (True, [('a', 1), (2, 1), (2, 3)])
255
267
  """
256
268
  cdef int i, j
257
269
 
258
270
  # Each vertex can partition its neighbors into equivalence classes
259
- equivalence_classes = {}
271
+ cdef dict equivalence_classes = {}
260
272
  for v in g:
261
273
  equivalence_classes[v] = g.subgraph(vertices=g.neighbors(v)).complement().connected_components(sort=False)
262
274
 
@@ -287,39 +299,43 @@ def greedy_is_comparability(g, no_certificate=False, equivalence_class=False):
287
299
 
288
300
  if isit:
289
301
  if equivalence_class:
302
+ # We use a mapping between vertices and integers to deal with
303
+ # vertices of different types
304
+ int_to_vertex = list(g)
305
+ vertex_to_int = {u: i for i, u in enumerate(int_to_vertex)}
290
306
 
291
307
  # Returning the largest equivalence class
292
- cc = sorted(h.connected_components(sort=False), key=len)[-1]
308
+ cc = max(h.connected_components(sort=False), key=len)
293
309
 
294
310
  edges = []
295
311
  for v, sid in cc:
296
312
  s = equivalence_classes[v][sid]
297
313
 
298
314
  # For each edge we pick the good orientations
315
+ vi = vertex_to_int[v]
299
316
  if certif[v, sid] == 1:
300
- for vv in s:
301
- edges.append((v, vv))
317
+ edges.extend((vi, vertex_to_int[vv]) for vv in s)
302
318
  else:
303
- for vv in s:
304
- edges.append((vv, v))
319
+ edges.extend((vertex_to_int[vv], vi) for vv in s)
305
320
 
306
321
  # We return the value but take care of removing edges that were
307
322
  # added twice.
308
- return True, sorted(set(edges))
323
+ edges = [(int_to_vertex[u], int_to_vertex[v]) for u, v in sorted(set(edges))]
324
+ return True, edges
309
325
 
310
326
  return True
311
327
 
312
328
  if no_certificate:
313
- certif.append(certif[0])
314
329
  cycle = [v for v, _ in certif]
330
+ cycle.append(cycle[0])
315
331
  return False, cycle
316
332
  return False
317
333
 
318
334
 
319
335
  def greedy_is_comparability_with_certificate(g, certificate=False):
320
336
  r"""
321
- Test whether the graph is a comparability graph and returns
322
- certificates(greedy algorithm).
337
+ Check whether the graph is a comparability graph and returns
338
+ certificates (greedy algorithm).
323
339
 
324
340
  This method can return certificates of both *yes* and *no* answers.
325
341
 
@@ -328,6 +344,8 @@ def greedy_is_comparability_with_certificate(g, certificate=False):
328
344
 
329
345
  INPUT:
330
346
 
347
+ - ``g`` -- a graph
348
+
331
349
  - ``certificate`` -- boolean; whether to return a
332
350
  certificate. *Yes*-answers the certificate is a transitive orientation of
333
351
  `G`, and a *no* certificates is an odd cycle of sequentially forcing
@@ -337,24 +355,34 @@ def greedy_is_comparability_with_certificate(g, certificate=False):
337
355
 
338
356
  The 5-cycle or the Petersen Graph are not transitively orientable::
339
357
 
340
- sage: from sage.graphs.comparability import greedy_is_comparability_with_certificate as is_comparability
341
- sage: is_comparability(graphs.CycleGraph(5), certificate=True)
342
- (False, [2, 1, 0, 4, 3, 2])
343
- sage: g = graphs.PetersenGraph()
344
- sage: is_comparability(g)
345
- False
346
- sage: is_comparability(g, certificate=True)
347
- (False, [2, 1, 0, 4, 3, 2])
358
+ sage: from sage.graphs.comparability import greedy_is_comparability_with_certificate as is_comparability
359
+ sage: is_comparability(graphs.CycleGraph(5), certificate=True)
360
+ (False, [2, 1, 0, 4, 3, 2])
361
+ sage: g = graphs.PetersenGraph()
362
+ sage: is_comparability(g)
363
+ False
364
+ sage: is_comparability(g, certificate=True)
365
+ (False, [2, 1, 0, 4, 3, 2])
348
366
 
349
367
  But the Bull graph is::
350
368
 
351
- sage: g = graphs.BullGraph()
352
- sage: is_comparability(g)
353
- True
354
- sage: is_comparability(g, certificate = True)
355
- (True, Digraph on 5 vertices)
356
- sage: is_comparability(g, certificate = True)[1].is_transitive()
357
- True
369
+ sage: g = graphs.BullGraph()
370
+ sage: is_comparability(g)
371
+ True
372
+ sage: is_comparability(g, certificate = True)
373
+ (True, Digraph on 5 vertices)
374
+ sage: is_comparability(g, certificate = True)[1].is_transitive()
375
+ True
376
+
377
+ TESTS:
378
+
379
+ Check that the method is working even when vertices are of incomparable
380
+ types::
381
+
382
+ sage: from sage.graphs.comparability import greedy_is_comparability_with_certificate
383
+ sage: G = Graph([('a', 1), (1, 2), (2, 3)])
384
+ sage: greedy_is_comparability_with_certificate(G, certificate=True)
385
+ (True, Digraph on 4 vertices)
358
386
  """
359
387
  isit, certif = greedy_is_comparability(g, no_certificate=True, equivalence_class=True)
360
388
  if not isit:
@@ -394,73 +422,70 @@ def greedy_is_comparability_with_certificate(g, certificate=False):
394
422
 
395
423
  def is_comparability_MILP(g, certificate=False, solver=None, verbose=0):
396
424
  r"""
397
- Test whether the graph is a comparability graph (MILP).
425
+ Check whether the graph is a comparability graph (MILP).
398
426
 
399
427
  INPUT:
400
428
 
401
- - ``certificate`` -- boolean; whether to return a certificate for
402
- yes instances. This method cannot return negative certificates.
429
+ - ``g`` -- a graph
403
430
 
404
- - ``solver`` -- (default: ``None``) specify a Linear Program (LP) solver to
405
- be used. If set to ``None``, the default one is used. For more information
406
- on LP solvers and which default solver is used, see the method
407
- :meth:`~sage.numerical.mip.MixedIntegerLinearProgram.solve` of the class
408
- :class:`~sage.numerical.mip.MixedIntegerLinearProgram`.
431
+ - ``certificate`` -- boolean (default: ``False``); whether to return a
432
+ certificate for yes instances. This method cannot return negative
433
+ certificates.
434
+
435
+ - ``solver`` -- string (default: ``None``); specifies a Mixed Integer Linear
436
+ Programming (MILP) solver to be used. If set to ``None``, the default one
437
+ is used. For more information on MILP solvers and which default solver is
438
+ used, see the method :meth:`solve
439
+ <sage.numerical.mip.MixedIntegerLinearProgram.solve>` of the class
440
+ :class:`MixedIntegerLinearProgram
441
+ <sage.numerical.mip.MixedIntegerLinearProgram>`.
409
442
 
410
443
  - ``verbose`` -- integer (default: 0); sets the level of verbosity. Set
411
444
  to 0 by default, which means quiet.
412
445
 
413
- EXAMPLES:
446
+ EXAMPLES:
414
447
 
415
448
  The 5-cycle or the Petersen Graph are not transitively orientable::
416
449
 
417
- sage: from sage.graphs.comparability import is_comparability_MILP as is_comparability
418
- sage: is_comparability(graphs.CycleGraph(5), certificate=True) # needs sage.numerical.mip
419
- (False, None)
420
- sage: g = graphs.PetersenGraph()
421
- sage: is_comparability(g, certificate=True) # needs sage.numerical.mip
422
- (False, None)
450
+ sage: from sage.graphs.comparability import is_comparability_MILP as is_comparability
451
+ sage: is_comparability(graphs.CycleGraph(5), certificate=True) # needs sage.numerical.mip
452
+ (False, None)
453
+ sage: g = graphs.PetersenGraph()
454
+ sage: is_comparability(g, certificate=True) # needs sage.numerical.mip
455
+ (False, None)
423
456
 
424
457
  But the Bull graph is::
425
458
 
426
- sage: g = graphs.BullGraph()
427
- sage: is_comparability(g) # needs sage.numerical.mip
428
- True
429
- sage: is_comparability(g, certificate=True) # needs sage.numerical.mip
430
- (True, Digraph on 5 vertices)
431
- sage: is_comparability(g, certificate=True)[1].is_transitive() # needs sage.numerical.mip
432
- True
459
+ sage: g = graphs.BullGraph()
460
+ sage: is_comparability(g) # needs sage.numerical.mip
461
+ True
462
+ sage: is_comparability(g, certificate=True) # needs sage.numerical.mip
463
+ (True, Digraph on 5 vertices)
464
+ sage: is_comparability(g, certificate=True)[1].is_transitive() # needs sage.numerical.mip
465
+ True
433
466
  """
434
467
  from sage.numerical.mip import MixedIntegerLinearProgram, MIPSolverException
435
- cdef int i
436
-
437
468
  p = MixedIntegerLinearProgram(solver=solver)
438
469
  o = p.new_variable(binary=True)
439
470
 
440
471
  for u, v in g.edge_iterator(labels=False):
441
472
  p.add_constraint(o[u, v] + o[v, u] == 1)
442
473
 
474
+ from itertools import combinations
443
475
  for u in g:
444
- neighbors = g.neighbors(u)
445
-
446
- for i in range(len(neighbors)):
447
- v = neighbors[i]
448
- for j in range(i + 1, len(neighbors)):
449
- vv = neighbors[j]
450
-
451
- # If there is an edge between v and vv, we must be
452
- # sure it is in the good direction when v-u-vv is a
453
- # directed path
454
- if g.has_edge(v, vv):
455
- p.add_constraint(o[u, v] + o[vv, u] - o[vv, v] <= 1)
456
- p.add_constraint(o[u, vv] + o[v, u] - o[v, vv] <= 1)
457
-
458
- # If there is no edge, there are only two
459
- # orientations possible (see the module's documentation
460
- # about edges which imply each other)
461
- else:
462
- p.add_constraint(o[u, v] + o[vv, u] <= 1)
463
- p.add_constraint(o[u, vv] + o[v, u] <= 1)
476
+ for v, vv in combinations(g.neighbors(u), 2):
477
+
478
+ # If there is an edge between v and vv, we must be sure it is in the
479
+ # good direction when v-u-vv is a directed path
480
+ if g.has_edge(v, vv):
481
+ p.add_constraint(o[u, v] + o[vv, u] - o[vv, v] <= 1)
482
+ p.add_constraint(o[u, vv] + o[v, u] - o[v, vv] <= 1)
483
+
484
+ # If there is no edge, there are only two orientations possible (see
485
+ # the module's documentation about edges which imply each other)
486
+ else:
487
+ p.add_constraint(o[u, v] + o[vv, u] <= 1)
488
+ p.add_constraint(o[u, vv] + o[v, u] <= 1)
464
489
 
465
490
  try:
466
491
  p.solve(log=verbose)
@@ -495,11 +520,14 @@ def is_comparability_MILP(g, certificate=False, solver=None, verbose=0):
495
520
  def is_comparability(g, algorithm='greedy', certificate=False, check=True,
496
521
  solver=None, verbose=0):
497
522
  r"""
498
- Test whether the graph is a comparability graph.
523
+ Check whether the graph is a comparability graph.
499
524
 
500
525
  INPUT:
501
526
 
502
- - ``algorithm`` -- choose the implementation used to do the test
527
+ - ``g`` -- a graph
528
+
529
+ - ``algorithm`` -- string (default: ``'greedy'``); choose the implementation
530
+ used to do the test
503
531
 
504
532
  - ``'greedy'`` -- a greedy algorithm (see the documentation of the
505
533
  :mod:`comparability module <sage.graphs.comparability>`)
@@ -509,20 +537,22 @@ def is_comparability(g, algorithm='greedy', certificate=False, check=True,
509
537
  certificates ! When ``certificate = True``, negative certificates are
510
538
  always equal to ``None``. ``True`` certificates are valid, though.
511
539
 
512
- - ``certificate`` -- boolean; whether to return a
540
+ - ``certificate`` -- boolean (default: ``False``); whether to return a
513
541
  certificate. *Yes*-answers the certificate is a transitive orientation of
514
542
  `G`, and a *no* certificates is an odd cycle of sequentially forcing
515
543
  edges.
516
544
 
517
- - ``check`` -- boolean; whether to check that the
545
+ - ``check`` -- boolean (default: ``True``); whether to check that the
518
546
  yes-certificates are indeed transitive. As it is very quick
519
547
  compared to the rest of the operation, it is enabled by default.
520
548
 
521
- - ``solver`` -- (default: ``None``) specify a Linear Program (LP) solver to
522
- be used. If set to ``None``, the default one is used. For more information
523
- on LP solvers and which default solver is used, see the method
524
- :meth:`~sage.numerical.mip.MixedIntegerLinearProgram.solve` of the class
525
- :class:`~sage.numerical.mip.MixedIntegerLinearProgram`.
549
+ - ``solver`` -- string (default: ``None``); specifies a Mixed Integer Linear
550
+ Programming (MILP) solver to be used. If set to ``None``, the default one
551
+ is used. For more information on MILP solvers and which default solver is
552
+ used, see the method :meth:`solve
553
+ <sage.numerical.mip.MixedIntegerLinearProgram.solve>` of the class
554
+ :class:`MixedIntegerLinearProgram
555
+ <sage.numerical.mip.MixedIntegerLinearProgram>`.
526
556
 
527
557
  - ``verbose`` -- integer (default: 0); sets the level of verbosity. Set
528
558
  to 0 by default, which means quiet.
@@ -538,15 +568,14 @@ def is_comparability(g, algorithm='greedy', certificate=False, check=True,
538
568
 
539
569
  TESTS:
540
570
 
541
- Let us ensure that no exception is raised when we go over all
542
- small graphs::
571
+ Let us ensure that no exception is raised when we go over all small graphs::
543
572
 
544
573
  sage: from sage.graphs.comparability import is_comparability
545
574
  sage: [len([g for g in graphs(i) if is_comparability(g, certificate=True)[0]]) for i in range(7)] # needs nauty
546
575
  [1, 1, 2, 4, 11, 33, 144]
547
576
  """
548
577
  g._scream_if_not_simple()
549
- if g.size() == 0:
578
+ if not g.size():
550
579
  if certificate:
551
580
  from sage.graphs.digraph import DiGraph
552
581
  return True, DiGraph(g)
@@ -569,8 +598,8 @@ def is_comparability(g, algorithm='greedy', certificate=False, check=True,
569
598
  if check and isit and (not certif.is_transitive()):
570
599
  raise ValueError("Looks like there is a bug somewhere. The "
571
600
  "algorithm thinks that the orientation is "
572
- "transitive, but we just checked and it is not."
573
- "Please report the bug on sage-devel, and give"
601
+ "transitive, but we just checked and it is not. "
602
+ "Please report the bug on sage-devel, and give "
574
603
  "us the graph that made this method fail !")
575
604
 
576
605
  return isit, certif
@@ -579,15 +608,17 @@ def is_comparability(g, algorithm='greedy', certificate=False, check=True,
579
608
  def is_permutation(g, algorithm='greedy', certificate=False, check=True,
580
609
  solver=None, verbose=0):
581
610
  r"""
582
- Test whether the graph is a permutation graph.
611
+ Check whether the graph is a permutation graph.
583
612
 
584
613
  For more information on permutation graphs, refer to the documentation of
585
614
  the :mod:`comparability module <sage.graphs.comparability>`.
586
615
 
587
616
  INPUT:
588
617
 
589
- - ``algorithm`` -- choose the implementation used for the subcalls to
590
- :meth:`is_comparability`
618
+ - ``g`` -- a graph
619
+
620
+ - ``algorithm`` -- string (default: ``'greedy'``); choose the implementation
621
+ used for the subcalls to :meth:`is_comparability`
591
622
 
592
623
  - ``'greedy'`` -- a greedy algorithm (see the documentation of the
593
624
  :mod:`comparability module <sage.graphs.comparability>`)
@@ -597,20 +628,23 @@ def is_permutation(g, algorithm='greedy', certificate=False, check=True,
597
628
  certificates ! When ``certificate = True``, negative certificates are
598
629
  always equal to ``None``. ``True`` certificates are valid, though.
599
630
 
600
- - ``certificate`` -- boolean; whether to return a certificate for the
601
- answer given. For ``True`` answers the certificate is a permutation, for
602
- ``False`` answers it is a no-certificate for the test of comparability or
603
- co-comparability.
631
+ - ``certificate`` -- boolean (default: ``False``); whether to return a
632
+ certificate for the answer given. For ``True`` answers the certificate is
633
+ a permutation, for ``False`` answers it is a no-certificate for the test
634
+ of comparability or co-comparability.
604
635
 
605
- - ``check`` -- boolean; whether to check that the permutations returned
606
- indeed create the expected Permutation graph. Pretty cheap compared to the
607
- rest, hence a good investment. It is enabled by default.
636
+ - ``check`` -- boolean (default: ``True``); whether to check that the
637
+ permutations returned indeed create the expected Permutation graph. Pretty
638
+ cheap compared to the rest, hence a good investment. It is enabled by
639
+ default.
608
640
 
609
- - ``solver`` -- (default: ``None``) specify a Linear Program (LP) solver to
610
- be used. If set to ``None``, the default one is used. For more information
611
- on LP solvers and which default solver is used, see the method
612
- :meth:`~sage.numerical.mip.MixedIntegerLinearProgram.solve` of the class
613
- :class:`~sage.numerical.mip.MixedIntegerLinearProgram`.
641
+ - ``solver`` -- string (default: ``None``); specifies a Mixed Integer Linear
642
+ Programming (MILP) solver to be used. If set to ``None``, the default one
643
+ is used. For more information on MILP solvers and which default solver is
644
+ used, see the method :meth:`solve
645
+ <sage.numerical.mip.MixedIntegerLinearProgram.solve>` of the class
646
+ :class:`MixedIntegerLinearProgram
647
+ <sage.numerical.mip.MixedIntegerLinearProgram>`.
614
648
 
615
649
  - ``verbose`` -- integer (default: 0); sets the level of verbosity. Set
616
650
  to 0 by default, which means quiet.
@@ -645,33 +679,33 @@ def is_permutation(g, algorithm='greedy', certificate=False, check=True,
645
679
 
646
680
  Trying random permutations, first with the greedy algorithm::
647
681
 
648
- sage: from sage.graphs.comparability import is_permutation
649
- sage: for i in range(20):
650
- ....: p = Permutations(10).random_element()
651
- ....: g1 = graphs.PermutationGraph(p)
652
- ....: isit, certif = is_permutation(g1, certificate=True)
653
- ....: if not isit:
654
- ....: print("Something is wrong here !!")
655
- ....: break
656
- ....: g2 = graphs.PermutationGraph(*certif)
657
- ....: if not g1.is_isomorphic(g2):
658
- ....: print("Something is wrong here !!")
659
- ....: break
682
+ sage: from sage.graphs.comparability import is_permutation
683
+ sage: for i in range(20):
684
+ ....: p = Permutations(10).random_element()
685
+ ....: g1 = graphs.PermutationGraph(p)
686
+ ....: isit, certif = is_permutation(g1, certificate=True)
687
+ ....: if not isit:
688
+ ....: print("Something is wrong here !!")
689
+ ....: break
690
+ ....: g2 = graphs.PermutationGraph(*certif)
691
+ ....: if not g1.is_isomorphic(g2):
692
+ ....: print("Something is wrong here !!")
693
+ ....: break
660
694
 
661
695
  Then with MILP::
662
696
 
663
- sage: from sage.graphs.comparability import is_permutation
664
- sage: for i in range(20): # needs sage.numerical.mip
665
- ....: p = Permutations(10).random_element()
666
- ....: g1 = graphs.PermutationGraph(p)
667
- ....: isit, certif = is_permutation(g1, algorithm='MILP', certificate=True)
668
- ....: if not isit:
669
- ....: print("Something is wrong here !!")
670
- ....: break
671
- ....: g2 = graphs.PermutationGraph(*certif)
672
- ....: if not g1.is_isomorphic(g2):
673
- ....: print("Something is wrong here !!")
674
- ....: break
697
+ sage: from sage.graphs.comparability import is_permutation
698
+ sage: for i in range(20): # needs sage.numerical.mip
699
+ ....: p = Permutations(10).random_element()
700
+ ....: g1 = graphs.PermutationGraph(p)
701
+ ....: isit, certif = is_permutation(g1, algorithm='MILP', certificate=True)
702
+ ....: if not isit:
703
+ ....: print("Something is wrong here !!")
704
+ ....: break
705
+ ....: g2 = graphs.PermutationGraph(*certif)
706
+ ....: if not g1.is_isomorphic(g2):
707
+ ....: print("Something is wrong here !!")
708
+ ....: break
675
709
  """
676
710
  if not certificate:
677
711
  # No certificate... A piece of cake