Why can not you? Your question is preventing someone from writing a program for you, since you donβt even mention any particular language ...
The idea is to start by placing a random node in the FIFO queue (also here ). The color is blue. Then repeat this until the nodes remain in the queue: dequeue a element. Color its neighbors with a different color than the extracted element, and insert (enqueue) each neighbor into the FIFO queue. For example, if you remove (extract) an element (node), color red, color its neighboring blue. If you select a blue node, paint its neighbors red. If there are no coloring conflicts, the schedule is bipartite. If you finish coloring the node with two different colors, then this will not be bipartite.
Like @Moron, what I described will only work for linked charts. However, you can apply the same algorithm for each connected component to make it work for any graph.
Ivlad
source share