简体   繁体   中英

Graph algorithms?

What would be the most efficient way if I want to identify if a graph can be grouped into two sub graphs where in each sub graph each node is connected to every other node.For Example here in the image the graph can be grouped into two sub graphs consisting of 4 nodes and 5 nodes respectively where in each sub graph every node is connected to every other node. Suppose I am given a graph and I am to check whether the above fact holds true or not,what would be the most efficient way or algorithm to do so. 在此处输入图片说明

This is known as the clique problem . A clique is a subset of vertices such that every two vertices in the subset are connected in the original graph (that is, they form a complete subgraph). You are asking for an algorithm that lists all maximal cliques (cliques that are not part of larger cliques). There are various algorithms for this. The usual one used is the Bron-Kerbosch algorithm . It has a worst-case running time of O(3 n /3 ), where n is the number of vertices in the graph.

Other algorithms may be applicable if your graph has special structure (eg, planar, which your example is not).

EDIT: Actually, if your decision problem is whether the graph can be partitioned into exactly two cliques, there's a more efficient algorithm, as described in this thread (which then becomes a duplicate of your question).

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

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