Skip to content
This repository has been archived by the owner on Jan 30, 2023. It is now read-only.

Commit

Permalink
trac #22349: some corrections
Browse files Browse the repository at this point in the history
  • Loading branch information
dcoudert authored and jhpalmieri committed Jul 18, 2022
1 parent a9ecbc5 commit 1e1ea24
Show file tree
Hide file tree
Showing 13 changed files with 36 additions and 38 deletions.
2 changes: 1 addition & 1 deletion src/sage/graphs/bipartite_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -1460,7 +1460,7 @@ def rec(G):
# We create a mapping from frozen unlabeled edges to (labeled) edges.
# This ease for instance the manipulation of multiedges (if any)
edges = {}
for e in G.edges(sort=True, labels=labels):
for e in G.edges(sort=False, labels=labels):
f = frozenset(e[:2])
if e[0] not in G.left:
e = (e[1], e[0], e[2]) if labels else (e[1], e[0])
Expand Down
10 changes: 5 additions & 5 deletions src/sage/graphs/generators/families.py
Original file line number Diff line number Diff line change
Expand Up @@ -2339,21 +2339,21 @@ def MycielskiStep(g):
gg = copy(g)

# rename a vertex v of gg as (1,v)
renamer = dict([(v, (1,v)) for v in g.vertices(sort=False)])
renamer = {v: (1, v) for v in g}
gg.relabel(renamer)

# add the w vertices to gg as (2,v)
wlist = [(2,v) for v in g.vertices(sort=False)]
wlist = [(2, v) for v in g]
gg.add_vertices(wlist)

# add the z vertex as (0,0)
gg.add_vertex((0,0))

# add the edges from z to w_i
gg.add_edges([((0,0), (2,v)) for v in g.vertices(sort=False)] )
gg.add_edges([((0, 0), (2, v)) for v in g] )

# make the v_i w_j edges
for v in g.vertices(sort=False):
for v in g:
gg.add_edges([((1,v),(2,vv)) for vv in g.neighbors(v)])

return gg
Expand Down Expand Up @@ -3200,7 +3200,7 @@ def next_step(triangle_list):
dg.add_edges([(tuple(b), tuple(c)) for a, b, c in tri_list])
dg.add_edges([(tuple(c), tuple(a)) for a, b, c in tri_list])
dg.set_pos({(x, y): (x + y / 2, y * 3 / 4)
for (x, y) in dg.vertices(sort=False)})
for (x, y) in dg})
dg.relabel()
return dg

Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/generators/random.py
Original file line number Diff line number Diff line change
Expand Up @@ -414,7 +414,7 @@ def RandomRegularBipartite(n1, n2, d1, set_position=False, seed=None):

if complement:
from sage.graphs.generators.basic import CompleteBipartiteGraph
E = E.symmetric_difference(CompleteBipartiteGraph(n1, n2).edges(sort=True, labels=False))
E = E.symmetric_difference(CompleteBipartiteGraph(n1, n2).edges(sort=False, labels=False))
d1, d2 = n2 - d1, n1 - d2

name = "Random regular bipartite graph of order {}+{} and degrees {} and {}".format(n1, n2, d1, d2)
Expand Down
10 changes: 5 additions & 5 deletions src/sage/graphs/generic_graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -19447,7 +19447,7 @@ def layout_circular(self, dim=2, center=(0, 0), radius=1, shift=0, angle=0, **op
"""
assert dim == 2, "3D circular layout not implemented"
from math import pi
return self._circle_embedding(self.vertices(sort=False), center=(0, 0),
return self._circle_embedding(self.vertices(sort=True), center=(0, 0),
radius=1, shift=0, angle=pi/2,
return_dict=True)

Expand Down Expand Up @@ -19908,11 +19908,11 @@ def _circle_embedding(self, vertices, center=(0, 0), radius=1, shift=0, angle=0,
sage: g._circle_embedding([0, 2, 4, 1, 3], radius=2, shift=.5)
sage: g.show()

sage: g._circle_embedding(g.vertices(sort=False), angle=0)
sage: g._circle_embedding(g.vertices(sort=True), angle=0)
sage: g._pos[0]
(1.0, 0.0)
sage: from math import pi
sage: g._circle_embedding(g.vertices(sort=False), angle=pi/2)
sage: g._circle_embedding(g.vertices(sort=True), angle=pi/2)
sage: g._pos[0]
(0.0, 1.0)

Expand All @@ -19926,7 +19926,7 @@ def _circle_embedding(self, vertices, center=(0, 0), radius=1, shift=0, angle=0,
The rounding error raised in :trac:`22050` is fixed::

sage: G = Graph(4)
sage: G._circle_embedding(G.vertices(sort=False))
sage: G._circle_embedding(G.vertices(sort=True))
sage: G._pos
{0: (1.0, 0.0), 1: (0.0, 1.0), 2: (-1.0, 0.0), 3: (0.0, -1.0)}
"""
Expand Down Expand Up @@ -23797,7 +23797,7 @@ def katz_matrix(self, alpha, nonedgesonly=False, vertices=None):
if n == 0 :
raise ValueError('graph is empty')
if vertices is None:
vertices = self.vertices(sort=False)
vertices = self.vertices(sort=True)
elif (len(vertices) != n or
set(vertices) != set(self)):
raise ValueError("``vertices`` must be a permutation of the vertices")
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/generic_graph_pyx.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -836,7 +836,7 @@ cdef class SubgraphSearch:
self.nh = H.order()

# Storing the list of vertices
self.g_vertices = G.vertices(sort=False)
self.g_vertices = G.vertices(sort=True)

# Are the graphs directed (in __init__(), we check
# whether both are of the same type)
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/graph.py
Original file line number Diff line number Diff line change
Expand Up @@ -3347,7 +3347,7 @@ def bounded_outdegree_orientation(self, bound, solver=None, verbose=False,
d.add_edges(('s', vertices_id[v], b[v]) for v in vertices)

d.add_edges(((vertices_id[u], vertices_id[v]), 't', 1)
for u,v in self.edges(sort=True, labels=None) )
for u,v in self.edges(sort=False, labels=None) )

# each v is linked to its incident edges

Expand Down Expand Up @@ -8856,7 +8856,7 @@ def rec(G):
# We create a mapping from frozen unlabeled edges to (labeled) edges.
# This ease for instance the manipulation of multiedges (if any)
edges = {}
for e in G.edges(sort=True, labels=labels):
for e in G.edges(sort=False, labels=labels):
f = frozenset(e[:2])
if f in edges:
edges[f].append(e)
Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/graph_generators.py
Original file line number Diff line number Diff line change
Expand Up @@ -2951,7 +2951,7 @@ def canaug_traverse_edge(g, aut_gens, property, dig=False, loops=False, sparse=T
z.add_edge(i, j)
if not property(z):
continue
z_aut_gens, _, canonical_relabeling = search_tree(z, [z.vertices(sort=False)], certificate=True, dig=(dig or loops))
z_aut_gens, _, canonical_relabeling = search_tree(z, [z.vertices(sort=True)], certificate=True, dig=(dig or loops))
relabel_inverse = [0]*n
for ii in range(n):
relabel_inverse[canonical_relabeling[ii]] = ii
Expand Down
4 changes: 1 addition & 3 deletions src/sage/graphs/schnyder.py
Original file line number Diff line number Diff line change
Expand Up @@ -195,9 +195,7 @@ def _normal_label(g, comb_emb, external_face):
v1, v2, v3 = external_vertices
v1_neighbors = Set(g.neighbors(v1))

neighbor_count = {}
for v in g.vertices(sort=False):
neighbor_count[v] = 0
neighbor_count = {v: 0 for v in g}
for v in g.neighbors(v1):
neighbor_count[v] = len(v1_neighbors.intersection(Set(g.neighbors(v))))

Expand Down
2 changes: 1 addition & 1 deletion src/sage/graphs/spanning_tree.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -1425,6 +1425,6 @@ def edge_disjoint_spanning_trees(G, k, by_weight=False, weight_function=None, ch
raise EmptySetError(msg_no_solution)

for f in res:
for u, v in f.edges(sort=True, labels=False):
for u, v in f.edges(sort=False, labels=False):
f.set_edge_label(u, v, G.edge_label(u, v))
return res
2 changes: 1 addition & 1 deletion src/sage/graphs/strongly_regular_db.pyx
Original file line number Diff line number Diff line change
Expand Up @@ -2592,7 +2592,7 @@ def SRG_126_50_13_24():
from sage.graphs.strongly_regular_db import SRG_175_72_20_36
from sage.graphs.generators.smallgraphs import HoffmanSingletonGraph
hs = HoffmanSingletonGraph()
s = set(hs.vertices(sort=True)).difference(hs.neighbors(0)+[0])
s = set(hs.vertices(sort=False)).difference(hs.neighbors(0)+[0])
g = SRG_175_72_20_36().subgraph(hs.edge_boundary(s,s))
g.name('Goethals graph')
return g
Expand Down
4 changes: 2 additions & 2 deletions src/sage/graphs/tutte_polynomial.py
Original file line number Diff line number Diff line change
Expand Up @@ -191,7 +191,7 @@ def underlying_graph(G):
from sage.graphs.graph import Graph
g = Graph()
g.allow_loops(True)
for edge in set(G.edges(sort=True, labels=False)):
for edge in set(G.edges(sort=False, labels=False)):
g.add_edge(edge)
return g

Expand All @@ -209,7 +209,7 @@ def edge_multiplicities(G):
[((1, 2), 2), ((1, 3), 1), ((2, 2), 1), ((2, 4), 3), ((3, 4), 2)]
"""
d = {}
for edge in G.edges(sort=True, labels=False):
for edge in G.edges(sort=False, labels=False):
d[edge] = d.setdefault(edge, 0) + 1
return d

Expand Down
6 changes: 3 additions & 3 deletions src/sage/sandpiles/sandpile.py
Original file line number Diff line number Diff line change
Expand Up @@ -972,7 +972,7 @@ def _set_max_stable_div(self):
sage: '_max_stable_div' in S.__dict__
True
"""
m = {v: self.out_degree(v) - 1 for v in self.vertices(sort=True)}
m = {v: self.out_degree(v) - 1 for v in self.vertices(sort=False)}
self._max_stable_div = SandpileDivisor(self, m)

def max_stable_div(self):
Expand Down Expand Up @@ -1004,8 +1004,8 @@ def _set_out_degrees(self):
sage: '_out_degrees' in s.__dict__
True
"""
self._out_degrees = {v: 0 for v in self.vertices(sort=True)}
for v in self.vertices(sort=True):
self._out_degrees = {v: 0 for v in self.vertices(sort=False)}
for v in self.vertices(sort=False):
for e in self.edges_incident(v):
self._out_degrees[v] += e[2]

Expand Down
24 changes: 12 additions & 12 deletions src/sage/schemes/curves/zariski_vankampen.py
Original file line number Diff line number Diff line change
Expand Up @@ -795,30 +795,30 @@ def geometric_basis(G, E, p):
EC = [v[0] for v in orient_circuit(E.eulerian_circuit())]
i = EC.index(p)
EC = EC[i:]+EC[:i+1] # A counterclockwise eulerian circuit on the boundary, based at p
if len(G.edges(sort=False)) == len(E.edges(sort=False)):
if G.size() == E.size():
if E.is_cycle():
return [EC]
I = Graph()
for e in G.edges(sort=False):
if not E.has_edge(e):
I.add_edge(e) # interior graph
# treat the case where I is empty
if not I.vertices(sort=False):
for v in E.vertices(sort=False):
if not I:
for v in E:
if len(E.neighbors(v)) > 2:
I.add_vertex(v)

for i in range(len(EC)): # q and r are the points we will cut through

if EC[i] in I.vertices(sort=False):
if EC[i] in I:
q = EC[i]
connecting_path = EC[:i]
break
elif EC[-i] in I.vertices(sort=False):
elif EC[-i] in I:
q = EC[-i]
connecting_path = list(reversed(EC[-i:]))
break
distancequotients = [(E.distance(q, v)**2/I.distance(q, v), v) for v in E.vertices(sort=False) if v in I.connected_component_containing_vertex(q) and not v == q]
distancequotients = [(E.distance(q, v)**2/I.distance(q, v), v) for v in E if v in I.connected_component_containing_vertex(q) and not v == q]
r = max(distancequotients)[1]
cutpath = I.shortest_path(q, r)
Gcut = copy(G)
Expand All @@ -834,16 +834,16 @@ def geometric_basis(G, E, p):
for v in cutpath:
neighs = G.neighbors(v)
for n in neighs:
if n in G1.vertices(sort=False)+cutpath:
if n in G1 or n in cutpath:
G1.add_edge(v, n, None)
if n in G2.vertices(sort=False)+cutpath:
if n in G2 or n in cutpath:
G2.add_edge(v, n, None)

if EC[EC.index(q)+1] in G2.vertices(sort=False):
if EC[EC.index(q)+1] in G2:
G1, G2 = G2, G1

E1, E2 = Ecut.connected_components_subgraphs()
if EC[EC.index(q)+1] in E2.vertices(sort=False):
if EC[EC.index(q)+1] in E2:
E1, E2 = E2, E1

for i in range(len(cutpath)-1):
Expand All @@ -852,9 +852,9 @@ def geometric_basis(G, E, p):

for v in [q, r]:
for n in E.neighbors(v):
if n in E1.vertices(sort=False):
if n in E1:
E1.add_edge(v, n, None)
if n in E2.vertices(sort=False):
if n in E2:
E2.add_edge(v, n, None)

gb1 = geometric_basis(G1, E1, q)
Expand Down

0 comments on commit 1e1ea24

Please sign in to comment.