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
12 {-# LANGUAGE Strict #-}
14 module Gargantext.Core.Methods.Distances
18 import Data.Array.Accelerate (Matrix)
20 import GHC.Generics (Generic)
21 import Gargantext.Core.Methods.Distances.Accelerate.Conditional (measureConditional)
22 import Gargantext.Core.Methods.Distances.Accelerate.Distributional (logDistributional)
23 import Gargantext.Prelude (Ord, Eq, Int, Double)
24 import Gargantext.Prelude (Show)
25 import Prelude (Enum, Bounded, minBound, maxBound)
26 import Test.QuickCheck (elements)
27 import Test.QuickCheck.Arbitrary
29 ------------------------------------------------------------------------
30 data Distance = Conditional | Distributional
33 measure :: Distance -> Matrix Int -> Matrix Double
34 measure Conditional = measureConditional
35 measure Distributional = logDistributional
37 ------------------------------------------------------------------------
38 withMetric :: GraphMetric -> Distance
39 withMetric Order1 = Conditional
40 withMetric Order2 = Distributional
42 ------------------------------------------------------------------------
43 data GraphMetric = Order1 | Order2
44 deriving (Generic, Eq, Ord, Enum, Bounded, Show)
46 instance FromJSON GraphMetric
47 instance ToJSON GraphMetric
48 instance ToSchema GraphMetric
49 instance Arbitrary GraphMetric where
50 arbitrary = elements [ minBound .. maxBound ]
52 ------------------------------------------------------------------------