A bipartite graph is a graph in which the vertices can be divided into two disjoint sets, such that no two vertices within the same set are adjacent. In other words, it is a graph in which every edge connects a vertex of one set to a vertex of the other set.
An alternate definition: Formally, a graph G = (V, E) is bipartite if and only if its vertex set V can be partitioned into two non-empty subsets X and Y, such that every edge in E has one endpoint in X and the other endpoint in Y. This partition of vertices is also known as bi-partition.
Note: In the above image nodes of the same colour belong to the same set.
Characteristics of Bipartite Graph
The characteristics of a bipartite graph are as follows:
- Vertices can be divided into two disjoint sets: A bipartite graph can be partitioned into two sets of vertices, with no edges between vertices within each set.
- Every edge connects vertices in different sets: Every edge in a bipartite graph connects a vertex from one set to a vertex from the other set.
- No odd-length cycles: A bipartite graph cannot contain any odd-length cycles, as this would require vertices from the same set to be connected by an edge.
- Maximum degree is bounded by the size of the smaller set: The maximum degree of a vertex in a bipartite graph is equal to the size of the smaller set.
- Coloring with two colors: A bipartite graph can be colored with two colors,, such that no adjacent vertices have the same color.
How to identify Bipartite Graph?
To identify whether a given graph is bipartite, you can use the following algorithm:
- Choose any vertex in the graph and assign it to one of the two sets, say X.
- Assign all of its neighbors to the other set, say Y.
- For each vertex in set Y, assign its neighbors to set X, and for each vertex in set X, assign its neighbors to set Y.
- Repeat step 3 until all vertices have been assigned to a set.
- Check if any two adjacent vertices are in the same set. If yes, then the graph is not bipartite. Otherwise, it is bipartite.
To learn more about “How to identify”, refer to this article.
Application of Bipartite Graph
Bipartite graphs have many applications in different fields, including:
- Matching problems: Bipartite graphs are commonly used to model matching problems, such as matching job seekers with job vacancies or assigning students to project supervisors. The bipartite structure allows for a natural way to match vertices from one set to vertices in the other set.
- Social networks: Bipartite graphs, where the nodes in one set represent users and the nodes in the other set reflect interests, groups, or communities, can be used to simulate social networks. The bipartite form makes it simple to analyse the connections between users and interests.
- Web Search engine: The query and click-through data of a search engine can be defined using a bipartite graph, where the two sets of vertices represent queries and web pages.
What else can you read?
- Check whether given graph is bipartite?
- Maximum bipartite matching
- Check if given graph is bipartite using DFS?
- Minimum Bipartite groups
Ready to dive in? Explore our Free Demo Content and join our DSA course, trusted by over 100,000 neveropen!