undirected graph bipartite

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了undirected graph bipartite相关的知识,希望对你有一定的参考价值。

Given an undirected graph, find if it is bipartite or not. Return true or false.

biparty graph = two coloring problem

DFS + coloring customization to implement it

We can do this by marking each node with 0 or 1.The first one we mark with 1, then a node in his list of neighbours with 0, 
then a neighbour of the neighbour with 1 and so until we mark all the nodes(and return true)
or we arrive in a node that is 0 and we want to mark it with 1 or viceversa (and we return false).

  

以上是关于undirected graph bipartite的主要内容,如果未能解决你的问题,请参考以下文章

785.Is Graph Bipartite?

Undirected Graphs

[LintCode] Connected Component in Undirected Graph

[LeetCode] Is Graph Bipartite? 是二分图么?

785. Is Graph Bipartite?( 判断是否为二分图)

lintcode431- Connected Component in Undirected Graph- medium