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

This means that node 0 has an edge to 1, 1 has edges to 0 and 2, and finally, node 2 has one edge to node 1.

This challenge is a sub task of the Graph Planarity challenge

Leaderboard

Author Bytes
#1 Mukundan314 avatar Mukundan314 100
#1 bizy-coder avatar bizy-coder 100
#3 ovs-code avatar ovs-code 103
#4 NicknamedTwice avatar NicknamedTwice 136
#4 sharky564 avatar sharky564 136
#6 mousetail avatar mousetail 557
Challenge ends in in 5 weeks, 3 days