human
I wrote the below code

    def breadth_first_search():
        for v in left:
            if (leftmatches[v] is None):
                distances[v] = 0
                queue.append(v)
            else:
                distances[v] = INFINITY
        distances[None] = INFINITY
        while queue:
            v = queue.popleft()
            if (distances[v] < distances[None]):
                for u in G[v]:
                    if (distances[rightmatches[u]] is INFINITY):
                        distances[rightmatches[u]] = (distances[v] + 1)
                        queue.append(rightmatches[u])
        return (distances[None] is not INFINITY)
    def depth_first_search(v):
        if (v is not None):
            for u in G[v]:
                if (distances[rightmatches[u]] == (distances[v] + 1)):
                    if depth_first_search(rightmatches[u]):
                        rightmatches[u] = v
                        leftmatches[v] = u
                        return True
            distances[v] = INFINITY
            return False
        return True
    (left, right) = bipartite_sets(G, top_nodes)
    leftmatches = {v: None for v in left}
    rightmatches = {v: None for v in right}
    distances = {}
    queue = collections.deque()
    num_matched_pairs = 0
    while breadth_first_search():
        for v in left:
            if (leftmatches[v] is None):
                if depth_first_search(v):
                    num_matched_pairs += 1
    leftmatches = {k: v for (k, v) in leftmatches.items() if (v is not None)}
    rightmatches = {k: v for (k, v) in rightmatches.items() if (v is not None)}
    return dict(itertools.chain(leftmatches.items(), rightmatches.items()))

What's a good function header?
 ... Here's a good function header?
assistant
#Here's a good function header.

def hopcroft_karp_matching(G, top_nodes=None):