@@ -0,0 +1,2208 @@
+# Python program to find out whether a  %0A# given graph is Bipartite or not %0A  %0Aclass Graph(): %0A  %0A    def __init__(self, V): %0A        self.V = V %0A        self.graph = %5B%5B0 for column in range(V)%5D %5C %0A                                for row in range(V)%5D %0A  %0A    # This function returns true if graph G%5BV%5D%5BV%5D  %0A    # is Bipartite, else false %0A    def isBipartite(self, src): %0A  %0A        # Create a color array to store colors assigned to all veritces. Vertex number is used as index in this array.  %0A        %0A        # The value '-1' of  colorArr%5Bi%5D is used to indicate that no color is assigned to vertex 'i'. The value 1 is used to indicate first color is assigned and value 0 %0A        #indicates second color is assigned. %0A        colorArr = %5B-1%5D * self.V %0A  %0A        # Assign first color to source %0A        colorArr%5Bsrc%5D = 1%0A  %0A        # Create a queue (FIFO) of vertex numbers and  %0A        # enqueue source vertex for BFS traversal %0A        queue = %5B%5D %0A        queue.append(src) %0A  %0A        # Run while there are vertices in queue %0A        while queue: %0A  %0A            u = queue.pop() %0A  %0A            # Return false if there is a self-loop %0A            if self.graph%5Bu%5D%5Bu%5D == 1: %0A                return False; %0A  %0A            for v in range(self.V): %0A  %0A                # An edge from u to v exists and destination  %0A                # v is not colored %0A                if self.graph%5Bu%5D%5Bv%5D == 1 and colorArr%5Bv%5D == -1: %0A  %0A                    # Assign alternate color to this  %0A                    # adjacent v of u %0A                    colorArr%5Bv%5D = 1 - colorArr%5Bu%5D %0A                    queue.append(v) %0A  %0A                # An edge from u to v exists and destination  %0A                # v is colored with same color as u %0A                elif self.graph%5Bu%5D%5Bv%5D == 1 and colorArr%5Bv%5D == colorArr%5Bu%5D: %0A                    return False%0A  %0A        # If we reach here, then all adjacent  %0A        # vertices can be colored with alternate  %0A        # color %0A        return True%0A  %0A# Driver program to test above function %0Ag = Graph(4) %0Ag.graph = %5B%5B0, 1, 0, 1%5D, %0A            %5B1, 0, 1, 0%5D, %0A            %5B0, 1, 0, 1%5D, %0A            %5B1, 0, 1, 0%5D %0A            %5D %0A              %0Aprint %22Yes%22 if g.isBipartite(0) else %22No%22%0A

Create bipartite.py