Skip to content
Merged
6 changes: 3 additions & 3 deletions src/sage/graphs/base/boost_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -572,7 +572,7 @@ cpdef bandwidth_heuristics(g, algorithm='cuthill_mckee'):
from sage.graphs.base.boost_graph import bandwidth_heuristics
sage: bandwidth_heuristics(Graph())
(0, [])
sage: bandwidth_heuristics(graphs.RandomGNM(10,0)) # optional - networkx
sage: bandwidth_heuristics(graphs.RandomGNM(10,0)) # needs networkx
(0, [0, 1, 2, 3, 4, 5, 6, 7, 8, 9])

"""
Expand Down Expand Up @@ -1964,8 +1964,8 @@ cpdef diameter_DHV(g, weight_function=None, check_weight=True):

TESTS::

sage: G = graphs.RandomBarabasiAlbert(17,6) # optional - networkx
sage: diameter_DHV(G) == G.diameter(algorithm = 'Dijkstra_Boost') # optional - networkx
sage: G = graphs.RandomBarabasiAlbert(17,6) # needs networkx
sage: diameter_DHV(G) == G.diameter(algorithm = 'Dijkstra_Boost') # needs networkx
True
sage: G = Graph([(0,1,-1)], weighted=True)
sage: diameter_DHV(G)
Expand Down
31 changes: 16 additions & 15 deletions src/sage/graphs/base/c_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1576,12 +1576,13 @@ cdef class CGraphBackend(GenericGraphBackend):

We check that the bug described in :trac:`8406` is gone::

sage: # needs sage.rings.finite_rings
sage: G = Graph()
sage: R.<a> = GF(3**3) # optional - sage.rings.finite_rings
sage: S.<x> = R[] # optional - sage.rings.finite_rings
sage: G.add_vertex(a**2) # optional - sage.rings.finite_rings
sage: G.add_vertex(x) # optional - sage.rings.finite_rings
sage: G.vertices(sort=True) # optional - sage.rings.finite_rings
sage: R.<a> = GF(3**3)
sage: S.<x> = R[]
sage: G.add_vertex(a**2)
sage: G.add_vertex(x)
sage: G.vertices(sort=True)
[a^2, x]

And that the bug described in :trac:`9610` is gone::
Expand Down Expand Up @@ -2107,9 +2108,9 @@ cdef class CGraphBackend(GenericGraphBackend):

Ensure that :trac:`13664` is fixed ::

sage: W = WeylGroup(["A",1]) # optional - sage.combinat sage.groups
sage: G = W.cayley_graph() # optional - sage.combinat sage.groups
sage: Graph(G).degree() # optional - sage.combinat sage.groups
sage: W = WeylGroup(["A",1]) # needs sage.combinat sage.groups
sage: G = W.cayley_graph() # needs sage.combinat sage.groups
sage: Graph(G).degree() # needs sage.combinat sage.groups
[1, 1]
sage: h = Graph()
sage: h.add_edge(1,2,"a")
Expand Down Expand Up @@ -4406,9 +4407,9 @@ cdef class CGraphBackend(GenericGraphBackend):

TESTS::

sage: P = posets.PentagonPoset() # optional - sage.modules
sage: H = P._hasse_diagram # optional - sage.modules
sage: H._backend.is_connected() # optional - sage.modules
sage: P = posets.PentagonPoset() # needs sage.modules
sage: H = P._hasse_diagram # needs sage.modules
sage: H._backend.is_connected() # needs sage.modules
True
"""
cdef int v_int
Expand Down Expand Up @@ -4548,7 +4549,7 @@ cdef class CGraphBackend(GenericGraphBackend):
At first, the following graph is acyclic::

sage: D = DiGraph({ 0:[1,2,3], 4:[2,5], 1:[8], 2:[7], 3:[7], 5:[6,7], 7:[8], 6:[9], 8:[10], 9:[10] })
sage: D.plot(layout='circular').show() # optional - sage.plot
sage: D.plot(layout='circular').show() # needs sage.plot
sage: D.is_directed_acyclic()
True

Expand Down Expand Up @@ -4589,9 +4590,9 @@ cdef class CGraphBackend(GenericGraphBackend):

TESTS::

sage: m = Matrix(3,[0, 1, 1, 0, 0, 0, 0, 1, 0]) # optional - sage.modules
sage: g = DiGraph(m) # optional - sage.modules
sage: g.is_directed_acyclic(certificate=True) # optional - sage.modules
sage: m = Matrix(3,[0, 1, 1, 0, 0, 0, 0, 1, 0]) # needs sage.modules
sage: g = DiGraph(m) # needs sage.modules
sage: g.is_directed_acyclic(certificate=True) # needs sage.modules
(True, [0, 2, 1])
"""
if not self._directed:
Expand Down
17 changes: 9 additions & 8 deletions src/sage/graphs/base/static_sparse_backend.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -446,17 +446,18 @@ cdef class StaticSparseBackend(CGraphBackend):

::

sage: g = DiGraph(digraphs.DeBruijn(4, 3), data_structure="static_sparse") # optional - sage.combinat
sage: gi = DiGraph(g, data_structure="static_sparse") # optional - sage.combinat
sage: gi.edges(sort=True)[0] # optional - sage.combinat
sage: # needs sage.combinat
sage: g = DiGraph(digraphs.DeBruijn(4, 3), data_structure="static_sparse")
sage: gi = DiGraph(g, data_structure="static_sparse")
sage: gi.edges(sort=True)[0]
('000', '000', '0')
sage: sorted(gi.edges_incident('111')) # optional - sage.combinat
sage: sorted(gi.edges_incident('111'))
[('111', '110', '0'),
('111', '111', '1'),
('111', '112', '2'),
('111', '113', '3')]

sage: set(g.edges(sort=False)) == set(gi.edges(sort=False)) # optional - sage.combinat
sage: set(g.edges(sort=False)) == set(gi.edges(sort=False)) # needs sage.combinat
True

::
Expand Down Expand Up @@ -671,10 +672,10 @@ cdef class StaticSparseBackend(CGraphBackend):
::

sage: from sage.graphs.base.static_sparse_backend import StaticSparseBackend
sage: g = StaticSparseBackend(digraphs.DeBruijn(3, 2)) # optional - sage.combinat
sage: g.has_edge('00', '01', '1') # optional - sage.combinat
sage: g = StaticSparseBackend(digraphs.DeBruijn(3, 2)) # needs sage.combinat
sage: g.has_edge('00', '01', '1') # needs sage.combinat
True
sage: g.has_edge('00', '01', '0') # optional - sage.combinat
sage: g.has_edge('00', '01', '0') # needs sage.combinat
False
"""
try:
Expand Down
18 changes: 9 additions & 9 deletions src/sage/graphs/base/static_sparse_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -731,8 +731,8 @@ def tarjan_strongly_connected_components(G):

Checking against NetworkX::

sage: import networkx # optional - networkx
sage: for i in range(10): # long time # optional - networkx
sage: import networkx # needs networkx
sage: for i in range(10): # long time # needs networkx
....: g = digraphs.RandomDirectedGNP(100,.05)
....: h = g.networkx_graph()
....: scc1 = g.strongly_connected_components()
Expand Down Expand Up @@ -1023,8 +1023,8 @@ def spectral_radius(G, prec=1e-10):

sage: G = Graph([(0,1),(0,2),(1,2),(1,3),(2,4),(3,4)])
sage: e_min, e_max = spectral_radius(G, 1e-14)
sage: e = max(G.adjacency_matrix().charpoly().roots(AA, multiplicities=False))
sage: e_min < e < e_max
sage: e = max(G.adjacency_matrix().charpoly().roots(AA, multiplicities=False)) # needs sage.modules
sage: e_min < e < e_max # needs sage.modules
True

sage: G.spectral_radius() # abs tol 1e-9
Expand All @@ -1037,10 +1037,10 @@ def spectral_radius(G, prec=1e-10):
sage: G.add_edge(200,0)
sage: G.add_edge(1,0)
sage: e_min, e_max = spectral_radius(G, 0.00001)
sage: p = G.adjacency_matrix(sparse=True).charpoly()
sage: p
sage: p = G.adjacency_matrix(sparse=True).charpoly() # needs sage.modules
sage: p # needs sage.modules
x^201 - x^199 - 1
sage: r = p.roots(AA, multiplicities=False)[0]
sage: r = p.roots(AA, multiplicities=False)[0] # needs sage.modules
sage: e_min < r < e_max
True

Expand All @@ -1060,7 +1060,7 @@ def spectral_radius(G, prec=1e-10):
sage: G.add_edges([(0,0),(0,0),(0,1),(1,0)])
sage: spectral_radius(G, 1e-14) # abs tol 1e-14
(2.414213562373094, 2.414213562373095)
sage: max(G.adjacency_matrix().eigenvalues(AA))
sage: max(G.adjacency_matrix().eigenvalues(AA)) # needs sage.modules
2.414213562373095?

Some bipartite graphs::
Expand Down Expand Up @@ -1091,7 +1091,7 @@ def spectral_radius(G, prec=1e-10):
...
ValueError: precision (=1.00000000000000e-20) is too small

sage: for _ in range(100):
sage: for _ in range(100): # needs sage.modules
....: G = digraphs.RandomDirectedGNM(10,35)
....: if not G.is_strongly_connected():
....: continue
Expand Down
Loading