Git Product home page Git Product logo

Danyal Farahany's Projects

hopcroft--karp-algorithm-in-java icon hopcroft--karp-algorithm-in-java

A vertex that is not the endpoint of an edge in some partial matching M M is called a free vertex. The basic concept that the algorithm relies on is that of an augmenting path, a path that starts at a free vertex, ends at a free vertex, and alternates between unmatched and matched edges within the path. It follows from this definition that, except for the endpoints, all other vertices (if any) in augmenting path must be non-free vertices. An augmenting path could consist of only two vertices (both free) and single unmatched edge between them. If M M is a matching, and P P is an augmenting path relative to M M, then the symmetric difference of the two sets of edges, M ⊕ P M \oplus P, would form a matching with size | M | + 1 |M| + 1. Thus, by finding augmenting paths, an algorithm may increase the size of the matching. Conversely, suppose that a matching M M is not optimal, and let P P be the symmetric difference M ⊕ M ∗ M \oplus M^* where M ∗ M^* is an optimal matching. Because M M and M ∗ M^* are both matchings, every vertex has degree at most 2 in P P. So P P must form a collection of disjoint cycles, of paths with an equal number of matched and unmatched edges in M M, of augmenting paths for M M, and of augmenting paths for M ∗ M^*; but the latter is impossible because M ∗ M^* is optimal. Now, the cycles and the paths with equal numbers of matched and unmatched vertices do not contribute to the difference in size between M M and M ∗ M^*, so this difference is equal to the number of augmenting paths for M M in P P. Thus, whenever there exists a matching M ∗ M^* larger than the current matching M M, there must also exist an augmenting path. If no augmenting path can be found, an algorithm may safely terminate, since in this case M M must be optimal. An augmenting path in a matching problem is closely related to the augmenting paths arising in maximum flow problems, paths along which one may increase the amount of flow between the terminals of the flow. It is possible to transform the bipartite matching problem into a maximum flow instance, such that the alternating paths of the matching problem become augmenting paths of the flow problem.[3] In fact, a generalization of the technique used in Hopcroft–Karp algorithm to arbitrary flow networks is known as Dinic's algorithm.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.