]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Viz/Graph.hs
Merge branch 'pipeline'
[gargantext.git] / src / Gargantext / Viz / Graph.hs
1 {-|
2 Module : Gargantext.Viz.Graph
3 Description :
4 Copyright : (c) CNRS, 2017-Present
5 License : AGPL + CECILL v3
6 Maintainer : team@gargantext.org
7 Stability : experimental
8 Portability : POSIX
9
10 -}
11
12 {-# LANGUAGE NoImplicitPrelude #-}
13 {-# LANGUAGE TemplateHaskell #-}
14 {-# LANGUAGE DeriveGeneric #-}
15
16 module Gargantext.Viz.Graph
17 where
18
19 import GHC.Generics (Generic)
20 import Data.Aeson.TH (deriveJSON)
21 import Data.Text (Text)
22 import Data.Map (Map)
23
24 import Gargantext.Prelude
25 import Gargantext.Core.Utils.Prefix (unPrefix)
26
27 import Data.Graph.Clustering.Louvain.CplusPlus (LouvainNode)
28
29
30 data TypeNode = Terms | Unknown
31 deriving (Show, Generic)
32
33 $(deriveJSON (unPrefix "") ''TypeNode)
34
35 data Attributes = Attributes { clust_default :: Int }
36 deriving (Show, Generic)
37 $(deriveJSON (unPrefix "") ''Attributes)
38
39 data Node = Node { n_size :: Int
40 , n_type :: TypeNode
41 , n_id :: Text
42 , n_label :: Text
43 , n_attributes :: Attributes
44 }
45 deriving (Show, Generic)
46 $(deriveJSON (unPrefix "n_") ''Node)
47
48 data Edge = Edge { e_source :: Int
49 , e_target :: Int
50 , e_weight :: Double
51 , e_id :: Int
52 }
53 deriving (Show, Generic)
54 $(deriveJSON (unPrefix "e_") ''Edge)
55
56 data Graph = Graph { g_nodes :: [Node]
57 , g_edges :: [Edge]
58 }
59 deriving (Show, Generic)
60 $(deriveJSON (unPrefix "g_") ''Graph)
61 -----------------------------------------------------------
62
63