Open the context
Choose the project folder and name the files or behavior involved.
Find a maximum-cardinality matching between two groups of at most 32 vertices from allowed-edge sets. Test disconnected vertices and reassignment through an augmenting path, rejecting invalid indices without changing the edge sets.
Choose the project folder and name the files or behavior involved.
Describe the input, expected output and boundaries that must stay intact.
Review the proposed edits and any commands before relying on their result.
Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.
def maximum_matching(edges, right_count):
if type(right_count) is not int or not 0 <= right_count <= 32 or type(edges) not in (list, tuple) or len(edges) > 32:
raise ValueError("matching.size")
if any(type(row) not in (set, frozenset) or any(type(v) is not int or not 0 <= v < right_count for v in row) for row in edges):
raise ValueError("matching.edge")
owners = [-1] * right_count
def augment(left, seen):
for right in sorted(edges[left]):
if right in seen:
continue
seen.add(right)
if owners[right] == -1 or augment(owners[right], seen):
owners[right] = left
return True
return False
for left in range(len(edges)):
augment(left, set())
return sorted((left, right) for right, left in enumerate(owners) if left != -1)The example is a starting point for a real project, not a claim that generated code is already tested. Adjust paths, dependencies and expected behavior to match your application.