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

Commit

Permalink
Use EdgesView for matching output
Browse files Browse the repository at this point in the history
  • Loading branch information
antonio-rojas committed Mar 13, 2022
1 parent 55a711e commit c6dc11b
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions src/sage/graphs/graph.py
Expand Up @@ -4118,8 +4118,8 @@ def matching(self, value_only=False, algorithm="Edmonds",
sage: edge_list = [(0,0,5), (0,1,1), (0,2,2), (0,3,3), (1,2,6)
....: , (1,2,3), (1,3,3), (2,3,3)]
sage: g = Graph(edge_list, loops=True, multiedges=True)
sage: g.matching(use_edge_labels=True)
[(1, 2, 6), (0, 3, 3)]
sage: sorted(g.matching(use_edge_labels=True))
[(0, 3, 3), (1, 2, 6)]
TESTS:
Expand Down Expand Up @@ -4166,7 +4166,7 @@ def weight(x):
else:
return Integer(len(d))
else:
return [(u, v, L[frozenset((u, v))]) for u, v in d]
return EdgesView(Graph([(u, v, L[frozenset((u, v))]) for u, v in d]))

elif algorithm == "LP":
g = self
Expand All @@ -4193,7 +4193,7 @@ def weight(x):
else:
return Integer(sum(1 for fe in L if b[fe]))
else:
return [(u, v, L[frozenset((u, v))]) for u, v in L if b[frozenset((u, v))]]
return EdgesView(Graph([(u, v, L[frozenset((u, v))]) for u, v in L if b[frozenset((u, v))]]))

else:
raise ValueError('algorithm must be set to either "Edmonds" or "LP"')
Expand Down

0 comments on commit c6dc11b

Please sign in to comment.