I was reading the augmenting path or Kuhn's algorithm to find the maximum matching size in an unweighed bipartite graph.
The algorithm tries to find an alternating path(consisting of alternating unmatched and matched edges) starting and ending at unmatched vertices. If an alternating path is found, the path is augmented and matching count is increased by 1.
I can understand the algorithm, however I have problem in understanding the way it is generally implemented. Here is a reference implementation - https://sites.google.com/site/indy256/algo/kuhn_matching2 .
At each stage, we should try to find an alternating path beginning from an unmatched vertex on the left. However, in the given implementation, in each iteration, instead of trying all unmatched vertices as possible start locations, we instead start our search from only a single unmatched vertex, as shown in the following code -
for (int u = 0; u < n1; u++) {
if (findPath(graph, u, matching, new boolean[n1]))
++matches;
}
This way, a vertex on left, which is not matched during its iteration, is never tried again. I can't understand why is this optimal?