Блог пользователя ikk

Автор ikk, 14 лет назад, По-английски

Some resources found on the Web state that the running time of the bipartite matching algorithm (as found in UL: Undefined's solution) is O(|V|(|V| + |E|)).  I suspect, however, that there exists a better upper bound for this.  In Problem H of Saratov Regional, the number of the vertices can be as large as .  A Θ(|V|(|V| + |E|)) algorithm usually gives TLE for graphs of this size, but many participants got ACs by submitting that algorithm.

I suspect the running time is determined by the lesser of the number of vertices on the left and the number of vertices on the right.  Am I wrong?  I couldn't prove or disprove myself.

  • Проголосовать: нравится
  • +4
  • Проголосовать: не нравится

14 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится
you can read about time here, but it's in russian (google translate ;))
14 лет назад, скрыть # |
 
Проголосовать: нравится 0 Проголосовать: не нравится
This algo is the best for bipartite graphs
14 лет назад, скрыть # |
 
Проголосовать: нравится +1 Проголосовать: не нравится

Yes, the running time is O(X (|V|+|E|)), where X is the number of vertices on the left. So if we choose left side as smaller side and right side as larger - it will be much faster that vice versa.

Also it's widely known that in reality this upper bound is never reached.

Additionally, there exists a trick, when before executing the DFS you try to find an straight edge to a non-saturated vertex. This trick greatly improves the running time, and makes the algorithm applicable even for thousands of vertices.