]> Git — Sourcephile - gargantext.git/blob - src/Gargantext/Viz/Graph/Distances.hs
Merge branch 'dev-list-charts' into dev-doc-table-optimization
[gargantext.git] / src / Gargantext / Viz / Graph / Distances.hs
1 {-|
2 Module : Gargantext.Graph.Distances
3 Description : Distance management tools
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 Strict #-}
13
14 module Gargantext.Viz.Graph.Distances
15 where
16
17 import Data.Aeson
18 import Data.Array.Accelerate (Matrix)
19 import Data.Swagger
20 import GHC.Generics (Generic)
21 import Gargantext.Prelude (Ord, Eq, Int, Double)
22 import Gargantext.Prelude (Show)
23 import Gargantext.Viz.Graph.Distances.Matrice (measureConditional, distributional)
24 import Prelude (Enum, Bounded, minBound, maxBound)
25 import Test.QuickCheck (elements)
26 import Test.QuickCheck.Arbitrary
27
28 ------------------------------------------------------------------------
29 data Distance = Conditional | Distributional
30
31 measure :: Distance -> Matrix Int -> Matrix Double
32 measure Conditional = measureConditional
33 measure Distributional = distributional
34 ------------------------------------------------------------------------
35
36 withMetric :: GraphMetric -> Matrix Int -> Matrix Double
37 withMetric Order1 = measureConditional
38 withMetric Order2 = distributional
39
40 ------------------------------------------------------------------------
41 data GraphMetric = Order1 | Order2
42 deriving (Generic, Eq, Ord, Enum, Bounded, Show)
43
44 instance FromJSON GraphMetric
45 instance ToJSON GraphMetric
46 instance ToSchema GraphMetric
47 instance Arbitrary GraphMetric where
48 arbitrary = elements [ minBound .. maxBound ]
49
50 ------------------------------------------------------------------------