Does anyone know of a library or some code (preferably Java) that solves the clique cover problem?
I found an OCaml version, but I would like to use something I can more easily integrate with.
I've also found Java code and C code to find the maximum clique in a graph, but I don't know of a way to leverage this code to find a clique cover (e.g., iteratively removing maximum cliques until no nodes are left does not yield an optimum solution).
A Java program that determines if there is a 3-clique in a graph:
The problem defined:
https://en.wikipedia.org/wiki/Clique_problem
Input format:
The input to the method called
three_clique
is a String encoding representing an undirected graph that is represented like this:This encoding denotes an undirected graph with three nodes: 1,2,3. There are edges between 1 and 2, 2 and 3 and 3 and 1. It looks like a triangle. Clearly this undirected graph contains a 3 clique.
This encoding of an undirected graph does not contain a 3-clique:
The code:
Output
The program outputs a series of seven dots on the screen which means all the unit tests pass. To prove it works, add some more unit test cases for large undirected graphs like this one:
(1,2,3,4,5)((1,5);(1,4);(1,3);(1,2);(1,1);)
And see if it returns false.Runtime complexity:
Computational complexity is Polynomial, specifically
O(n^3)
. So it's very inefficient and is certainly not the optimal algorithm for this problem. But it demonstrates the starting point how to approach and solve the clique problem in Java.