I want to use graphviz in order to draw for a given graph all the maximal cliques that it has.
Therefore I would like that nodes in the same maximal clique will be visually encapsulated together (meaning that I would like that a big circle will surround them). I know that the cluster option exists – but in all the examples that I saw so far – each node is in one cluster only. In the maximal clique situation, a node can be in multiple cliques.
Is there an option to visualize this with graphviz?
If not, are there any other tools for this task (preferably with a python api).
Thank you.
I want to use graphviz in order to draw for a given graph all
Share
Take a tea, it’s gonna be long 🙂
I draw this with networkx, but the main steps could be easily transferred into graphviz.
The plan is the following:
a) find maximal cliques (just in case, maximal cliques are not necessary the largest cliques);
b) draw the graph and remember the coordinates of vertices that were used by drawing programm;
c) take clique’s coordinates, calculate the center and radius of the cirles that surrounds it;
d) draw the circles and color the verteces of the cliques in the same color (for the verteces in the intersection of 2 and more maxcliques it’s not possible).
Concerning c): I was lazy to figure the tight circle, but having some time it can be easily done.
Instead, I calculated the “approximating circle”: I took as radius the length of the longest edge in the clique and multiplied it by 1.3. Actually, with this approach some nodes might be left out, since only sqrt(3) quotient garantees that everyone is in. However, taking sqrt(3) will make the circle too large (again, it’s not tight). As center I took the middle of the largest edge.
Let’s see what we get:
Pic:

Another example with 3 maxcliques: