Commit 3fc98251 authored by Karen Konou's avatar Karen Konou

[Graph] Add more parameters to metadata

parent f4097d0a
Pipeline #7013 failed with stages
in 65 minutes and 33 seconds
...@@ -5,8 +5,7 @@ import Data.Aeson ...@@ -5,8 +5,7 @@ import Data.Aeson
import Data.Swagger ( ToSchema ) import Data.Swagger ( ToSchema )
import Gargantext.Core.Methods.Similarities (GraphMetric(..)) import Gargantext.Core.Methods.Similarities (GraphMetric(..))
import Gargantext.Core.Text.Ngrams (NgramsType) import Gargantext.Core.Text.Ngrams (NgramsType)
import Gargantext.Core.Viz.Graph.Tools (PartitionMethod(..), BridgenessMethod(..)) import Gargantext.Core.Viz.Graph.Types (Strength, PartitionMethod(..), BridgenessMethod(..))
import Gargantext.Core.Viz.Graph.Types (Strength)
import Gargantext.Core.Viz.Phylo (PhyloSubConfigAPI(..)) import Gargantext.Core.Viz.Phylo (PhyloSubConfigAPI(..))
import Gargantext.Database.Admin.Types.Node ( NodeId, NodeType ) import Gargantext.Database.Admin.Types.Node ( NodeId, NodeType )
import Gargantext.Prelude import Gargantext.Prelude
......
...@@ -75,7 +75,7 @@ getGraph nId = do ...@@ -75,7 +75,7 @@ getGraph nId = do
let defaultEdgesStrength = Strong let defaultEdgesStrength = Strong
let defaultBridgenessMethod = BridgenessMethod_Basic let defaultBridgenessMethod = BridgenessMethod_Basic
graph' <- computeGraph cId defaultPartitionMethod defaultBridgenessMethod (withMetric defaultMetric) defaultEdgesStrength (NgramsTerms, NgramsTerms) repo graph' <- computeGraph cId defaultPartitionMethod defaultBridgenessMethod (withMetric defaultMetric) defaultEdgesStrength (NgramsTerms, NgramsTerms) repo
mt <- defaultGraphMetadata cId listId "Title" repo defaultMetric defaultEdgesStrength mt <- defaultGraphMetadata cId listId "Title" repo defaultMetric defaultEdgesStrength defaultPartitionMethod defaultBridgenessMethod
let mt' = set gm_legend (generateLegend graph') mt let mt' = set gm_legend (generateLegend graph') mt
let let
graph'' = set graph_metadata (Just mt') graph' graph'' = set graph_metadata (Just mt') graph'
...@@ -135,7 +135,7 @@ recomputeGraph nId partitionMethod bridgeMethod maybeSimilarity maybeStrength nt ...@@ -135,7 +135,7 @@ recomputeGraph nId partitionMethod bridgeMethod maybeSimilarity maybeStrength nt
case graph of case graph of
Nothing -> do Nothing -> do
mt <- defaultGraphMetadata cId listId "Title" repo (fromMaybe Order1 maybeSimilarity) strength mt <- defaultGraphMetadata cId listId "Title" repo (fromMaybe Order1 maybeSimilarity) strength partitionMethod bridgeMethod
g <- computeG mt g <- computeG mt
pure $ trace ("[G.V.G.API.recomputeGraph] Graph empty, computed" :: Text) g pure $ trace ("[G.V.G.API.recomputeGraph] Graph empty, computed" :: Text) g
Just graph' -> if (listVersion == Just v) && (not force') Just graph' -> if (listVersion == Just v) && (not force')
...@@ -143,7 +143,7 @@ recomputeGraph nId partitionMethod bridgeMethod maybeSimilarity maybeStrength nt ...@@ -143,7 +143,7 @@ recomputeGraph nId partitionMethod bridgeMethod maybeSimilarity maybeStrength nt
else do else do
case graphMetadata of case graphMetadata of
Nothing -> do Nothing -> do
mt <- defaultGraphMetadata cId listId "Title" repo (fromMaybe Order1 maybeSimilarity) strength mt <- defaultGraphMetadata cId listId "Title" repo (fromMaybe Order1 maybeSimilarity) strength partitionMethod bridgeMethod
g <- computeG mt g <- computeG mt
pure $ trace ("[G.V.G.API] Graph exists, no metadata, recomputing" :: Text) g pure $ trace ("[G.V.G.API] Graph exists, no metadata, recomputing" :: Text) g
Just mt -> do Just mt -> do
...@@ -204,12 +204,16 @@ defaultGraphMetadata :: HasNodeError err ...@@ -204,12 +204,16 @@ defaultGraphMetadata :: HasNodeError err
-> NodeListStory -> NodeListStory
-> GraphMetric -> GraphMetric
-> Strength -> Strength
-> PartitionMethod
-> BridgenessMethod
-> DBCmd err GraphMetadata -> DBCmd err GraphMetadata
defaultGraphMetadata cId lId t repo gm str = do defaultGraphMetadata cId lId t repo gm str pm bm = do
pure $ GraphMetadata { _gm_title = t pure $ GraphMetadata { _gm_title = t
, _gm_metric = gm , _gm_metric = gm
, _gm_edgesStrength = Just str , _gm_edgesStrength = Just str
, _gm_corpusId = [cId] , _gm_corpusId = [cId]
, _gm_partitionMethod = Just pm
, _gm_bridgenessMethod = Just bm
, _gm_legend = [ , _gm_legend = [
LegendField 1 "#FFF" "Cluster1" LegendField 1 "#FFF" "Cluster1"
, LegendField 2 "#FFF" "Cluster2" , LegendField 2 "#FFF" "Cluster2"
......
...@@ -23,7 +23,6 @@ import Data.HashSet qualified as HashSet ...@@ -23,7 +23,6 @@ import Data.HashSet qualified as HashSet
import Data.List qualified as List import Data.List qualified as List
import Data.Map.Strict qualified as Map import Data.Map.Strict qualified as Map
import Data.Set qualified as Set import Data.Set qualified as Set
import Data.Swagger ( ToSchema )
import Data.Text qualified as Text import Data.Text qualified as Text
import Data.Vector.Storable qualified as Vec import Data.Vector.Storable qualified as Vec
import Gargantext.API.Ngrams.Types (NgramsTerm(..)) import Gargantext.API.Ngrams.Types (NgramsTerm(..))
...@@ -34,7 +33,7 @@ import Gargantext.Core.Viz.Graph.Bridgeness (bridgeness, Bridgeness(..), Partiti ...@@ -34,7 +33,7 @@ import Gargantext.Core.Viz.Graph.Bridgeness (bridgeness, Bridgeness(..), Partiti
import Gargantext.Core.Viz.Graph.Index (createIndices, toIndex, map2mat, mat2map, Index, MatrixShape(..)) import Gargantext.Core.Viz.Graph.Index (createIndices, toIndex, map2mat, mat2map, Index, MatrixShape(..))
import Gargantext.Core.Viz.Graph.Tools.IGraph (mkGraphUfromEdges, spinglass, spinglass') import Gargantext.Core.Viz.Graph.Tools.IGraph (mkGraphUfromEdges, spinglass, spinglass')
import Gargantext.Core.Viz.Graph.Tools.Infomap (infomap) import Gargantext.Core.Viz.Graph.Tools.Infomap (infomap)
import Gargantext.Core.Viz.Graph.Types (Attributes(..), Edge(..), Graph(..), MultiPartite(..), Node(..), Partite(..), Strength(..), LegendField(..)) import Gargantext.Core.Viz.Graph.Types (Attributes(..), Edge(..), Graph(..), MultiPartite(..), Node(..), Partite(..), Strength(..), LegendField(..), BridgenessMethod(..), PartitionMethod(..))
import Gargantext.Core.Viz.Graph.Utils (edgesFilter, nodesFilter) import Gargantext.Core.Viz.Graph.Utils (edgesFilter, nodesFilter)
import Gargantext.Prelude import Gargantext.Prelude
import Graph.BAC.ProxemyOptim qualified as BAC import Graph.BAC.ProxemyOptim qualified as BAC
...@@ -42,25 +41,6 @@ import Graph.Types (ClusterNode) ...@@ -42,25 +41,6 @@ import Graph.Types (ClusterNode)
import IGraph qualified as Igraph import IGraph qualified as Igraph
import IGraph.Algorithms.Layout qualified as Layout import IGraph.Algorithms.Layout qualified as Layout
import IGraph.Random ( Gen ) -- (Gen(..)) import IGraph.Random ( Gen ) -- (Gen(..))
import Test.QuickCheck (elements)
import Test.QuickCheck.Arbitrary ( Arbitrary(arbitrary) )
data PartitionMethod = Spinglass | Confluence | Infomap
deriving (Generic, Eq, Ord, Enum, Bounded, Show)
instance FromJSON PartitionMethod
instance ToJSON PartitionMethod
instance ToSchema PartitionMethod
instance Arbitrary PartitionMethod where
arbitrary = elements [ minBound .. maxBound ]
data BridgenessMethod = BridgenessMethod_Basic | BridgenessMethod_Advanced
deriving (Generic, Eq, Ord, Enum, Bounded, Show)
instance FromJSON BridgenessMethod
instance ToJSON BridgenessMethod
instance ToSchema BridgenessMethod
instance Arbitrary BridgenessMethod where
arbitrary = elements [ minBound .. maxBound ]
------------------------------------------------------------- -------------------------------------------------------------
defaultClustering :: Map (Int, Int) Double -> IO [ClusterNode] defaultClustering :: Map (Int, Int) Double -> IO [ClusterNode]
......
...@@ -107,6 +107,23 @@ instance ToSchema MultiPartite where ...@@ -107,6 +107,23 @@ instance ToSchema MultiPartite where
declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_multipartite_") declareNamedSchema = genericDeclareNamedSchema (unPrefixSwagger "_multipartite_")
makeLenses ''MultiPartite makeLenses ''MultiPartite
---------------------------------------------------------------
data PartitionMethod = Spinglass | Confluence | Infomap
deriving (Generic, Eq, Ord, Enum, Bounded, Show)
instance FromJSON PartitionMethod
instance ToJSON PartitionMethod
instance ToSchema PartitionMethod
instance Arbitrary PartitionMethod where
arbitrary = elements [ minBound .. maxBound ]
data BridgenessMethod = BridgenessMethod_Basic | BridgenessMethod_Advanced
deriving (Generic, Eq, Ord, Enum, Bounded, Show)
instance FromJSON BridgenessMethod
instance ToJSON BridgenessMethod
instance ToSchema BridgenessMethod
instance Arbitrary BridgenessMethod where
arbitrary = elements [ minBound .. maxBound ]
--------------------------------------------------------------- ---------------------------------------------------------------
type Version = Int type Version = Int
...@@ -134,6 +151,8 @@ data GraphMetadata = ...@@ -134,6 +151,8 @@ data GraphMetadata =
GraphMetadata { _gm_title :: Text -- title of the graph GraphMetadata { _gm_title :: Text -- title of the graph
, _gm_metric :: GraphMetric , _gm_metric :: GraphMetric
, _gm_edgesStrength :: Maybe Strength , _gm_edgesStrength :: Maybe Strength
, _gm_partitionMethod :: Maybe PartitionMethod
, _gm_bridgenessMethod :: Maybe BridgenessMethod
, _gm_corpusId :: [NodeId] -- we can map with different corpus , _gm_corpusId :: [NodeId] -- we can map with different corpus
, _gm_legend :: [LegendField] -- legend of the Graph , _gm_legend :: [LegendField] -- legend of the Graph
, _gm_list :: ListForGraph , _gm_list :: ListForGraph
......
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