Graph Theory - Bipartite Graphs



Bipartite Graphs

A bipartite graph is a type of graph where the vertices can be divided into two disjoint and independent sets, U and V, such that every edge connects a vertex in U to a vertex in V.

Bipartite graphs are also known as bigraphs. These graphs are used in various applications like modeling relationships between two different classes of objects, such as jobs and workers, or students and courses.

Example

Consider a bipartite graph where U = {A, B, C} and V = {1, 2, 3}, and the edges are E = {(A, 1), (A, 2), (B, 2), (C, 3)}. This graph shows the connections between two distinct sets of vertices.

Bipartite Graph

Properties of Bipartite Graphs

Bipartite graphs have several important properties that distinguish them from other types of graphs.

No Odd-Length Cycles

A graph is bipartite if and only if it does not contain any odd-length cycles. This means that any cycle in a bipartite graph must have an even number of edges.

Two-Colorability

A bipartite graph can be colored using two colors such that no two adjacent vertices share the same color. This property is known as two-colorability and is a key characteristic of bipartite graphs.

Matching and Perfect Matching

In a bipartite graph, a matching is a set of edges without common vertices. A perfect matching is a matching that covers all vertices of the graph. Bipartite graphs are often analyzed for maximum matching problems.

Complete Bipartite Graph

A complete bipartite graph is a bipartite graph where every vertex in set U is connected to every vertex in set V. It is denoted as K(m, n), where m and n are the sizes of the two sets.

Complete Bipartite Graph

Representation of Bipartite Graphs

Bipartite graphs can be represented using adjacency matrices, adjacency lists, and incidence matrices.

Adjacency Matrix Representation

An adjacency matrix for a bipartite graph is a rectangular matrix where the rows represent vertices from set U and the columns represent vertices from set V. The entry a[i][j] is 1 if there is an edge between vertex U[i] and vertex V[j], otherwise it is 0.

Example

For the bipartite graph with vertices U = {A, B, C}, V = {1, 2, 3}, and edges E = {(A, 1), (A, 2), (B, 2), (C, 3)}, the adjacency matrix would be −

1 2 3
A 1 1 0
B 0 1 0
C 0 0 1

Adjacency List Representation

An adjacency list for a bipartite graph consists of lists where each vertex in set U points to its adjacent vertices in set V, and vice versa.

Example

For the bipartite graph with vertices U = {A, B, C}, V = {1, 2, 3}, and edges E = {(A, 1), (A, 2), (B, 2), (C, 3)}, the adjacency list representation would be −

  • A: [1, 2]
  • B: [2]
  • C: [3]
  • 1: [A]
  • 2: [A, B]
  • 3: [C]

Incidence Matrix Representation

An incidence matrix for a bipartite graph is a matrix where the rows represent the vertices and the columns represent the edges. The entry a[i][j] is 1 if vertex i is incident to edge j, otherwise it is 0.

Example

For the bipartite graph with vertices U = {A, B, C}, V = {1, 2, 3}, and edges E = {(A, 1), (A, 2), (B, 2), (C, 3)}, the incidence matrix would be −

e1 (A-1) e2 (A-2) e3 (B-2) e4 (C-3)
A 1 1 0 0
B 0 0 1 0
C 0 0 0 1
1 1 0 0 0
2 0 1 1 0
3 0 0 0 1

Algorithms for Bipartite Graphs

Several algorithms are specifically designed to handle problems in bipartite graphs, such as testing bipartiteness, finding matchings, and solving network flow problems.

Bipartiteness Test

To test whether a given graph is bipartite, one can use a graph traversal algorithm like BFS or DFS to check if the graph can be colored using two colors.

Breadth-First Search (BFS) Approach

Using BFS, we can start from any vertex and attempt to color the graph using two colors. If we find a vertex that has the same color as one of its neighbors, the graph is not bipartite.

Example

Consider the graph with vertices V = {A, B, C, D, E} and edges E = {(A, B), (A, C), (B, D), (C, D), (D, E)}. Starting from vertex A and using BFS, we can attempt to color the graph.

Depth-First Search (DFS) Approach

DFS can also be used for the bipartiteness test by coloring vertices during the traversal. The process involves recursively visiting adjacent vertices and coloring them alternately. If a conflict arises, the graph is not bipartite.

Advertisements