Bipartite Graphs

A challenge by mousetail avatar mousetail

Description

According to Wikipedia a bipartite graph is the following:

In the mathematical field of graph theory, a bipartite graph (or bigraph) is a graph whose vertices can be divided into two disjoint and independent sets U and V, that is, every edge connects a vertex in U to one in V. Vertex sets U and V are usually called the parts of the graph. Equivalently, a bipartite graph is a graph that does not contain any odd-length cycles.

Your task is, given a list of graphs, output only the graphs that are bipartite.

Input Format

The input format will be: One graph per line, a space separated list of node indexes that the nth node connects to. For example

1, 0,2 1

Means node 0 has an edge to 1, 1 had edges to 0 and finally node 2 has one edge to node 1.

This challenge is a sub task of the Graph Planarity challenge

Leaderboard

Author Score
#1 Mukundan314 avatar Mukundan314 177
#2 XenThe avatar XenThe 291
#3 NicknamedTwice avatar NicknamedTwice 792
Challenge ends in 24 April 2026
You must be logged in to submit a solution.