Skip to content

Commit 36ac7e4

Browse files
committed
fix method lift_cross_ratios in sage/matroids/utilities.py
1 parent 2fdb5e5 commit 36ac7e4

File tree

1 file changed

+8
-6
lines changed

1 file changed

+8
-6
lines changed

src/sage/matroids/utilities.py

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -572,26 +572,28 @@ def lift_cross_ratios(A, lift_map=None):
572572

573573
G = Graph([((r, 0), (c, 1), (r, c)) for r, c in A.nonzero_positions()])
574574
# write the entries of (a scaled version of) A as products of cross ratios of A
575-
T = set()
575+
T = Graph()
576576
for C in G.connected_components_subgraphs():
577-
T.update(C.min_spanning_tree())
577+
T.add_edges(C.min_spanning_tree())
578578
# - fix a tree of the support graph G to units (= empty dict, product of 0 terms)
579-
F = {entry[2]: dict() for entry in T}
580-
W = set(G.edge_iterator()) - set(T)
581-
H = G.subgraph(edges=T)
579+
F = {entry: dict() for entry in T.edge_labels()}
580+
W = set(G.edge_iterator()) - set(T.edge_iterator())
581+
H = G.subgraph(edges=T.edge_iterator())
582582
while W:
583583
# - find an edge in W to process, closing a circuit in H which is induced in G
584584
edge = W.pop()
585585
path = H.shortest_path(edge[0], edge[1])
586+
path_s = set(path)
586587
retry = True
587588
while retry:
588589
retry = False
589590
for edge2 in W:
590-
if edge2[0] in path and edge2[1] in path:
591+
if edge2[0] in path_s and edge2[1] in path_s:
591592
W.add(edge)
592593
edge = edge2
593594
W.remove(edge)
594595
path = H.shortest_path(edge[0], edge[1])
596+
path_s = set(path)
595597
retry = True
596598
break
597599
entry = edge[2]

0 commit comments

Comments
 (0)