Skip to content

Commit 5560fa3

Browse files
committed
clean import of Graph and DiGraph
1 parent f10820f commit 5560fa3

File tree

9 files changed

+19
-14
lines changed

9 files changed

+19
-14
lines changed

src/sage/categories/coxeter_groups.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1088,7 +1088,7 @@ def bruhat_interval_poset(self, x, y, facade=False):
10881088
nextlayer.add(t)
10891089
curlayer = nextlayer
10901090

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

1177-
from sage.graphs.graph import DiGraph
1177+
from sage.graphs.digraph import DiGraph
11781178
return DiGraph(d)
11791179

11801180
def canonical_representation(self):

src/sage/combinat/binary_tree.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -748,7 +748,7 @@ def graph(self, with_leaves=True):
748748
sage: t1.graph(with_leaves=False).edges(sort=True)
749749
[(0, 1, None), (0, 2, None), (2, 3, None), (2, 4, None)]
750750
"""
751-
from sage.graphs.graph import DiGraph
751+
from sage.graphs.digraph import DiGraph
752752

753753
if with_leaves: # We want leaves and nodes.
754754

src/sage/geometry/lattice_polytope.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -112,7 +112,6 @@
112112
is_PointCollection,
113113
read_palp_point_collection)
114114
from sage.geometry.toric_lattice import ToricLattice, is_ToricLattice
115-
from sage.graphs.graph import DiGraph, Graph
116115
from sage.groups.perm_gps.permgroup_named import SymmetricGroup
117116

118117
from sage.misc.lazy_import import lazy_import
@@ -2039,6 +2038,7 @@ def LPFace(vertices, facets):
20392038
else:
20402039
# Get face lattice as a sublattice of the ambient one
20412040
allowed_indices = frozenset(self._ambient_vertex_indices)
2041+
from sage.graphs.digraph import DiGraph
20422042
L = DiGraph()
20432043
empty = self._ambient.face_lattice().bottom()
20442044
L.add_vertex(0) # In case it is the only one
@@ -3974,6 +3974,7 @@ def skeleton(self):
39743974
sage: g.edges(sort=True) # needs palp sage.graphs
39753975
[(0, 1, None), (0, 3, None), (1, 2, None), (2, 3, None)]
39763976
"""
3977+
from sage.graphs.graph import Graph
39773978
skeleton = Graph()
39783979
skeleton.add_vertices(self.skeleton_points(1))
39793980
for edge in self.edges():

src/sage/graphs/bliss.pyx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -581,7 +581,7 @@ cpdef canonical_form(G, partition=None, return_graph=False, use_edge_labels=True
581581

582582
if return_graph:
583583
if directed:
584-
from sage.graphs.graph import DiGraph
584+
from sage.graphs.digraph import DiGraph
585585
H = DiGraph(new_edges, loops=G.allows_loops(), multiedges=G.allows_multiple_edges())
586586
else:
587587
from sage.graphs.graph import Graph

src/sage/graphs/graph.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -421,7 +421,6 @@
421421
from sage.rings.integer_ring import ZZ
422422
import sage.graphs.generic_graph_pyx as generic_graph_pyx
423423
from sage.graphs.generic_graph import GenericGraph
424-
from sage.graphs.digraph import DiGraph
425424
from sage.graphs.independent_sets import IndependentSets
426425
from sage.misc.rest_index_of_methods import doc_index, gen_thematic_rest_table_index
427426
from sage.graphs.views import EdgesView
@@ -3514,6 +3513,7 @@ def orientations(self, data_structure=None, sparse=None):
35143513
if name:
35153514
name = 'An orientation of ' + name
35163515

3516+
from sage.graphs.digraph import DiGraph
35173517
if not self.size():
35183518
D = DiGraph(data=[self.vertices(sort=False), []],
35193519
format='vertices_and_edges',

src/sage/graphs/graph_generators_pyx.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,8 +63,6 @@ def RandomGNP(n, p, bint directed=False, bint loops=False, seed=None):
6363
...
6464
ValueError: parameter 'loops' can be set to True only when 'directed' is True
6565
"""
66-
from sage.graphs.graph import Graph, DiGraph
67-
6866
if seed is not None:
6967
set_random_seed(seed)
7068

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

7674
if directed:
75+
from sage.graphs.digraph import DiGraph
7776
G = DiGraph(loops=loops)
7877
else:
78+
from sage.graphs.graph import Graph
7979
G = Graph()
8080
if loops:
8181
raise ValueError("parameter 'loops' can be set to True only when 'directed' is True")

src/sage/schemes/elliptic_curves/ell_field.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1931,7 +1931,6 @@ class of curves. If the j-invariant is not unique in the isogeny
19311931
"""
19321932

19331933
from warnings import warn
1934-
from sage.graphs.graph import DiGraph, Graph
19351934
from sage.matrix.constructor import Matrix
19361935

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

19851984
A = Matrix([r + [0] * (len(A) - len(r)) for r in A])
1986-
G = (DiGraph if directed else Graph)(A, format="adjacency_matrix",
1987-
data_structure="static_sparse")
1985+
if directed:
1986+
from sage.graphs.digraph import DiGraph as GraphType
1987+
else:
1988+
from sage.graphs.graph import Graph as GraphType
1989+
1990+
G = GraphType(A, format="adjacency_matrix",
1991+
data_structure="static_sparse")
19881992
# inplace relabelling is necessary for static_sparse graphs
19891993
GL = G.relabel(labels, inplace=False)
19901994
return GL

src/sage/sets/disjoint_set.pyx

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -600,7 +600,7 @@ cdef class DisjointSet_of_integers(DisjointSet_class):
600600
[(0, 0, None), (1, 1, None), (2, 1, None), (3, 1, None), (4, 1, None)]
601601
"""
602602
d = {i: [self._nodes.parent[i]] for i in range(self.cardinality())}
603-
from sage.graphs.graph import DiGraph
603+
from sage.graphs.digraph import DiGraph
604604
return DiGraph(d)
605605

606606
cdef class DisjointSet_of_hashables(DisjointSet_class):
@@ -891,5 +891,5 @@ cdef class DisjointSet_of_hashables(DisjointSet_class):
891891
e = self._int_to_el[i]
892892
p = self._int_to_el[self._nodes.parent[i]]
893893
d[e] = [p]
894-
from sage.graphs.graph import DiGraph
894+
from sage.graphs.digraph import DiGraph
895895
return DiGraph(d)

src/sage/sets/set.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -813,7 +813,7 @@ def subsets_lattice(self):
813813
raise NotImplementedError(
814814
"this method is only implemented for finite sets")
815815
from sage.combinat.posets.lattices import FiniteLatticePoset
816-
from sage.graphs.graph import DiGraph
816+
from sage.graphs.digraph import DiGraph
817817
from sage.rings.integer import Integer
818818
n = self.cardinality()
819819
# list, contains at position 0 <= i < 2^n

0 commit comments

Comments
 (0)