MMatchOriel
Workflows

Coding workflows · Maximum bipartite matching

03
Built around your work

A concrete starting point

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.

01

Open the context

Choose the project folder and name the files or behavior involved.

02

Define the change

Describe the input, expected output and boundaries that must stay intact.

03

Inspect the work

Review the proposed edits and any commands before relying on their result.

04

Check the outcome

Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes.

Maximum bipartite matching

A concrete starting point
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.

AI coding workspace

Your next change starts here.

Get the Windows app ↗