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
@@ -123,7 +123,6 @@ Functions
123
123
  # https://www.gnu.org/licenses/
124
124
  # ****************************************************************************
125
125
 
126
- from sage.data_structures.binary_matrix cimport *
127
126
  from libc.string cimport memset
128
127
  from libc.stdint cimport uint64_t, UINT64_MAX
129
128
  from libc.stdint cimport uint32_t, INT32_MAX, UINT32_MAX
@@ -131,9 +130,11 @@ from cysignals.memory cimport sig_malloc, sig_calloc, sig_free
131
130
  from cysignals.signals cimport sig_on, sig_off
132
131
  from memory_allocator cimport MemoryAllocator
133
132
 
133
+ from sage.data_structures.binary_matrix cimport *
134
134
  from sage.graphs.base.c_graph cimport CGraphBackend
135
135
  from sage.graphs.base.c_graph cimport CGraph
136
-
136
+ from sage.graphs.base.static_sparse_backend cimport StaticSparseCGraph
137
+ from sage.graphs.base.static_sparse_backend cimport StaticSparseBackend
137
138
  from sage.graphs.base.static_sparse_graph cimport (short_digraph,
138
139
  init_short_digraph,
139
140
  init_reverse,
@@ -447,15 +448,15 @@ def distances_all_pairs(G):
447
448
  sage: g = graphs.PetersenGraph()
448
449
  sage: distances_all_pairs(g)
449
450
  {0: {0: 0, 1: 1, 2: 2, 3: 2, 4: 1, 5: 1, 6: 2, 7: 2, 8: 2, 9: 2},
450
- 1: {0: 1, 1: 0, 2: 1, 3: 2, 4: 2, 5: 2, 6: 1, 7: 2, 8: 2, 9: 2},
451
- 2: {0: 2, 1: 1, 2: 0, 3: 1, 4: 2, 5: 2, 6: 2, 7: 1, 8: 2, 9: 2},
452
- 3: {0: 2, 1: 2, 2: 1, 3: 0, 4: 1, 5: 2, 6: 2, 7: 2, 8: 1, 9: 2},
453
- 4: {0: 1, 1: 2, 2: 2, 3: 1, 4: 0, 5: 2, 6: 2, 7: 2, 8: 2, 9: 1},
454
- 5: {0: 1, 1: 2, 2: 2, 3: 2, 4: 2, 5: 0, 6: 2, 7: 1, 8: 1, 9: 2},
455
- 6: {0: 2, 1: 1, 2: 2, 3: 2, 4: 2, 5: 2, 6: 0, 7: 2, 8: 1, 9: 1},
456
- 7: {0: 2, 1: 2, 2: 1, 3: 2, 4: 2, 5: 1, 6: 2, 7: 0, 8: 2, 9: 1},
457
- 8: {0: 2, 1: 2, 2: 2, 3: 1, 4: 2, 5: 1, 6: 1, 7: 2, 8: 0, 9: 2},
458
- 9: {0: 2, 1: 2, 2: 2, 3: 2, 4: 1, 5: 2, 6: 1, 7: 1, 8: 2, 9: 0}}
451
+ 1: {0: 1, 1: 0, 2: 1, 3: 2, 4: 2, 5: 2, 6: 1, 7: 2, 8: 2, 9: 2},
452
+ 2: {0: 2, 1: 1, 2: 0, 3: 1, 4: 2, 5: 2, 6: 2, 7: 1, 8: 2, 9: 2},
453
+ 3: {0: 2, 1: 2, 2: 1, 3: 0, 4: 1, 5: 2, 6: 2, 7: 2, 8: 1, 9: 2},
454
+ 4: {0: 1, 1: 2, 2: 2, 3: 1, 4: 0, 5: 2, 6: 2, 7: 2, 8: 2, 9: 1},
455
+ 5: {0: 1, 1: 2, 2: 2, 3: 2, 4: 2, 5: 0, 6: 2, 7: 1, 8: 1, 9: 2},
456
+ 6: {0: 2, 1: 1, 2: 2, 3: 2, 4: 2, 5: 2, 6: 0, 7: 2, 8: 1, 9: 1},
457
+ 7: {0: 2, 1: 2, 2: 1, 3: 2, 4: 2, 5: 1, 6: 2, 7: 0, 8: 2, 9: 1},
458
+ 8: {0: 2, 1: 2, 2: 2, 3: 1, 4: 2, 5: 1, 6: 1, 7: 2, 8: 0, 9: 2},
459
+ 9: {0: 2, 1: 2, 2: 2, 3: 2, 4: 1, 5: 2, 6: 1, 7: 1, 8: 2, 9: 0}}
459
460
  """
460
461
  from sage.rings.infinity import Infinity
461
462
 
@@ -1807,6 +1808,17 @@ def diameter(G, algorithm=None, source=None):
1807
1808
  sage: G = graphs.PathGraph(1)
1808
1809
  sage: diameter(G, algorithm='iFUB')
1809
1810
  0
1811
+
1812
+ Immutable graphs::
1813
+
1814
+ sage: G = graphs.RandomGNP(10, .5)
1815
+ sage: G._backend
1816
+ <sage.graphs.base.sparse_graph.SparseGraphBackend ...>
1817
+ sage: H = Graph(G, immutable=True)
1818
+ sage: H._backend
1819
+ <sage.graphs.base.static_sparse_backend.StaticSparseBackend ...>
1820
+ sage: diameter(G, algorithm='iFUB') == diameter(H, algorithm='iFUB')
1821
+ True
1810
1822
  """
1811
1823
  cdef uint32_t n = G.order()
1812
1824
  if n <= 1:
@@ -1833,9 +1845,16 @@ def diameter(G, algorithm=None, source=None):
1833
1845
  # Copying the whole graph to obtain the list of neighbors quicker than by
1834
1846
  # calling out_neighbors. This data structure is well documented in the
1835
1847
  # module sage.graphs.base.static_sparse_graph
1836
- cdef list int_to_vertex = list(G)
1848
+ cdef list int_to_vertex
1849
+ cdef StaticSparseCGraph cg
1837
1850
  cdef short_digraph sd
1838
- init_short_digraph(sd, G, edge_labelled=False, vertex_list=int_to_vertex)
1851
+ if isinstance(G, StaticSparseBackend):
1852
+ cg = <StaticSparseCGraph> G._cg
1853
+ sd = <short_digraph> cg.g
1854
+ int_to_vertex = cg._vertex_to_labels
1855
+ else:
1856
+ int_to_vertex = list(G)
1857
+ init_short_digraph(sd, G, edge_labelled=False, vertex_list=int_to_vertex)
1839
1858
  cdef short_digraph rev_sd # to store copy of sd with edges reversed
1840
1859
 
1841
1860
  # and we map the source to an int in [0,n-1]
@@ -1850,7 +1869,8 @@ def diameter(G, algorithm=None, source=None):
1850
1869
  bitset_init(seen, n)
1851
1870
  tab = <uint32_t*> sig_malloc(2* n * sizeof(uint32_t))
1852
1871
  if not tab:
1853
- free_short_digraph(sd)
1872
+ if not isinstance(G, StaticSparseBackend):
1873
+ free_short_digraph(sd)
1854
1874
  bitset_free(seen)
1855
1875
  raise MemoryError()
1856
1876
 
@@ -1876,7 +1896,8 @@ def diameter(G, algorithm=None, source=None):
1876
1896
  else: # algorithm == 'iFUB'
1877
1897
  LB = diameter_iFUB(sd, isource)
1878
1898
 
1879
- free_short_digraph(sd)
1899
+ if not isinstance(G, StaticSparseBackend):
1900
+ free_short_digraph(sd)
1880
1901
 
1881
1902
  if LB < 0 or LB > n:
1882
1903
  from sage.rings.infinity import Infinity
@@ -1927,6 +1948,17 @@ def radius_DHV(G):
1927
1948
  Traceback (most recent call last):
1928
1949
  ...
1929
1950
  TypeError: this method works for unweighted undirected graphs only
1951
+
1952
+ Immutable graphs::
1953
+
1954
+ sage: G = graphs.RandomGNP(10, .5)
1955
+ sage: G._backend
1956
+ <sage.graphs.base.sparse_graph.SparseGraphBackend ...>
1957
+ sage: H = Graph(G, immutable=True)
1958
+ sage: H._backend
1959
+ <sage.graphs.base.static_sparse_backend.StaticSparseBackend ...>
1960
+ sage: radius_DHV(G) == radius_DHV(H)
1961
+ True
1930
1962
  """
1931
1963
  if G.is_directed():
1932
1964
  raise TypeError("this method works for unweighted undirected graphs only")
@@ -1935,9 +1967,16 @@ def radius_DHV(G):
1935
1967
  if n <= 1:
1936
1968
  return 0
1937
1969
 
1938
- cdef list int_to_vertex = list(G)
1970
+ cdef list int_to_vertex
1971
+ cdef StaticSparseCGraph cg
1939
1972
  cdef short_digraph sd
1940
- init_short_digraph(sd, G, edge_labelled=False, vertex_list=int_to_vertex)
1973
+ if isinstance(G, StaticSparseBackend):
1974
+ cg = <StaticSparseCGraph> G._cg
1975
+ sd = <short_digraph> cg.g
1976
+ int_to_vertex = cg._vertex_to_labels
1977
+ else:
1978
+ int_to_vertex = list(G)
1979
+ init_short_digraph(sd, G, edge_labelled=False, vertex_list=int_to_vertex)
1941
1980
 
1942
1981
  cdef uint32_t source, ecc_source
1943
1982
  cdef uint32_t antipode, ecc_antipode
@@ -1947,6 +1986,8 @@ def radius_DHV(G):
1947
1986
  cdef MemoryAllocator mem = MemoryAllocator()
1948
1987
  cdef uint32_t * distances = <uint32_t *>mem.malloc(3 * n * sizeof(uint32_t))
1949
1988
  if not distances:
1989
+ if not isinstance(G, StaticSparseBackend):
1990
+ free_short_digraph(sd)
1950
1991
  raise MemoryError()
1951
1992
 
1952
1993
  cdef uint32_t * waiting_list = distances + n
@@ -1988,7 +2029,8 @@ def radius_DHV(G):
1988
2029
  LB = ecc_lower_bound[v]
1989
2030
  source = v # vertex with minimum eccentricity lower bound
1990
2031
 
1991
- free_short_digraph(sd)
2032
+ if not isinstance(G, StaticSparseBackend):
2033
+ free_short_digraph(sd)
1992
2034
  bitset_free(seen)
1993
2035
  if UB == UINT32_MAX:
1994
2036
  from sage.rings.infinity import Infinity
@@ -2042,6 +2084,19 @@ def wiener_index(G):
2042
2084
  Traceback (most recent call last):
2043
2085
  ...
2044
2086
  ValueError: Wiener index is not defined for the empty graph
2087
+
2088
+ TESTS:
2089
+
2090
+ Immutable graphs::
2091
+
2092
+ sage: G = graphs.RandomGNP(10, .5)
2093
+ sage: G._backend
2094
+ <sage.graphs.base.sparse_graph.SparseGraphBackend ...>
2095
+ sage: H = Graph(G, immutable=True)
2096
+ sage: H._backend
2097
+ <sage.graphs.base.static_sparse_backend.StaticSparseBackend ...>
2098
+ sage: G.wiener_index() == H.wiener_index()
2099
+ True
2045
2100
  """
2046
2101
  if not G:
2047
2102
  raise ValueError("Wiener index is not defined for the empty graph")
@@ -2053,8 +2108,13 @@ def wiener_index(G):
2053
2108
  # Copying the whole graph to obtain the list of neighbors quicker than by
2054
2109
  # calling out_neighbors. This data structure is well documented in the
2055
2110
  # module sage.graphs.base.static_sparse_graph
2111
+ cdef StaticSparseCGraph cg
2056
2112
  cdef short_digraph sd
2057
- init_short_digraph(sd, G, edge_labelled=False, vertex_list=list(G))
2113
+ if isinstance(G, StaticSparseBackend):
2114
+ cg = <StaticSparseCGraph> G._cg
2115
+ sd = <short_digraph> cg.g
2116
+ else:
2117
+ init_short_digraph(sd, G, edge_labelled=False, vertex_list=list(G))
2058
2118
 
2059
2119
  # allocated some data structures
2060
2120
  cdef bitset_t seen
@@ -2075,7 +2135,8 @@ def wiener_index(G):
2075
2135
  for v in range(0 if G.is_directed() else (u + 1), n):
2076
2136
  s += distances[v]
2077
2137
 
2078
- free_short_digraph(sd)
2138
+ if not isinstance(G, StaticSparseBackend):
2139
+ free_short_digraph(sd)
2079
2140
  bitset_free(seen)
2080
2141
 
2081
2142
  if s == UINT64_MAX:
@@ -2343,6 +2404,18 @@ def szeged_index(G, algorithm=None):
2343
2404
  Traceback (most recent call last):
2344
2405
  ...
2345
2406
  ValueError: the 'low' algorithm cannot be used on digraphs
2407
+
2408
+ Immutable graphs::
2409
+
2410
+ sage: G = graphs.RandomGNP(10, .3)
2411
+ sage: G.add_edges(graphs.RandomTree(10).edges())
2412
+ sage: G._backend
2413
+ <sage.graphs.base.sparse_graph.SparseGraphBackend ...>
2414
+ sage: H = Graph(G, immutable=True)
2415
+ sage: H._backend
2416
+ <sage.graphs.base.static_sparse_backend.StaticSparseBackend ...>
2417
+ sage: szeged_index(G) == szeged_index(H)
2418
+ True
2346
2419
  """
2347
2420
  if not G.is_connected():
2348
2421
  raise ValueError("the Szeged index is defined for connected graphs only")
@@ -2365,8 +2438,14 @@ def szeged_index(G, algorithm=None):
2365
2438
  if G.order() <= 1:
2366
2439
  return 0
2367
2440
 
2441
+ cdef StaticSparseCGraph cg
2368
2442
  cdef short_digraph sd
2369
- init_short_digraph(sd, G, edge_labelled=False, vertex_list=list(G))
2443
+ if isinstance(G, StaticSparseBackend):
2444
+ cg = <StaticSparseCGraph> G._cg
2445
+ sd = <short_digraph> cg.g
2446
+ else:
2447
+ init_short_digraph(sd, G, edge_labelled=False, vertex_list=list(G))
2448
+
2370
2449
  cdef uint64_t s
2371
2450
 
2372
2451
  if algorithm == "low":
@@ -2374,7 +2453,8 @@ def szeged_index(G, algorithm=None):
2374
2453
  else:
2375
2454
  s = c_szeged_index_high_memory(sd)
2376
2455
 
2377
- free_short_digraph(sd)
2456
+ if not isinstance(G, StaticSparseBackend):
2457
+ free_short_digraph(sd)
2378
2458
  return s
2379
2459
 
2380
2460
 
@@ -2442,13 +2522,31 @@ def distances_distribution(G):
2442
2522
  sage: D = digraphs.DeBruijn(2,3) # needs sage.combinat
2443
2523
  sage: D.distances_distribution() # needs sage.combinat
2444
2524
  {1: 1/4, 2: 11/28, 3: 5/14}
2525
+
2526
+ TESTS:
2527
+
2528
+ Immutable graphs::
2529
+
2530
+ sage: G = graphs.RandomGNP(10, .5)
2531
+ sage: G._backend
2532
+ <sage.graphs.base.sparse_graph.SparseGraphBackend ...>
2533
+ sage: H = Graph(G, immutable=True)
2534
+ sage: H._backend
2535
+ <sage.graphs.base.static_sparse_backend.StaticSparseBackend ...>
2536
+ sage: G.distances_distribution() == H.distances_distribution()
2537
+ True
2445
2538
  """
2446
2539
  cdef size_t n = G.order()
2447
2540
  if n <= 1:
2448
2541
  return {}
2449
2542
 
2543
+ cdef StaticSparseCGraph cg
2450
2544
  cdef short_digraph sd
2451
- init_short_digraph(sd, G, edge_labelled=False, vertex_list=list(G))
2545
+ if isinstance(G, StaticSparseBackend):
2546
+ cg = <StaticSparseCGraph> G._cg
2547
+ sd = <short_digraph> cg.g
2548
+ else:
2549
+ init_short_digraph(sd, G, edge_labelled=False, vertex_list=list(G))
2452
2550
 
2453
2551
  cdef MemoryAllocator mem = MemoryAllocator()
2454
2552
  cdef uint32_t * distances = <uint32_t *> mem.allocarray(2 * n, sizeof(uint32_t))
@@ -2471,7 +2569,8 @@ def distances_distribution(G):
2471
2569
  for v in range(n):
2472
2570
  count[distances[v]] += 1
2473
2571
 
2474
- free_short_digraph(sd)
2572
+ if not isinstance(G, StaticSparseBackend):
2573
+ free_short_digraph(sd)
2475
2574
  bitset_free(seen)
2476
2575
 
2477
2576
  from sage.rings.infinity import Infinity
@@ -2555,6 +2654,17 @@ def antipodal_graph(G):
2555
2654
  Antipodal graph of Graph on 1 vertex: Looped graph on 1 vertex
2556
2655
  sage: antipodal_graph(Graph(2)).edges(sort=True, labels=False)
2557
2656
  [(0, 1)]
2657
+
2658
+ Immutable graphs::
2659
+
2660
+ sage: G = graphs.RandomGNP(10, .5)
2661
+ sage: G._backend
2662
+ <sage.graphs.base.sparse_graph.SparseGraphBackend ...>
2663
+ sage: H = Graph(G, immutable=True)
2664
+ sage: H._backend
2665
+ <sage.graphs.base.static_sparse_backend.StaticSparseBackend ...>
2666
+ sage: antipodal_graph(G).is_isomorphic(antipodal_graph(H))
2667
+ True
2558
2668
  """
2559
2669
  if not G:
2560
2670
  raise ValueError("the antipodal graph of the empty graph is not defined")
@@ -2578,9 +2688,16 @@ def antipodal_graph(G):
2578
2688
  A.add_edges(itertools.product(c1, c2))
2579
2689
  return A
2580
2690
 
2581
- cdef list int_to_vertex = list(G)
2691
+ cdef list int_to_vertex
2692
+ cdef StaticSparseCGraph cg
2582
2693
  cdef short_digraph sd
2583
- init_short_digraph(sd, G, edge_labelled=False, vertex_list=int_to_vertex)
2694
+ if isinstance(G, StaticSparseBackend):
2695
+ cg = <StaticSparseCGraph> G._cg
2696
+ sd = <short_digraph> cg.g
2697
+ int_to_vertex = cg._vertex_to_labels
2698
+ else:
2699
+ int_to_vertex = list(G)
2700
+ init_short_digraph(sd, G, edge_labelled=False, vertex_list=int_to_vertex)
2584
2701
 
2585
2702
  cdef MemoryAllocator mem = MemoryAllocator()
2586
2703
  cdef uint32_t * distances = <uint32_t *> mem.allocarray(2 * n, sizeof(uint32_t))
@@ -2608,7 +2725,8 @@ def antipodal_graph(G):
2608
2725
  A.add_edge(u, int_to_vertex[vj])
2609
2726
  j -= 1
2610
2727
 
2611
- free_short_digraph(sd)
2728
+ if not isinstance(G, StaticSparseBackend):
2729
+ free_short_digraph(sd)
2612
2730
  bitset_free(seen)
2613
2731
 
2614
2732
  A.add_vertices(G)