Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

sage.graphs: More modularization #35718

Merged
merged 6 commits into from
Jun 11, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/sage/graphs/all.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
lazy_import("sage.graphs.graph_generators", "graphs")
lazy_import("sage.graphs.digraph_generators", "digraphs")
lazy_import("sage.graphs.hypergraph_generators", "hypergraphs")
from .graph_database import GraphDatabase, GenericGraphQuery, GraphQuery
lazy_import("sage.graphs.graph_database", ["GraphDatabase", "GenericGraphQuery", "GraphQuery"])
from .graph import Graph
from .digraph import DiGraph
from .bipartite_graph import BipartiteGraph
Expand All @@ -13,7 +13,7 @@
import sage.graphs.partial_cube
from . import graph_list as graphs_list
lazy_import("sage.graphs", "graph_coloring")
from .graph_database import graph_db_info
lazy_import("sage.graphs.graph_database", "graph_db_info")
lazy_import("sage.graphs.graph_editor", "graph_editor")

from sage.graphs.isgci import graph_classes
Expand Down
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))
sage: bandwidth_heuristics(graphs.RandomGNM(10,0)) # optional - 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)
sage: diameter_DHV(G) == G.diameter(algorithm = 'Dijkstra_Boost')
sage: G = graphs.RandomBarabasiAlbert(17,6) # optional - networkx
sage: diameter_DHV(G) == G.diameter(algorithm = 'Dijkstra_Boost') # optional - networkx
True
sage: G = Graph([(0,1,-1)], weighted=True)
sage: diameter_DHV(G)
Expand Down
28 changes: 14 additions & 14 deletions src/sage/graphs/base/c_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1577,11 +1577,11 @@ cdef class CGraphBackend(GenericGraphBackend):
We check that the bug described in :trac:`8406` is gone::

sage: G = Graph()
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)
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
[a^2, x]

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

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

sage: W = WeylGroup(["A",1])
sage: G = W.cayley_graph()
sage: Graph(G).degree()
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
[1, 1]
sage: h = Graph()
sage: h.add_edge(1,2,"a")
Expand Down Expand Up @@ -4406,9 +4406,9 @@ cdef class CGraphBackend(GenericGraphBackend):

TESTS::

sage: P = posets.PentagonPoset()
sage: H = P._hasse_diagram
sage: H._backend.is_connected()
sage: P = posets.PentagonPoset() # optional - sage.modules
sage: H = P._hasse_diagram # optional - sage.modules
sage: H._backend.is_connected() # optional - sage.modules
True
"""
cdef int v_int
Expand Down Expand Up @@ -4589,9 +4589,9 @@ cdef class CGraphBackend(GenericGraphBackend):

TESTS::

sage: m = Matrix(3,[0, 1, 1, 0, 0, 0, 0, 1, 0])
sage: g = DiGraph(m)
sage: g.is_directed_acyclic(certificate=True)
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
(True, [0, 2, 1])
"""
if not self._directed:
Expand Down
16 changes: 8 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,17 @@ cdef class StaticSparseBackend(CGraphBackend):

::

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]
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
('000', '000', '0')
sage: sorted(gi.edges_incident('111'))
sage: sorted(gi.edges_incident('111')) # optional - sage.combinat
[('111', '110', '0'),
('111', '111', '1'),
('111', '112', '2'),
('111', '113', '3')]

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

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

sage: from sage.graphs.base.static_sparse_backend import StaticSparseBackend
sage: g = StaticSparseBackend(digraphs.DeBruijn(3, 2))
sage: g.has_edge('00', '01', '1')
sage: g = StaticSparseBackend(digraphs.DeBruijn(3, 2)) # optional - sage.combinat
sage: g.has_edge('00', '01', '1') # optional - sage.combinat
True
sage: g.has_edge('00', '01', '0')
sage: g.has_edge('00', '01', '0') # optional - sage.combinat
False
"""
try:
Expand Down
Loading