Commit 68dbd445 authored by Alexandre Delanoë's avatar Alexandre Delanoë

[ILouvain] RGraph definition.

parent 60924bc5
...@@ -4,7 +4,7 @@ cabal-version: 1.12 ...@@ -4,7 +4,7 @@ cabal-version: 1.12
-- --
-- see: https://github.com/sol/hpack -- see: https://github.com/sol/hpack
-- --
-- hash: 0eb2bbc80a3d9343540c4d5c0c2ff6adee085a9a75364b8f5344890891c5b781 -- hash: 9d2b00c4d3d099b31d6b9db84cd1172e0464481bc132080e2694e02b5587b29b
name: clustering-louvain name: clustering-louvain
version: 0.1.0.0 version: 0.1.0.0
...@@ -42,5 +42,6 @@ library ...@@ -42,5 +42,6 @@ library
Data.Graph.Clustering.Example Data.Graph.Clustering.Example
Data.Graph.Clustering.FLouvain Data.Graph.Clustering.FLouvain
Data.Graph.Clustering.HLouvain Data.Graph.Clustering.HLouvain
Data.Graph.Clustering.ILouvain
Paths_clustering_louvain Paths_clustering_louvain
default-language: Haskell2010 default-language: Haskell2010
{-|
Module : Data.Graph.Clustering.ILouvain
Description : Purely functional (Inductive) Louvain clustering
Copyright : (c) Alexandre Delanoë, CNRS, 2020-Present
License : AGPL + CECILL v3
Maintainer : alexandre.delanoe+louvain@iscpif.fr
Stability : experimental
Portability : POSIX
ILouvain: really inductive Graph
-}
{-# LANGUAGE ConstrainedClassMethods #-}
{-# LANGUAGE FlexibleInstances #-}
{-# LANGUAGE InstanceSigs #-}
{-# LANGUAGE NoImplicitPrelude #-}
module Data.Graph.Clustering.ILouvain
where
import Data.List (zip, cycle)
import Protolude hiding (empty)
import Data.Graph.Inductive
------------------------------------------------------------------------
-- Recursive Graph
data RGraph = Empty | Gr [RGraph] Double
deriving (Show, Eq)
------------------------------------------------------------------------
-- Spoon Graph
-- 1
-- / \
-- 2 3
-- \ /
-- 4
-- |
-- 5
ns :: [LNode RGraph]
ns = zip [1..6] (cycle [Empty])
es :: [LEdge Double]
es = [ (1, 2, 1.0)
, (1, 3, 1.0)
, (2, 4, 1.0)
, (3, 4, 1.0)
, (4, 5, 1.0)
]
spoon :: Gr RGraph Double
spoon = mkGraph ns es
------------------------------------------------------------------------
------------------------------------------------------------------------
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment