Talk:Hopcroft–Karp algorithm

message: Is it just me, or is the pseudocode rather hard to read? For example, the first loop tripped me a bit, because it is some akward mixture of high-level functions ((u,v) in E) and low-level implementation (for node u, node v). Furthermore, the code checks for nodes being in M. I do not understand this, as M is a matching, and thus, a set of edges? --Tetha (talk) 05:49, 11 June 2008 (UTC)
replies: text: M is a matching. When the code asks whether a vertex is in M, it means, is it an endpoint of one of the edges in M? I don't think it's any shorter or clearer than what's here, but if it would help you to see actual code for this algorithm, I have some here. (You can ignore the "imperfections" routine in that file; it solves a different and somewhat more complicated problem.) —David Eppstein (talk) 06:32, 11 June 2008 (UTC)
replies: text:  At least for me, the python code helps a lot. My definition of a matching came from graph theory, where a matching was just a set of edges that encode the matching (that is, an edge (u,v) in M means: u is matched with v). Your matching is a mapping that maps a node u to the node v, with u being matched with v. In your world, it makes a lot of sense to ask: node in matching, in mine, it did not (I rather would ask: exist an x with (x, u) in M.). Thank you. --Tetha (talk) 09:39, 11 June 2008 (UTC)
thread_title: Pseudocode

message: Page says:
 We also maintain a queue(last in first out datastructure)
Last in, first out is a stack, no?  —Preceding unsigned comment added by Talex (talk • contribs) 11:40, 20 July 2008 (UTC)
thread_title:  LIFO queue? 

message: I am sorry that I was trigger-happy with the main article. Only after I have completed my edit did I realize that it should have been discussed on this forum first. (First time to edit a Wikipedia page).
Did not touch the pseudo-code itself, only the part that explains it. It may take me much longer to write a readable and correct version of the pseudo-code.
The pseudo code is not complicated without a reason, it is incorrect. I realized it after I have implemented the algorithm only to see that in some cases it requires almost |V| iterations (rather than the promised O(\sqrt{(|V|)})). 
The main problem with the pseudo code (other than clarity) is that the BFS stops immediately when it discovers an augmenting path. The is against the way the original algorithm works, when it generates a maximal number of augmenting paths each time.
The proof that only O(\sqrt{(|V|)}) iterations are needed is based on the premises that each BFS iteration will return strictly longer augmenting paths. The current pseudo-code does not work this way.
For example, consider a graph with edges (divided into n subsets):
* (u01, v01) (u01, v02) (u02, v01)  
* (u11, v11) (u11, v12) (u12, v11)
...
* (u_n1, v_n1) (u_n1, v_n2) (u_n2, v_n1)
With initial matching marked in bold
The pseudo-code will require n iterations, when the real algorithm requires only one.
Michael Veksler (talk) 23:09, 9 October 2008 (UTC)
thread_title:  Incorrect pseudo-code 

message: It would be nice if the definitions of augmenting/alternating paths in Matching#Definition and Hopcroft–Karp algorithm#Alternating paths matched. — Miym (talk) 23:04, 5 March 2009 (UTC)
replies: text: It turns out that the Matching article's terminology matches the terminology in Ahuja, Magnanti, and Orlin. So I'll fix up this article to match. —David Eppstein (talk) 23:19, 5 March 2009 (UTC)
thread_title:  Terminology: augmenting and alternating paths 

message: I read some papers that, for a maximum weighted bipartite graph matching, claim they use Hopcroft-Karp instead of the Hungarian algorithm, since it's O(n^2.5) instead of O(n^3). See for example "Tracking Across Multiple Cameras With Disjoint Views" (Javed, Shah, 2003). Are these guys just clueless people trying to make it seem like they're using the new "hip" algorithm that is faster instead of the "old" Hungarian algorithm? Hopcroft-Karp has nothing to do with weights. Or am I missing something? This can be considered a widely referenced paper in Computer Vision. Jotaf (talk) 18:22, 31 August 2010 (UTC)
replies: text: If you're missing something, so am I; I don't know of a weighted version of Hopcroft-Karp. —David Eppstein (talk) 19:33, 31 August 2010 (UTC)
thread_title:  Weighted graphs? 

message: The pseudo-code DFS from vertices that has a Dist of 0, which starts a path, whereas the algorithm states that we should begin from vertices that ends a path. According to Dinic Algorithm, this corresponds to BFS from the sink and DFS from the source. I am not sure if this will make a difference to the time complexity.  — Preceding unsigned comment added by Tonyxty (talk • contribs) 02:04, 14 April 2011 (UTC)
thread_title:  Pseudo-code conflicts with the algorithm 

message: It's been several hours since I implemented this algorithm. This pseudocode is really helpful but...
BFS function does not do what it is supposed to do. As soon as it reaches NIL, it should clear queue Q and return true. Then there's no need to check NIL distance at the end of the function body, false should be returned. Now algorithm proceeds, causing (not asymptotically significant) time loss and maybe strange behavior on undefined Adj[NIL]. 80.188.71.176 (talk) 02:10, 16 January 2012 (UTC)
thread_title:  BFS should stop as soon as it reaches NIL 

message: "It can be shown that each phase increases the length of the shortest augmenting path by at least one: the phase finds a maximal set of augmenting paths of the given length, so any remaining augmenting path must be longer."
This is not that simple. In fact, showing that the length of the shortest augmenting path increases is perhaps the most difficult part of the entire proof. The error comes down to the distinction between "maximal" and "maximum." There may be other paths of the same length, but just not ones which are vertex-disjoint from these ones. 68.61.30.23 (talk) 16:48, 21 April 2013 (UTC)
thread_title:  "Analysis" 

message: In the references section there is a link to lecture notes from Meena Mahajan. Up to a point it's sort of good. Corollary fifteen which is a central statement in this paper states something about an M* matching and in the proof it assumes it is a maximum matching while the statement is true for any matching and in the same paper it is used for a generic matching rather than a maximum matching. In the original paper of Hopcroft and Karp in Theorem 1 gives the statement for any matching in a refined manner and proves it correctly. Unfortunately the original article is still not freely available, but I'm referring to this paper.  — Preceding unsigned comment added by Jakab922 (talk • contribs) 14:06, 14 March 2019 (UTC)
thread_title:  Remove the link to Mahajan's lecture notes