Book Image

Haskell Data Analysis Cookbook

By : Nishant Shukla
Book Image

Haskell Data Analysis Cookbook

By: Nishant Shukla

Overview of this book

Table of Contents (19 chapters)
Haskell Data Analysis Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Determining whether any two graphs are isomorphic


Graphs can have arbitrary labels, but their topology may be isomorphic. In the world of data analysis, we can examine different graphical networks and identify clusters of nodes that have identical connection patterns. This helps us discover when two seemingly different graphical networks end up with the same network mapping. Maybe then we can declare a one-to-one isomorphism between the nodes and learn something profound about the nature of the graphs.

We will use the isIsomorphic function from Data.Graph.Automorphism to detect whether two graphs are identical in their connection.

In this recipe, we will let the library calculate whether the two graphs in the following diagram are isomorphic in their connections:

Getting started

Install the Automorphism library:

$ cabal install hgal

How to do it...

Write the following code in a new file, which we will name Main.hs:

  1. Import the following packages:

    import Data.Graph
    import Data.Graph.Automorphism
  2. Construct...