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
@@ -204,7 +204,7 @@ class DiGraphGenerators:
204
204
  218
205
205
  """
206
206
 
207
- def ButterflyGraph(self, n, vertices='strings'):
207
+ def ButterflyGraph(self, n, vertices='strings', immutable=False):
208
208
  r"""
209
209
  Return a `n`-dimensional butterfly graph.
210
210
 
@@ -224,6 +224,9 @@ class DiGraphGenerators:
224
224
  vertices are zero-one strings (default) or tuples over GF(2)
225
225
  (``vertices='vectors'``)
226
226
 
227
+ - ``immutable`` -- boolean (default: ``False``); whether to return
228
+ an immutable or mutable digraph.
229
+
227
230
  EXAMPLES::
228
231
 
229
232
  sage: digraphs.ButterflyGraph(2).edges(sort=True, labels=False)
@@ -324,9 +327,10 @@ class DiGraphGenerators:
324
327
  for x in range(n + 1):
325
328
  pos[v, x] = (dec * x, i)
326
329
  return DiGraph([pos.keys(), E], format='vertices_and_edges', pos=pos,
327
- name="{}-dimensional Butterfly".format(n))
330
+ name="{}-dimensional Butterfly".format(n),
331
+ immutable=immutable)
328
332
 
329
- def Path(self, n):
333
+ def Path(self, n, immutable=False):
330
334
  r"""
331
335
  Return a directed path on `n` vertices.
332
336
 
@@ -334,6 +338,9 @@ class DiGraphGenerators:
334
338
 
335
339
  - ``n`` -- integer; number of vertices in the path
336
340
 
341
+ - ``immutable`` -- boolean (default: ``False``); whether to return
342
+ an immutable or mutable digraph.
343
+
337
344
  EXAMPLES::
338
345
 
339
346
  sage: g = digraphs.Path(5)
@@ -344,15 +351,13 @@ class DiGraphGenerators:
344
351
  sage: g.automorphism_group().cardinality() # needs sage.groups
345
352
  1
346
353
  """
347
- g = DiGraph(n, name='Path')
348
-
349
- if n:
350
- g.add_path(list(range(n)))
351
-
354
+ g = DiGraph([range(n), zip(range(n - 1), range(1, n))],
355
+ format='vertices_and_edges', name='Path',
356
+ immutable=immutable)
352
357
  g.set_pos({i: (i, 0) for i in range(n)})
353
358
  return g
354
359
 
355
- def StronglyRegular(self, n):
360
+ def StronglyRegular(self, n, immutable=False):
356
361
  r"""
357
362
  Return a Strongly Regular digraph with `n` vertices.
358
363
 
@@ -363,6 +368,9 @@ class DiGraphGenerators:
363
368
 
364
369
  - ``n`` -- integer; the number of vertices of the digraph
365
370
 
371
+ - ``immutable`` -- boolean (default: ``False``); whether to return
372
+ an immutable or mutable digraph.
373
+
366
374
  .. SEEALSO::
367
375
 
368
376
  - :func:`sage.combinat.matrices.hadamard_matrix.skew_hadamard_matrix`
@@ -398,15 +406,23 @@ class DiGraphGenerators:
398
406
  H = skew_hadamard_matrix(n + 1, skew_normalize=True)
399
407
  M = H[1:, 1:]
400
408
  M = (M + ones_matrix(n)) / 2 - identity_matrix(n)
401
- return DiGraph(M, format='adjacency_matrix', name='Strongly regular digraph')
409
+ return DiGraph(M, format='adjacency_matrix', immutable=immutable,
410
+ name='Strongly regular digraph')
402
411
 
403
- def Paley(self, q):
412
+ def Paley(self, q, immutable=False):
404
413
  r"""
405
414
  Return a Paley digraph on `q` vertices.
406
415
 
407
416
  Parameter `q` must be the power of a prime number and congruent to 3 mod
408
417
  4.
409
418
 
419
+ INPUT:
420
+
421
+ - ``q`` -- integer; the number of vertices of the digraph
422
+
423
+ - ``immutable`` -- boolean (default: ``False``); whether to return
424
+ an immutable or mutable digraph.
425
+
410
426
  .. SEEALSO::
411
427
 
412
428
  - :wikipedia:`Paley_graph`
@@ -449,13 +465,12 @@ class DiGraphGenerators:
449
465
  raise ValueError("parameter q must be a prime power")
450
466
  if not mod(q, 4) == 3:
451
467
  raise ValueError("parameter q must be congruent to 3 mod 4")
452
- g = DiGraph([FiniteField(q, 'a'),
453
- lambda i, j: (i != j) and (j - i).is_square()],
454
- loops=False,
455
- name="Paley digraph with parameter {}".format(q))
456
- return g
468
+ return DiGraph([FiniteField(q, 'a'),
469
+ lambda i, j: (i != j) and (j - i).is_square()],
470
+ format='rule', loops=False, immutable=immutable,
471
+ name="Paley digraph with parameter {}".format(q))
457
472
 
458
- def TransitiveTournament(self, n):
473
+ def TransitiveTournament(self, n, immutable=False):
459
474
  r"""
460
475
  Return a transitive tournament on `n` vertices.
461
476
 
@@ -467,6 +482,9 @@ class DiGraphGenerators:
467
482
 
468
483
  - ``n`` -- integer; number of vertices in the tournament
469
484
 
485
+ - ``immutable`` -- boolean (default: ``False``); whether to return
486
+ an immutable or mutable digraph.
487
+
470
488
  EXAMPLES::
471
489
 
472
490
  sage: g = digraphs.TransitiveTournament(5)
@@ -491,17 +509,17 @@ class DiGraphGenerators:
491
509
  ...
492
510
  ValueError: the number of vertices cannot be strictly negative
493
511
  """
494
- g = DiGraph(n, name="Transitive Tournament")
495
-
496
- for i in range(n - 1):
497
- for j in range(i + 1, n):
498
- g.add_edge(i, j)
512
+ if n < 0:
513
+ raise ValueError('the number of vertices cannot be strictly negative')
499
514
 
515
+ from itertools import combinations
516
+ g = DiGraph([range(n), combinations(range(n), 2)],
517
+ format='vertices_and_edges', immutable=immutable,
518
+ name="Transitive Tournament")
500
519
  g._circle_embedding(list(range(n)))
501
-
502
520
  return g
503
521
 
504
- def RandomTournament(self, n):
522
+ def RandomTournament(self, n, immutable=False):
505
523
  r"""
506
524
  Return a random tournament on `n` vertices.
507
525
 
@@ -513,6 +531,9 @@ class DiGraphGenerators:
513
531
 
514
532
  - ``n`` -- integer; number of vertices
515
533
 
534
+ - ``immutable`` -- boolean (default: ``False``); whether to return
535
+ an immutable or mutable digraph.
536
+
516
537
  EXAMPLES::
517
538
 
518
539
  sage: T = digraphs.RandomTournament(10); T
@@ -534,15 +555,17 @@ class DiGraphGenerators:
534
555
  - :meth:`~sage.graphs.digraph_generators.DiGraphGenerators.Complete`
535
556
  - :meth:`~sage.graphs.digraph_generators.DiGraphGenerators.RandomSemiComplete`
536
557
  """
537
- from sage.misc.prandom import random
538
- g = DiGraph(n, name="Random Tournament")
558
+ if n < 0:
559
+ raise ValueError('the number of vertices cannot be strictly negative')
539
560
 
540
- for i in range(n - 1):
541
- for j in range(i + 1, n):
542
- if random() <= .5:
543
- g.add_edge(i, j)
544
- else:
545
- g.add_edge(j, i)
561
+ from itertools import combinations
562
+ from sage.misc.prandom import getrandbits
563
+
564
+ bits = getrandbits(n * (n - 1) // 2)
565
+ edges = ((i, j) if (bits >> k) & 1 else (j, i)
566
+ for k, (i, j) in enumerate(combinations(range(n), 2)))
567
+ g = DiGraph([range(n), edges], format='vertices_and_edges',
568
+ immutable=immutable, name="Random Tournament")
546
569
 
547
570
  g._circle_embedding(list(range(n)))
548
571
 
@@ -550,7 +573,8 @@ class DiGraphGenerators:
550
573
 
551
574
  def tournaments_nauty(self, n,
552
575
  min_out_degree=None, max_out_degree=None,
553
- strongly_connected=False, debug=False, options=""):
576
+ strongly_connected=False, debug=False, options="",
577
+ immutable=False):
554
578
  r"""
555
579
  Iterator over all tournaments on `n` vertices using Nauty.
556
580
 
@@ -572,6 +596,9 @@ class DiGraphGenerators:
572
596
  to Nauty's gentourng. See its documentation for more information :
573
597
  `<https://pallini.di.uniroma1.it>`_.
574
598
 
599
+ - ``immutable`` -- boolean (default: ``False``); whether to return
600
+ immutable or mutable digraphs.
601
+
575
602
  EXAMPLES::
576
603
 
577
604
  sage: # needs nauty
@@ -614,22 +641,11 @@ class DiGraphGenerators:
614
641
  if debug:
615
642
  yield sp.stderr.readline()
616
643
 
617
- gen = sp.stdout
618
- while True:
619
- try:
620
- s = bytes_to_str(next(gen))
621
- except StopIteration:
622
- # Exhausted list of graphs from nauty geng
623
- return
624
-
625
- G = DiGraph(n)
644
+ def edges(s):
626
645
  i = 0
627
646
  j = 1
628
647
  for b in s[:-1]:
629
- if b == '0':
630
- G.add_edge(i, j)
631
- else:
632
- G.add_edge(j, i)
648
+ yield (i, j) if b == '0' else (j, i)
633
649
 
634
650
  if j == n - 1:
635
651
  i += 1
@@ -637,9 +653,18 @@ class DiGraphGenerators:
637
653
  else:
638
654
  j += 1
639
655
 
640
- yield G
656
+ gen = sp.stdout
657
+ while True:
658
+ try:
659
+ s = bytes_to_str(next(gen))
660
+ except StopIteration:
661
+ # Exhausted list of graphs from nauty geng
662
+ return
663
+
664
+ yield DiGraph([range(n), edges(s)], format='vertices_and_edges',
665
+ immutable=immutable)
641
666
 
642
- def nauty_directg(self, graphs, options='', debug=False):
667
+ def nauty_directg(self, graphs, options='', debug=False, immutable=False):
643
668
  r"""
644
669
  Return an iterator yielding digraphs using nauty's ``directg`` program.
645
670
 
@@ -671,6 +696,9 @@ class DiGraphGenerators:
671
696
  - ``debug`` -- boolean (default: ``False``); if ``True`` ``directg``
672
697
  standard error and standard output are displayed
673
698
 
699
+ - ``immutable`` -- boolean (default: ``False``); whether to return
700
+ immutable or mutable digraphs.
701
+
674
702
  EXAMPLES::
675
703
 
676
704
  sage: # needs nauty
@@ -764,9 +792,9 @@ class DiGraphGenerators:
764
792
  # digraph6 specifications:
765
793
  # http://users.cecs.anu.edu.au/~bdm/data/formats.txt
766
794
  if line and line[0] == '&':
767
- yield DiGraph(line[1:], format='dig6')
795
+ yield DiGraph(line[1:], format='dig6', immutable=immutable)
768
796
 
769
- def nauty_posetg(self, options='', debug=False):
797
+ def nauty_posetg(self, options='', debug=False, immutable=False):
770
798
  r"""
771
799
  Return a generator which creates all posets using ``nauty``.
772
800
 
@@ -787,6 +815,9 @@ class DiGraphGenerators:
787
815
  the program with some information on the arguments, while a line
788
816
  beginning with ">E" indicates an error with the input.
789
817
 
818
+ - ``immutable`` -- boolean (default: ``False``); whether to return
819
+ immutable or mutable posets.
820
+
790
821
  The possible options, obtained as output of ``genposetg --help``::
791
822
 
792
823
  n: the number of vertices, between 0 and 16
@@ -820,10 +851,9 @@ class DiGraphGenerators:
820
851
  except StopIteration:
821
852
  # Exhausted list of graphs from nauty genposetg
822
853
  return
823
- G = DiGraph(s[1:-1], format='dig6')
824
- yield G
854
+ yield DiGraph(s[1:-1], format='dig6', immutable=immutable)
825
855
 
826
- def Complete(self, n, loops=False):
856
+ def Complete(self, n, loops=False, immutable=False):
827
857
  r"""
828
858
  Return the complete digraph on `n` vertices.
829
859
 
@@ -834,6 +864,9 @@ class DiGraphGenerators:
834
864
  - ``loops`` -- boolean (default: ``False``); whether to add loops or
835
865
  not, i.e., edges from `u` to itself
836
866
 
867
+ - ``immutable`` -- boolean (default: ``False``); whether to return
868
+ an immutable or mutable digraph.
869
+
837
870
  .. SEEALSO::
838
871
 
839
872
  - :meth:`~sage.graphs.digraph_generators.DiGraphGenerators.RandomSemiComplete`
@@ -856,24 +889,32 @@ class DiGraphGenerators:
856
889
  ...
857
890
  ValueError: the number of vertices cannot be strictly negative
858
891
  """
859
- G = DiGraph(n, name="Complete digraph" + (" with loops" if loops else ''), loops=loops)
860
-
861
- if loops:
862
- G.add_edges((u, u) for u in range(n))
892
+ if n < 0:
893
+ raise ValueError('the number of vertices cannot be strictly negative')
863
894
 
864
- G.add_edges((u, v) for u in range(n) for v in range(n) if u != v)
895
+ edges = ((u, v) for u in range(n) for v in range(n) if u != v or loops)
896
+ G = DiGraph([range(n), edges], format='vertices_and_edges',
897
+ loops=loops, immutable=immutable,
898
+ name="Complete digraph" + (" with loops" if loops else ''))
865
899
 
866
900
  G._circle_embedding(list(range(n)))
867
901
 
868
902
  return G
869
903
 
870
- def Circuit(self, n):
904
+ def Circuit(self, n, immutable=False):
871
905
  r"""
872
906
  Return the circuit on `n` vertices.
873
907
 
874
908
  The circuit is an oriented
875
909
  :meth:`~sage.graphs.graph_generators.GraphGenerators.CycleGraph`.
876
910
 
911
+ INPUT:
912
+
913
+ - ``n`` -- integer; number of vertices
914
+
915
+ - ``immutable`` -- boolean (default: ``False``); whether to return
916
+ an immutable or mutable digraph.
917
+
877
918
  EXAMPLES:
878
919
 
879
920
  A circuit is the smallest strongly connected digraph::
@@ -882,19 +923,20 @@ class DiGraphGenerators:
882
923
  sage: len(circuit.strongly_connected_components()) == 1
883
924
  True
884
925
  """
885
- g = DiGraph(n, name='Circuit')
886
-
926
+ if n < 0:
927
+ raise ValueError('the number of vertices cannot be strictly negative')
887
928
  if n == 1:
888
- g.allow_loops(True)
889
- g.add_edge(0, 0)
890
- return g
891
- elif n:
892
- g.add_edges(zip(range(n - 1), range(1, n)))
893
- g.add_edge(n - 1, 0)
894
- g._circle_embedding(list(range(n)))
929
+ return DiGraph([(0, 0)], format='list_of_edges', loops=True,
930
+ immutable=immutable, name='Circuit')
931
+
932
+ from itertools import chain
933
+ edges = zip(range(n), chain(range(1, n), [0]))
934
+ g = DiGraph([range(n), edges], format='vertices_and_edges',
935
+ immutable=immutable, name='Circuit')
936
+ g._circle_embedding(list(range(n)))
895
937
  return g
896
938
 
897
- def Circulant(self, n, integers):
939
+ def Circulant(self, n, integers, immutable=False):
898
940
  r"""
899
941
  Return a circulant digraph on `n` vertices from a set of integers.
900
942
 
@@ -909,6 +951,9 @@ class DiGraphGenerators:
909
951
  that there is an edge from `i` to `j` if and only if `(j-i) \pmod{n}`
910
952
  is an integer
911
953
 
954
+ - ``immutable`` -- boolean (default: ``False``); whether to return
955
+ an immutable or mutable digraph.
956
+
912
957
  EXAMPLES:
913
958
 
914
959
  Construct and show the circulant graph [3, 5, 7], a digraph on 13
@@ -947,12 +992,11 @@ class DiGraphGenerators:
947
992
  if not i % n:
948
993
  loops = True
949
994
 
950
- G = DiGraph(n, name="Circulant graph (" + str(integers) + ")", loops=loops)
951
-
995
+ edges = ((v, (v + j) % n) for j in integers for v in range(n))
996
+ G = DiGraph([range(n), edges], format='vertices_and_edges',
997
+ loops=loops, immutable=immutable,
998
+ name="Circulant graph (" + str(integers) + ")")
952
999
  G._circle_embedding(list(range(n)))
953
- for v in range(n):
954
- G.add_edges((v, (v + j) % n) for j in integers)
955
-
956
1000
  return G
957
1001
 
958
1002
  def DeBruijn(self, k, n, vertices='strings'):