Book Image

Haskell Data Analysis cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis cookbook

By: Nishant Shukla

Overview of this book

Step-by-step recipes filled with practical code samples and engaging examples demonstrate Haskell in practice, and then the concepts behind the code. This book shows functional developers and analysts how to leverage their existing knowledge of Haskell specifically for high-quality data analysis. A good understanding of data sets and functional programming is assumed.
Table of Contents (14 chapters)
13
Index

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:

  1. Import the required library:

    import Data.Algorithm.MaximalCliques
  2. In main...