码迷,mamicode.com
首页 > 其他好文 > 详细

undirected graph bipartite

时间:2017-12-10 11:16:11      阅读:136      评论:0      收藏:0      [点我收藏+]

标签:highlight   ati   false   art   can   coloring   rsa   first   nod   

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

标签:highlight   ati   false   art   can   coloring   rsa   first   nod   

原文地址:http://www.cnblogs.com/apanda009/p/8016125.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!