Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
mkoeppe committed Jan 19, 2022
2 parents 61d043e + 1dbef4d commit 6f8efcb
Show file tree
Hide file tree
Showing 22 changed files with 67 additions and 55 deletions.
2 changes: 1 addition & 1 deletion src/sage/categories/crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -889,7 +889,7 @@ def digraph(self, subset=None, index_set=None):
.. TODO:: Add more tests.
"""
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
d = {}

# Parse optional arguments
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/examples/crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from sage.structure.element_wrapper import ElementWrapper
from sage.structure.unique_representation import UniqueRepresentation
from sage.categories.classical_crystals import ClassicalCrystals
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
from sage.categories.enumerated_sets import EnumeratedSets
from sage.combinat.root_system.cartan_type import CartanType

Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/finite_coxeter_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -890,7 +890,7 @@ def coxeter_knuth_graph(self):
...
NotImplementedError: This has only been implemented in finite type A so far!
"""
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
R = [tuple(v) for v in self.reduced_words()]
G = Graph()
G.add_vertices(R)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/finite_groups.py
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ def cayley_graph_disabled(self, connecting_set=None):
if g not in self:
raise RuntimeError("Each element of the connecting set must be in the group!")
connecting_set = [self(g) for g in connecting_set]
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
arrows = {}
for x in self:
arrows[x] = {}
Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/highest_weight_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ def digraph(self, subset=None, index_set=None, depth=None):
raise NotImplementedError("crystals not known to be finite must"
" specify either the subset or depth")

from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
if index_set is None:
index_set = self.index_set()

Expand Down
2 changes: 1 addition & 1 deletion src/sage/categories/regular_crystals.py
Original file line number Diff line number Diff line change
Expand Up @@ -446,7 +446,7 @@ def wt_zero(x):
y = x.e(i).e(im).f(i).f(im)
if checker(y):
edges.append([x, y, i])
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
G = DiGraph([X, edges], format="vertices_and_edges", immutable=True)
from sage.graphs.dot2tex_utils import have_dot2tex
if have_dot2tex():
Expand Down
2 changes: 1 addition & 1 deletion src/sage/geometry/hyperplane_arrangement/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
# http://www.gnu.org/licenses/
#*****************************************************************************

from sage.graphs.all import graphs
from sage.graphs.graph_generators import graphs
from sage.matrix.constructor import matrix, random_matrix
from sage.rings.integer_ring import ZZ
from sage.rings.rational_field import QQ
Expand Down
5 changes: 3 additions & 2 deletions src/sage/graphs/base/static_sparse_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,8 @@ cdef int init_short_digraph(short_digraph g, G, edge_labelled=False, vertex_list

cdef int isdigraph

from sage.graphs.all import Graph, DiGraph
from sage.graphs.graph import Graph
from sage.graphs.digraph import DiGraph

if isinstance(G, DiGraph):
isdigraph = 1
Expand Down Expand Up @@ -1116,7 +1117,7 @@ def spectral_radius(G, prec=1e-10):
# and the iteration is likely to reach a cycle of length 2 and hence the
# algorithm never terminate. Here we compute the "square" reduced to
# one component of the bipartition.
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
H = DiGraph(loops=True, multiedges=True)
if G.is_directed():
neighbors_iterator = G.neighbor_out_iterator
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/digraph.py
Original file line number Diff line number Diff line change
Expand Up @@ -670,7 +670,7 @@ def __init__(self, data=None, pos=None, loops=None, format=None,
msg += "Non-symmetric or non-square matrix assumed to be an incidence matrix: "
if format is None and isinstance(data, DiGraph):
format = 'DiGraph'
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
if format is None and isinstance(data, Graph):
data = data.to_directed()
format = 'DiGraph'
Expand Down Expand Up @@ -1062,7 +1062,7 @@ def to_undirected(self, data_structure=None, sparse=None):
data_structure = "sparse"
else:
data_structure = "static_sparse"
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
G = Graph(name = self.name(),
pos = self._pos,
multiedges = self.allows_multiple_edges(),
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/generators/families.py
Original file line number Diff line number Diff line change
Expand Up @@ -2950,7 +2950,7 @@ def line_graph_forbidden_subgraphs():
Graph on 5 vertices]
"""
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
from sage.graphs.generators.basic import ClawGraph
graphs = [ClawGraph()]

Expand Down
52 changes: 28 additions & 24 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -614,7 +614,7 @@ def __eq__(self, other):
# inputs must be (di)graphs:
if not isinstance(other, GenericGraph):
return False
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
g1_is_graph = isinstance(self, Graph) # otherwise, DiGraph
g2_is_graph = isinstance(other, Graph) # otherwise, DiGraph
# Fast checks
Expand Down Expand Up @@ -6227,7 +6227,7 @@ def steiner_tree(self, vertices, weighted=False, solver=None, verbose=0,
self._scream_if_not_simple(allow_loops=True)

if self.is_directed():
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
g = Graph(self)
else:
g = self
Expand Down Expand Up @@ -8119,7 +8119,7 @@ def traveling_salesman_problem(self, use_edge_labels=False, maximize=False,
#################
if g.is_directed():

from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
b = p.new_variable(binary=True)

# Objective function
Expand Down Expand Up @@ -8169,7 +8169,7 @@ def traveling_salesman_problem(self, use_edge_labels=False, maximize=False,
###################
else:

from sage.graphs.all import Graph
from sage.graphs.graph import Graph
b = p.new_variable(binary=True)

# Objective function
Expand Down Expand Up @@ -8254,7 +8254,7 @@ def traveling_salesman_problem(self, use_edge_labels=False, maximize=False,
p.set_objective(p.sum(weight(l) * f[u,v] for u,v,l in g.edge_iterator()))

# defining the answer when g is directed
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
tsp = DiGraph()

else:
Expand All @@ -8270,7 +8270,7 @@ def traveling_salesman_problem(self, use_edge_labels=False, maximize=False,
if use_edge_labels:
p.set_objective(p.sum(weight(l) * f[frozenset((u,v))] for u,v,l in g.edge_iterator()))

from sage.graphs.all import Graph
from sage.graphs.graph import Graph

# defining the answer when g is not directed
tsp = Graph()
Expand Down Expand Up @@ -14913,7 +14913,7 @@ def distance_graph(self, dist):
looped = True
else:
looped = False
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
D = Graph(vertices, pos=positions, multiedges=False, loops=looped)
if len(distances) == 1:
dstring = "distance " + str(distances[0])
Expand Down Expand Up @@ -18146,10 +18146,10 @@ def union(self, other, immutable=None):
weighted = self.weighted() and other.weighted()

if self._directed:
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
G = DiGraph(multiedges=multiedges, loops=loops, weighted=weighted)
else:
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
G = Graph(multiedges=multiedges, loops=loops, weighted=weighted)
G.add_vertices(self)
G.add_vertices(other)
Expand Down Expand Up @@ -18216,10 +18216,10 @@ def cartesian_product(self, other):
"""
self._scream_if_not_simple(allow_loops=True)
if self._directed and other._directed:
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
G = DiGraph(loops=(self.has_loops() or other.has_loops()))
elif (not self._directed) and (not other._directed):
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
G = Graph(loops=(self.has_loops() or other.has_loops()))
else:
raise TypeError('the graphs should be both directed or both undirected')
Expand Down Expand Up @@ -18300,10 +18300,10 @@ def tensor_product(self, other):
"""
self._scream_if_not_simple(allow_loops=True)
if self._directed and other._directed:
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
G = DiGraph(loops=(self.has_loops() or other.has_loops()))
elif (not self._directed) and (not other._directed):
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
G = Graph(loops=(self.has_loops() or other.has_loops()))
else:
raise TypeError('the graphs should be both directed or both undirected')
Expand Down Expand Up @@ -18370,10 +18370,10 @@ def lexicographic_product(self, other):
"""
self._scream_if_not_simple(allow_loops=True)
if self._directed and other._directed:
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
G = DiGraph(loops=(self.has_loops() or other.has_loops()))
elif (not self._directed) and (not other._directed):
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
G = Graph(loops=(self.has_loops() or other.has_loops()))
else:
raise TypeError('the graphs should be both directed or both undirected')
Expand Down Expand Up @@ -18451,10 +18451,10 @@ def strong_product(self, other):
"""
self._scream_if_not_simple(allow_loops=True)
if self._directed and other._directed:
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
G = DiGraph(loops=(self.has_loops() or other.has_loops()))
elif (not self._directed) and (not other._directed):
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
G = Graph(loops=(self.has_loops() or other.has_loops()))
else:
raise TypeError('the graphs should be both directed or both undirected')
Expand Down Expand Up @@ -18522,10 +18522,10 @@ def disjunctive_product(self, other):
"""
self._scream_if_not_simple(allow_loops=True)
if self._directed and other._directed:
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
G = DiGraph(loops=(self.has_loops() or other.has_loops()))
elif (not self._directed) and (not other._directed):
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
G = Graph(loops=(self.has_loops() or other.has_loops()))
else:
raise TypeError('the graphs should be both directed or both undirected')
Expand Down Expand Up @@ -19355,7 +19355,7 @@ def layout_tree(self, tree_orientation="down", tree_root=None,
if not self:
return dict()

from sage.graphs.all import Graph
from sage.graphs.graph import Graph
if not Graph(self).is_tree():
raise RuntimeError("cannot use tree layout on this graph: "
"self.is_tree() returns False")
Expand Down Expand Up @@ -22347,7 +22347,8 @@ def automorphism_group(self, partition=None, verbosity=0,

from sage.groups.perm_gps.partn_ref.refinement_graphs import search_tree
from sage.groups.perm_gps.permgroup import PermutationGroup
from sage.graphs.all import Graph, DiGraph
from sage.graphs.graph import Graph
from sage.graphs.digraph import DiGraph
from itertools import chain
dig = (self._directed or self.has_loops())

Expand Down Expand Up @@ -22848,7 +22849,8 @@ def is_isomorphic(self, other, certificate=False, verbosity=0, edge_labels=False
G2 = other
partition2 = other_vertices
G_to = {u: i for i,u in enumerate(self_vertices)}
from sage.graphs.all import Graph, DiGraph
from sage.graphs.graph import Graph
from sage.graphs.digraph import DiGraph
DoDG = DiGraph if self._directed else Graph
H = DoDG(len(self_vertices), loops=G.allows_loops())
HB = H._backend
Expand Down Expand Up @@ -23098,7 +23100,8 @@ class by some canonization function `c`. If `G` and `H` are graphs,

# algorithm == 'sage':
from sage.groups.perm_gps.partn_ref.refinement_graphs import search_tree
from sage.graphs.all import Graph, DiGraph
from sage.graphs.graph import Graph
from sage.graphs.digraph import DiGraph
from itertools import chain

dig = (self.has_loops() or self._directed)
Expand Down Expand Up @@ -24096,7 +24099,8 @@ def graph_isom_equivalent_non_edge_labeled_graph(g, partition=None, standard_lab
sage: g[0].is_bipartite()
False
"""
from sage.graphs.all import Graph, DiGraph
from sage.graphs.graph import Graph
from sage.graphs.digraph import DiGraph
from itertools import chain

g_has_multiple_edges = g.has_multiple_edges()
Expand Down
6 changes: 3 additions & 3 deletions src/sage/graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1067,7 +1067,7 @@ def __init__(self, data=None, pos=None, loops=None, format=None,
format = 'incidence_matrix'
if format is None and isinstance(data, Graph):
format = 'Graph'
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
if format is None and isinstance(data, DiGraph):
data = data.to_undirected()
format = 'Graph'
Expand Down Expand Up @@ -3312,7 +3312,7 @@ def bounded_outdegree_orientation(self, bound, solver=None, verbose=False,
"""
self._scream_if_not_simple()
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
n = self.order()

if not n:
Expand Down Expand Up @@ -5541,7 +5541,7 @@ def to_directed(self, data_structure=None, sparse=None):
data_structure = "sparse"
else:
data_structure = "static_sparse"
from sage.graphs.all import DiGraph
from sage.graphs.digraph import DiGraph
D = DiGraph(name = self.name(),
pos = self.get_pos(),
multiedges = self.allows_multiple_edges(),
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/graph_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -775,7 +775,7 @@ def __call__(self, vertices=None, property=None, augment='edges',
def property(x):
return True

from sage.graphs.all import Graph
from sage.graphs.graph import Graph
from copy import copy as copyfun

if degree_sequence is not None:
Expand Down Expand Up @@ -1070,7 +1070,7 @@ def cospectral_graphs(self, vertices, matrix_function=lambda g: g.adjacency_matr
sage: g[0][1].laplacian_matrix(normalized=True).charpoly()==g[0][1].laplacian_matrix(normalized=True).charpoly() # optional - sage.symbolic
True
"""
from sage.graphs.all import graphs as graph_gen
from sage.graphs.graph_generators import graphs as graph_gen
if graphs is None:
graph_list=graph_gen(vertices, property=lambda _: True)
elif callable(graphs):
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/line_graph.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -366,7 +366,7 @@ def line_graph(g, labels=True):
for f in g.outgoing_edge_iterator(v, labels=labels))
return G
else:
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
G = Graph()

# We must sort the edges' endpoints so that (1,2,None) is seen as the
Expand Down
12 changes: 7 additions & 5 deletions src/sage/groups/perm_gps/partn_ref/refinement_graphs.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def isomorphic(G1, G2, partn, ordering2, dig, use_indicator_function, sparse=Fal
cdef list partition, cell
cdef bint loops = 0

from sage.graphs.all import Graph, DiGraph
from sage.graphs.graph import Graph
from sage.graphs.digraph import DiGraph
from sage.graphs.generic_graph import GenericGraph
from copy import copy
which_G = 1
Expand Down Expand Up @@ -379,7 +380,8 @@ def search_tree(G_in, partition, lab=True, dig=False, dict_rep=False, certificat
cdef bint loops
cdef aut_gp_and_can_lab *output
cdef PartitionStack *part
from sage.graphs.all import Graph, DiGraph
from sage.graphs.graph import Graph
from sage.graphs.digraph import DiGraph
from sage.graphs.generic_graph import GenericGraph
from copy import copy
if isinstance(G_in, GenericGraph):
Expand Down Expand Up @@ -775,7 +777,7 @@ def all_labeled_graphs(n):
5 34

"""
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
TE = []
for i in range(n):
for j in range(i):
Expand Down Expand Up @@ -1291,7 +1293,7 @@ def generate_dense_graphs_edge_addition(int n, bint loops, G = None, depth = Non
12346

"""
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
cdef iterator *graph_iterator
cdef DenseGraph DG, ODG
cdef GraphStruct GS
Expand Down Expand Up @@ -1561,7 +1563,7 @@ def generate_dense_graphs_vert_addition(int n, base_G = None, bint construct = F
11

"""
from sage.graphs.all import Graph
from sage.graphs.graph import Graph
cdef iterator *graph_iterator
cdef DenseGraph DG, ODG
cdef GraphStruct GS
Expand Down
Loading

0 comments on commit 6f8efcb

Please sign in to comment.