codinggraphs
Can a graph be colored with two colors?
Anonymous
Start a BFS from each unvisited component and alternate colors across every edge. If an edge connects two nodes with the same color, the graph isn't bipartite. Checking every node and edge takes O(V + E) time.
0