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

avoid importing DiGraph from sage.graphs.graph #36736

Merged
merged 1 commit into from
Dec 10, 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/categories/coxeter_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -1088,7 +1088,7 @@ def bruhat_interval_poset(self, x, y, facade=False):
nextlayer.add(t)
curlayer = nextlayer

from sage.graphs.graph import DiGraph
from sage.graphs.digraph import DiGraph
return Poset(DiGraph(d, format='dict_of_lists',
data_structure='static_sparse'),
cover_relations=True,
Expand Down Expand Up @@ -1174,7 +1174,7 @@ def bruhat_graph(self, x=None, y=None, edge_labels=False):
else:
d.append((u, v))

from sage.graphs.graph import DiGraph
from sage.graphs.digraph import DiGraph
return DiGraph(d)

def canonical_representation(self):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/combinat/binary_tree.py
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ def graph(self, with_leaves=True):
sage: t1.graph(with_leaves=False).edges(sort=True)
[(0, 1, None), (0, 2, None), (2, 3, None), (2, 4, None)]
"""
from sage.graphs.graph import DiGraph
from sage.graphs.digraph import DiGraph

if with_leaves: # We want leaves and nodes.

Expand Down
3 changes: 2 additions & 1 deletion src/sage/geometry/lattice_polytope.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,6 @@
is_PointCollection,
read_palp_point_collection)
from sage.geometry.toric_lattice import ToricLattice, is_ToricLattice
from sage.graphs.graph import DiGraph, Graph
from sage.groups.perm_gps.permgroup_named import SymmetricGroup

from sage.misc.lazy_import import lazy_import
Expand Down Expand Up @@ -2039,6 +2038,7 @@ def LPFace(vertices, facets):
else:
# Get face lattice as a sublattice of the ambient one
allowed_indices = frozenset(self._ambient_vertex_indices)
from sage.graphs.digraph import DiGraph
L = DiGraph()
empty = self._ambient.face_lattice().bottom()
L.add_vertex(0) # In case it is the only one
Expand Down Expand Up @@ -3974,6 +3974,7 @@ def skeleton(self):
sage: g.edges(sort=True) # needs palp sage.graphs
[(0, 1, None), (0, 3, None), (1, 2, None), (2, 3, None)]
"""
from sage.graphs.graph import Graph
skeleton = Graph()
skeleton.add_vertices(self.skeleton_points(1))
for edge in self.edges():
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/bliss.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -581,7 +581,7 @@ cpdef canonical_form(G, partition=None, return_graph=False, use_edge_labels=True

if return_graph:
if directed:
from sage.graphs.graph import DiGraph
from sage.graphs.digraph import DiGraph
H = DiGraph(new_edges, loops=G.allows_loops(), multiedges=G.allows_multiple_edges())
else:
from sage.graphs.graph import Graph
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -421,7 +421,6 @@
from sage.rings.integer_ring import ZZ
import sage.graphs.generic_graph_pyx as generic_graph_pyx
from sage.graphs.generic_graph import GenericGraph
from sage.graphs.digraph import DiGraph
from sage.graphs.independent_sets import IndependentSets
from sage.misc.rest_index_of_methods import doc_index, gen_thematic_rest_table_index
from sage.graphs.views import EdgesView
Expand Down Expand Up @@ -3514,6 +3513,7 @@ def orientations(self, data_structure=None, sparse=None):
if name:
name = 'An orientation of ' + name

from sage.graphs.digraph import DiGraph
if not self.size():
D = DiGraph(data=[self.vertices(sort=False), []],
format='vertices_and_edges',
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/graph_generators_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -63,8 +63,6 @@ def RandomGNP(n, p, bint directed=False, bint loops=False, seed=None):
...
ValueError: parameter 'loops' can be set to True only when 'directed' is True
"""
from sage.graphs.graph import Graph, DiGraph

if seed is not None:
set_random_seed(seed)

Expand All @@ -74,8 +72,10 @@ def RandomGNP(n, p, bint directed=False, bint loops=False, seed=None):
cdef int pp = int(round(float(p * RAND_MAX_f)))

if directed:
from sage.graphs.digraph import DiGraph
G = DiGraph(loops=loops)
else:
from sage.graphs.graph import Graph
G = Graph()
if loops:
raise ValueError("parameter 'loops' can be set to True only when 'directed' is True")
Expand Down
10 changes: 7 additions & 3 deletions src/sage/schemes/elliptic_curves/ell_field.py
Original file line number Diff line number Diff line change
Expand Up @@ -1931,7 +1931,6 @@ class of curves. If the j-invariant is not unique in the isogeny
"""

from warnings import warn
from sage.graphs.graph import DiGraph, Graph
from sage.matrix.constructor import Matrix

# warn users if things are getting big
Expand Down Expand Up @@ -1983,8 +1982,13 @@ class of curves. If the j-invariant is not unique in the isogeny
labels.append(E._equation_string())

A = Matrix([r + [0] * (len(A) - len(r)) for r in A])
G = (DiGraph if directed else Graph)(A, format="adjacency_matrix",
data_structure="static_sparse")
if directed:
from sage.graphs.digraph import DiGraph as GraphType
else:
from sage.graphs.graph import Graph as GraphType

G = GraphType(A, format="adjacency_matrix",
data_structure="static_sparse")
# inplace relabelling is necessary for static_sparse graphs
GL = G.relabel(labels, inplace=False)
return GL
Expand Down
4 changes: 2 additions & 2 deletions src/sage/sets/disjoint_set.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -600,7 +600,7 @@ cdef class DisjointSet_of_integers(DisjointSet_class):
[(0, 0, None), (1, 1, None), (2, 1, None), (3, 1, None), (4, 1, None)]
"""
d = {i: [self._nodes.parent[i]] for i in range(self.cardinality())}
from sage.graphs.graph import DiGraph
from sage.graphs.digraph import DiGraph
return DiGraph(d)

cdef class DisjointSet_of_hashables(DisjointSet_class):
Expand Down Expand Up @@ -891,5 +891,5 @@ cdef class DisjointSet_of_hashables(DisjointSet_class):
e = self._int_to_el[i]
p = self._int_to_el[self._nodes.parent[i]]
d[e] = [p]
from sage.graphs.graph import DiGraph
from sage.graphs.digraph import DiGraph
return DiGraph(d)
2 changes: 1 addition & 1 deletion src/sage/sets/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -813,7 +813,7 @@ def subsets_lattice(self):
raise NotImplementedError(
"this method is only implemented for finite sets")
from sage.combinat.posets.lattices import FiniteLatticePoset
from sage.graphs.graph import DiGraph
from sage.graphs.digraph import DiGraph
from sage.rings.integer import Integer
n = self.cardinality()
# list, contains at position 0 <= i < 2^n
Expand Down