# Which Data Structure Is Used for Bipartite Matching Problem?

//

Heather Bennett

The bipartite matching problem is a classic problem in graph theory and algorithm design. It involves finding a maximum matching in a bipartite graph. In this article, we will explore the data structure commonly used to solve this problem – the augmented path algorithm.

What is Bipartite Graph?
A bipartite graph is a graph whose vertices can be divided into two disjoint sets such that no two vertices within the same set are adjacent. In other words, there are no edges connecting vertices within the same set.

What is Matching?
In graph theory, a matching refers to a subset of edges in which no two edges share a common vertex. A maximum matching is a matching of maximum cardinality (i.e., it contains the maximum number of edges).

The Augmented Path Algorithm
The augmented path algorithm is commonly used to solve the bipartite matching problem efficiently. It starts with an initial empty matching and iteratively augments it until no more augmenting paths can be found.

## 1. Building the Initial Matching

To begin, we initialize an empty set of matched edges called the matching. We then iterate through each vertex on one side of the bipartite graph and attempt to find an unmatched neighbor on the other side.

• If an unmatched neighbor is found, we add the edge connecting these two vertices to the matching.
• If no unmatched neighbor is found, we move on to the next vertex.

This process continues until all vertices on one side have been processed.

## 2. Finding Augmenting Paths

Once we have built the initial matching, we need to find augmenting paths in order to increase its cardinality. An augmenting path is a path that starts and ends with unmatched vertices and alternates between matched and unmatched edges.

To find an augmenting path, we can use a depth-first search (DFS) or a breadth-first search (BFS) starting from any unmatched vertex on one side of the bipartite graph. During the search, we alternate between following matched and unmatched edges.

### 2.1 Depth-First Search (DFS)

A depth-first search is a recursive algorithm that explores as far as possible along each branch before backtracking. In the context of finding augmenting paths, we start with an unmatched vertex and recursively explore its neighbors, following unmatched edges whenever possible.2 Breadth-First Search (BFS)

A breadth-first search explores all the vertices at the current level before moving to the next level. In the context of finding augmenting paths, we start with an unmatched vertex and iteratively visit its neighbors at each level, following unmatched edges whenever possible.

## 3. Augmenting the Matching

Once we have found an augmenting path, we can augment the matching by flipping the status of matched and unmatched edges along this path. This effectively increases the cardinality of the matching by one.

After augmenting the matching, we repeat steps 2 and 3 until no more augmenting paths can be found. At this point, we have found a maximum matching in the bipartite graph.

Conclusion
The augmented path algorithm is a powerful tool for solving bipartite matching problems efficiently. By building an initial matching and repeatedly finding and augmenting paths, we can find a maximum matching in a bipartite graph.

With proper implementation using data structures like adjacency lists or adjacency matrices to represent graphs, this algorithm can efficiently handle large-scale bipartite matching problems.

So if you ever encounter a problem that requires finding a maximum matching in a bipartite graph, consider using the augmented path algorithm and utilize the power of data structures to solve it effectively.