Finding maximal cliques in a graph
Haskell comes with a luxury of vital graph libraries, conveniently one of which is the clique detection library from Data.Algorithm.MaximualCliques
. A clique in a graph is a subgraph where all the nodes have connections between themselves, and is depicted as follows:
For example, the preceding graph contains two cliques shaded in different colors. Perhaps, the graph represents web pages that link to each other. We can visually infer that there might be two clusters of Internet communities due to the structure of the graph. As the network of connections increases, finding the greatest clique becomes an exponentially difficult problem.
In this recipe, we will use an efficient implementation of the maximal clique problem.
Getting started
Install the clique library using cabal:
$ cabal install maximal-cliques
How to do it...
Write the following code in a new file, which we will name Main.hs
:
Import the required library:
import Data.Algorithm.MaximalCliques
In
main
...