We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 5e2d8f7 commit a9936c7Copy full SHA for a9936c7
src/Advanced.Algorithms/Graph/Matching/HopcroftKarp.cs
@@ -81,14 +81,14 @@ private List<T> bfs(IGraph<T> graph,
81
foreach (var vertex in partitions[1])
82
{
83
//if this left vertex is free
84
- if (!leftToRightMatchEdges.ContainsKey(vertex))
+ if (!leftToRightMatchEdges.ContainsKey(vertex) && !visited.Contains(vertex))
85
86
queue.Enqueue(vertex);
87
- visited.Add(vertex);
88
-
+
89
while (queue.Count > 0)
90
91
var current = queue.Dequeue();
+ visited.Add(vertex);
92
93
//unmatched edges left to right
94
foreach (var leftToRightEdge in graph.GetVertex(current).Edges)
0 commit comments