@@ -2065,7 +2065,7 @@ def plot(self, label_elements=True, element_labels=None,
2065
2065
2066
2066
if cover_labels is not None :
2067
2067
if callable (cover_labels ):
2068
- for v , w in graph .edges (sort = True , labels = False ):
2068
+ for v , w in graph .edges (sort = False , labels = False ):
2069
2069
graph .set_edge_label (v , w , cover_labels (v , w ))
2070
2070
elif isinstance (cover_labels , dict ):
2071
2071
for v , w in cover_labels :
@@ -2453,7 +2453,7 @@ def is_d_complete(self) -> bool:
2453
2453
min_elmt = d [0 ]
2454
2454
max_elmt = d [3 ]
2455
2455
2456
- if len ( H . neighbors_in (max_elmt ) ) != 2 :
2456
+ if H . in_degree (max_elmt ) != 2 :
2457
2457
# Top of a diamond cannot cover anything but the two side elements
2458
2458
return False
2459
2459
@@ -2469,7 +2469,7 @@ def is_d_complete(self) -> bool:
2469
2469
continue
2470
2470
for mx in potential_max :
2471
2471
if len (H .all_paths (mn , mx )) == 2 :
2472
- if len ( H . neighbors_in (mx ) ) != 1 :
2472
+ if H . in_degree (mx ) != 1 :
2473
2473
# Max element covers something outside of double tailed diamond
2474
2474
return False
2475
2475
# Success
@@ -3632,7 +3632,7 @@ def dimension(self, certificate=False, *, solver=None, integrality_tolerance=1e-
3632
3632
P = Poset (self ._hasse_diagram ) # work on an int-labelled poset
3633
3633
hasse_diagram = P .hasse_diagram ()
3634
3634
inc_graph = P .incomparability_graph ()
3635
- inc_P = inc_graph .edges (sort = True , labels = False )
3635
+ inc_P = inc_graph .edges (sort = False , labels = False )
3636
3636
3637
3637
# cycles is the list of all cycles found during the execution of the
3638
3638
# algorithm
@@ -5323,9 +5323,9 @@ def edge_color(va, vb):
5323
5323
5324
5324
for i0 , i1 in Subsets (factors_range , 2 ):
5325
5325
for x in prod_dg :
5326
- neigh0 = [y for y in prod_dg .neighbors (x )
5326
+ neigh0 = [y for y in prod_dg .neighbor_iterator (x )
5327
5327
if edge_color (x , y ) == i0 ]
5328
- neigh1 = [z for z in prod_dg .neighbors (x )
5328
+ neigh1 = [z for z in prod_dg .neighbor_iterator (x )
5329
5329
if edge_color (x , z ) == i1 ]
5330
5330
for x0 , x1 in cartesian_product_iterator ([neigh0 , neigh1 ]):
5331
5331
x2 = list (x0 )
@@ -7175,7 +7175,7 @@ def order_polytope(self):
7175
7175
"""
7176
7176
from sage .geometry .polyhedron .constructor import Polyhedron
7177
7177
ineqs = [[0 ] + [ZZ (j == v ) - ZZ (j == u ) for j in self ]
7178
- for u , v , w in self .hasse_diagram ().edges (sort = True )]
7178
+ for u , v in self .hasse_diagram ().edges (sort = False , labels = False )]
7179
7179
for i in self .maximal_elements ():
7180
7180
ineqs += [[1 ] + [- ZZ (j == i ) for j in self ]]
7181
7181
for i in self .minimal_elements ():
@@ -8369,7 +8369,7 @@ def frank_network(self):
8369
8369
pdict [(0 , i )] = [(1 , j ) for j in self if self .ge (i , j )]
8370
8370
pdict [(1 , i )] = [(2 , 0 )]
8371
8371
G = DiGraph (pdict , format = "dict_of_lists" )
8372
- a = {( u , v ) : 0 for ( u , v , l ) in G .edge_iterator ()}
8372
+ a = {e : 0 for e in G .edge_iterator (labels = False )}
8373
8373
for i in self :
8374
8374
a [((0 , i ), (1 , i ))] = 1
8375
8375
return (G , a )
@@ -9108,50 +9108,49 @@ def _ford_fulkerson_chronicle(G, s, t, a):
9108
9108
(11, 2)
9109
9109
"""
9110
9110
# pi: potential function as a dictionary.
9111
- pi = {v : 0 for v in G . vertex_iterator () }
9111
+ pi = {v : 0 for v in G }
9112
9112
# p: value of the potential pi.
9113
9113
p = 0
9114
9114
9115
9115
# f: flow function as a dictionary.
9116
- f = {( u , v ) : 0 for ( u , v , l ) in G .edge_iterator ()}
9116
+ f = {edge : 0 for edge in G .edge_iterator (labels = False )}
9117
9117
# val: value of the flow f. (Cannot call it v due to Python's asinine
9118
9118
# handling of for loops.)
9119
9119
val = 0
9120
9120
9121
9121
# capacity: capacity function as a dictionary. Here, just the
9122
9122
# indicator function of the set of arcs of G.
9123
- capacity = {( u , v ) : 1 for ( u , v , l ) in G .edge_iterator ()}
9123
+ capacity = {edge : 1 for edge in G .edge_iterator (labels = False )}
9124
9124
9125
9125
while True :
9126
9126
9127
9127
# Step MC1 in Britz-Fomin, Algorithm 7.2.
9128
9128
9129
9129
# Gprime: directed graph G' from Britz-Fomin, Section 7.
9130
9130
Gprime = DiGraph ()
9131
- Gprime .add_vertices (G . vertices ( sort = False ) )
9132
- for ( u , v , l ) in G .edge_iterator ():
9131
+ Gprime .add_vertices (G )
9132
+ for u , v in G .edge_iterator (labels = False ):
9133
9133
if pi [v ] - pi [u ] == a [(u , v )]:
9134
9134
if f [(u , v )] < capacity [(u , v )]:
9135
9135
Gprime .add_edge (u , v )
9136
9136
elif f [(u , v )] > 0 :
9137
9137
Gprime .add_edge (v , u )
9138
9138
9139
- # X: list of vertices of G' reachable from s, along with
9140
- # the shortest paths from s to them.
9141
- X = Gprime .shortest_paths (s )
9139
+ # X: list of vertices of G' reachable from s
9140
+ X = set (Gprime .depth_first_search (s ))
9142
9141
if t in X :
9143
9142
# Step MC2a in Britz-Fomin, Algorithm 7.2.
9144
- shortest_path = X [ t ]
9143
+ shortest_path = Gprime . shortest_path ( s , t , by_weight = False )
9145
9144
shortest_path_in_edges = zip (shortest_path [:- 1 ], shortest_path [1 :])
9146
- for ( u , v ) in shortest_path_in_edges :
9147
- if v in G .neighbors_out (u ):
9145
+ for u , v in shortest_path_in_edges :
9146
+ if v in G .neighbor_out_iterator (u ):
9148
9147
f [(u , v )] += 1
9149
9148
else :
9150
9149
f [(v , u )] -= 1
9151
9150
val += 1
9152
9151
else :
9153
9152
# Step MC2b in Britz-Fomin, Algorithm 7.2.
9154
- for v in G . vertex_iterator () :
9153
+ for v in G :
9155
9154
if v not in X :
9156
9155
pi [v ] += 1
9157
9156
p += 1
0 commit comments