2

I want to find the largest clique containing certain vertex in a connected graph. In the wiki it said a maximal clique can be found by greedy search. However, this can't ensure that you find the largest clique IMO. For example,

enter image description here

If I want to find the largest clique containing A, and I do this by greedy search, I may end up finding (A,B), which is smaller than another clique (A,C,D).

I came up with a naive way to avoid smaller cliques: First find all vertices that are adjacent to your starting point, and then for each of these vertices (let's call it x), calculate how many other vertices that x is not adjacent to. After this, delete the vertex that is not adjacent to most number of vertices, and check if the rest of them form a clique. If not, repeat the procedure until the rest of them form a clique.

I understand this is a silly question but I'd appreciate it very much if anyone can tell me whether this approach is correct or not.

Catarina Ferreira
  • 1,824
  • 5
  • 17
  • 26
Si Chen
  • 53
  • 5
  • 2
    Probably this question is better off [here](https://math.stackexchange.com). – rodgdor Jun 21 '17 at 23:23
  • 2
    @RodrigoDorantes-Gilardi Definitely not math. CS, maybe, but not math. – btilly Jun 22 '17 at 00:18
  • The answers so far talk about maxim**al** ( = "ungrowable") cliques, which are not the same thing as maxim**um** ( = "largest possible") cliques. Nevertheless your problem is NP-hard, since if there was an algorithm for solving it efficiently, we could also solve any instance of the NP-hard (Maximum) Clique problem simply by adding one more vertex, linking it to every other vertex, and then calling the algorithm that solves your problem efficiently. – j_random_hacker Jun 22 '17 at 15:06
  • @j_random_hacker, thanks. My friend showed me a counterexample of my method. It can still miss some maximum cliques. – Si Chen Jun 22 '17 at 15:46
  • Rephrasing @j_random_hacker 's comment, your problem of finding a maxim**al** clique in G containing a specific node N is equivalent to finding the maxim**um** clique of the subgraph G' containing node N and all nodes connected to N. So the problem remains NP-Hard. However, it is better to work with the subgraph than enumerating all maxim**al** cliques of the entire graph. – wolfmanx Aug 19 '20 at 18:25

1 Answers1

1

Enumerate all maximal cliques within your graph, then just check - do they contain given vertex or do not.

Maximal clique enumeration is NP-hard problem, that is, we don't know an efficient way to solve it at the moment. I have tried MACE (MAximal Clique Enumerater, ver. 2.2 and it worked quite well for me (it worked on graphs with thousands of vertices). You can check the details in corresponding article.

EDIT If you just want to check does the maximum clique contain a vertex or not, you can try cliquer to find the maximum clique.

CaptainTrunky
  • 1,562
  • 2
  • 15
  • 23
  • The OP needs a maxim**um** ( = largest possible) clique in this subgraph. A maxim**al** clique C is just one that can't be grown by adding more vertices; a different clique (that leaves out some of the vertices in C) could have more vertices in total. – j_random_hacker Jun 22 '17 at 15:04
  • @j_random_hacker. It's true that maximal and maximum cliques are different things, but I think finding all maximal cliques is a way to solve my problem because after finding them, you can sorting the cliques containing A by size and pick up the largest one, though this involves much redundant calculation. – Si Chen Jun 22 '17 at 15:49
  • @j_random_hacker I am fully aware of the difference between maximal and maximum cliques. But if you need a clique that contains a certain node, you have to run enumeration - the maximum clique could not contain the required node, but you are looking for the largest possible clique with the node. Still, thanks for a point, I edited my answer. – CaptainTrunky Jun 23 '17 at 00:55
  • @SiChen You can try MaxSAT for finding the maximum clique with a node, but it could be rather difficult to implement. For example, consider [this](https://pdfs.semanticscholar.org/6ce2/c473be601c1030f1ec4fbf733718e2a2c75b.pdf) – CaptainTrunky Jun 23 '17 at 01:49
  • @CaptainTrunky: You don't "need" to run such an enumeration -- you could alternatively delete the required node v and all vertices that are not neighbours of it, and then look for a maxim**um** clique C. Finally, add v (and its edges to vertices in C) back to C, to produce a largest-possible clique containing v. (Notice that adding v and these edges back to C always produces a clique, since we removed any non-neighbours of v before looking for the maximum clique.) – j_random_hacker Jun 23 '17 at 11:17