简体   繁体   English

我怎样才能证明一个图是二分的?

[英]How can i prove that a graph is bipartite?

I know the theory and the lemma that says if a graph contains an odd length cycle then it cant be bipartite but how can i PROVE it?我知道理论和引理说,如果一个图包含一个奇数长度的循环,那么它不能是二分的,但我怎么能证明呢?

take for example this adjacency matrix how can i prove that this graph is or isnt bipartite?以这个邻接矩阵为例,我如何证明这个图是或不是二分的?

So here's the algorithm I would use.所以这是我将使用的算法。 It uses approach (3) that I mentioned in the comments above: determine the two sets and confirm that they meet the requirements (ie, each vertex only connects to the other set)它使用我在上面评论中提到的方法(3):确定两个集合并确认它们满足要求(即每个顶点只连接到另一个集合)

  1) Make two sets, group1 and group2.  
     Mark all of the vertexes as unassigned and incomplete

  2) Assign the first unassigned vertex to group1 and make it the current vertex

  3) For every assigned vertex connected to the current vertex (both to and from):
    a) If the current vertex is unassigned, 
           then assign the current vertex to the other group
    b) If the current vertex is assigned to the same group, 
           then the graph is not bipartite, EXIT

  4) If the current vertex is still unassigned then assign it to group1
  5) For every unassigned vertex connected to the current vertex (both to and from):
    a) assign it to the other group
  6) Mark the current vertex as complete

  7) Make the first incomplete assigned vertex the current vertex
    a) If there are none, then make the first unassigned vertex the current vertex
    b) If there are none, then the graph is bipartite.  EXIT

  8) GoTo (3)

If you use the Adjacency Matrix then this is probably O(v^2) where v is the number of vertices.如果您使用邻接矩阵,那么这可能是O(v^2) ,其中v是顶点数。 If you change it to a list of vertices with To/From connection lists attached then I think that it is O(v+c) where c is the number of connections.如果将其更改为附加了 To/From 连接列表的顶点列表,那么我认为它是O(v+c) ,其中c是连接数。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM