Bipartite graph
Bipartite graph - a graph whose vertices can be divided into two sets so that each edge connects the vertices from different sets.
Often in the context of bipartite graphs, the concept of colors vertices is used. Splitting a graph into two parts is called coloring its vertices with two different colors. Each edge must connect vertices of a different color.
DFS
.
Algorithm
We start painting from an arbitrary vertex, which we paint in an arbitrary color.
When passing along each edge, paint the next vertex in the opposite color.
If, while iterating over neighboring vertices, we find a vertex that is already painted in the same color as the current one, then there is an odd cycle in the graph, which means that it is not bipartite.