[graph] snapshot of graph works now

However, there is an issue that the snapshotted graph doesn't render
for some reason. (sigma.graph.nodes() is empty, why?)
parent d7efafab
...@@ -39,7 +39,7 @@ newtype Node = Node { ...@@ -39,7 +39,7 @@ newtype Node = Node {
, children :: Array String , children :: Array String
, id_ :: String , id_ :: String
, label :: String , label :: String
, size :: Number , size :: Int
, type_ :: String , type_ :: String
, x :: Number , x :: Number
, y :: Number , y :: Number
......
...@@ -5,7 +5,7 @@ import Gargantext.Prelude hiding (max, min) ...@@ -5,7 +5,7 @@ import Gargantext.Prelude hiding (max, min)
import DOM.Simple.Types (Element) import DOM.Simple.Types (Element)
import Data.Array as A import Data.Array as A
import Data.FoldableWithIndex (foldMapWithIndex) import Data.FoldableWithIndex (foldMapWithIndex)
import Data.Int (toNumber) import Data.Int (floor, toNumber)
import Data.Map as Map import Data.Map as Map
import Data.Maybe (Maybe(..), fromJust) import Data.Maybe (Maybe(..), fromJust)
import Data.Nullable (null, Nullable) import Data.Nullable (null, Nullable)
...@@ -200,6 +200,7 @@ layoutCpt = here.component "layout" cpt where ...@@ -200,6 +200,7 @@ layoutCpt = here.component "layout" cpt where
{ fa2Ref { fa2Ref
, noverlapRef , noverlapRef
, reloadForest: reloadForest , reloadForest: reloadForest
, session
, sigmaRef , sigmaRef
} }
] ]
...@@ -270,6 +271,8 @@ graphViewCpt = R.memo' $ here.component "graphView" cpt where ...@@ -270,6 +271,8 @@ graphViewCpt = R.memo' $ here.component "graphView" cpt where
-- todo Cache this? -- todo Cache this?
R.useEffect' $ do R.useEffect' $ do
here.log2 "[graphView] transformedGraph" $ transformGraph graph' transformParams
--let louvain = Louvain.louvain unit in --let louvain = Louvain.louvain unit in
--let cluster = Louvain.init louvain (SigmaxT.louvainNodes graph') (SigmaxT.louvainEdges graph') in --let cluster = Louvain.init louvain (SigmaxT.louvainNodes graph') (SigmaxT.louvainEdges graph') in
--SigmaxT.louvainGraph graph' cluster --SigmaxT.louvainGraph graph' cluster
...@@ -313,7 +316,8 @@ convert :: GET.GraphData -> Tuple (Maybe GET.MetaData) SigmaxT.SGraph ...@@ -313,7 +316,8 @@ convert :: GET.GraphData -> Tuple (Maybe GET.MetaData) SigmaxT.SGraph
convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges} convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges}
where where
normalizedNodes :: Array GEGT.Node normalizedNodes :: Array GEGT.Node
normalizedNodes = GEGT.Node <$> (GEU.normalizeNodeSizeDefault $ (\(GEGT.Node n) -> n) <$> r.nodes) normalizedNodes = (\n -> GEGT.Node (n { size = floor n.size })) <$>
(GEU.normalizeNodeSizeDefault $ (\(GEGT.Node n) -> n { size = toNumber n.size }) <$> r.nodes)
nodes :: Seq.Seq (Record SigmaxT.Node) nodes :: Seq.Seq (Record SigmaxT.Node)
nodes = foldMapWithIndex nodeFn normalizedNodes nodes = foldMapWithIndex nodeFn normalizedNodes
nodeFn :: Int -> GEGT.Node -> Seq.Seq (Record SigmaxT.Node) nodeFn :: Int -> GEGT.Node -> Seq.Seq (Record SigmaxT.Node)
...@@ -330,7 +334,7 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges} ...@@ -330,7 +334,7 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxT.Graph {nodes, edges}
, highlighted: false , highlighted: false
, id : n.id_ , id : n.id_
, label : n.label , label : n.label
, size : n.size , size : toNumber n.size
--, size: toNumber n.size --, size: toNumber n.size
, type : modeGraphType gargType , type : modeGraphType gargType
, x : n.x -- cos (toNumber i) , x : n.x -- cos (toNumber i)
......
...@@ -11,7 +11,7 @@ import Effect.Timer (setTimeout) ...@@ -11,7 +11,7 @@ import Effect.Timer (setTimeout)
import Gargantext.Components.Bootstrap as B import Gargantext.Components.Bootstrap as B
import Gargantext.Components.GraphExplorer.Resources as Graph import Gargantext.Components.GraphExplorer.Resources as Graph
import Gargantext.Components.GraphExplorer.Store as GraphStore import Gargantext.Components.GraphExplorer.Store as GraphStore
import Gargantext.Components.GraphExplorer.Toolbar.Buttons (centerButton, edgesToggleButton, louvainButton, pauseForceAtlasButton, pauseNoverlapButton, multiSelectEnabledButton) import Gargantext.Components.GraphExplorer.Toolbar.Buttons (cameraButton, centerButton, edgesToggleButton, louvainButton, pauseForceAtlasButton, pauseNoverlapButton, multiSelectEnabledButton)
import Gargantext.Components.GraphExplorer.Toolbar.RangeControl (edgeConfluenceControl, nodeSizeControl) import Gargantext.Components.GraphExplorer.Toolbar.RangeControl (edgeConfluenceControl, nodeSizeControl)
import Gargantext.Components.GraphExplorer.Toolbar.SlideButton (labelSizeButton, labelRenderedSizeThresholdButton, mouseSelectorSizeSlider) import Gargantext.Components.GraphExplorer.Toolbar.SlideButton (labelSizeButton, labelRenderedSizeThresholdButton, mouseSelectorSizeSlider)
import Gargantext.Components.GraphExplorer.Types as GET import Gargantext.Components.GraphExplorer.Types as GET
...@@ -20,6 +20,7 @@ import Gargantext.Hooks.Sigmax.Noverlap as Noverlap ...@@ -20,6 +20,7 @@ import Gargantext.Hooks.Sigmax.Noverlap as Noverlap
import Gargantext.Hooks.Sigmax as Sigmax import Gargantext.Hooks.Sigmax as Sigmax
import Gargantext.Hooks.Sigmax.Sigma as Sigma import Gargantext.Hooks.Sigmax.Sigma as Sigma
import Gargantext.Hooks.Sigmax.Types as SigmaxT import Gargantext.Hooks.Sigmax.Types as SigmaxT
import Gargantext.Sessions (Session)
import Gargantext.Types as GT import Gargantext.Types as GT
import Gargantext.Utils.Reactix as R2 import Gargantext.Utils.Reactix as R2
import Gargantext.Utils.Toestand as T2 import Gargantext.Utils.Toestand as T2
...@@ -34,6 +35,7 @@ type Controls = ...@@ -34,6 +35,7 @@ type Controls =
( fa2Ref :: R.Ref (Maybe ForceAtlas.FA2Layout) ( fa2Ref :: R.Ref (Maybe ForceAtlas.FA2Layout)
, noverlapRef :: R.Ref (Maybe Noverlap.NoverlapLayout) , noverlapRef :: R.Ref (Maybe Noverlap.NoverlapLayout)
, reloadForest :: T2.ReloadS , reloadForest :: T2.ReloadS
, session :: Session
, sigmaRef :: R.Ref Sigmax.Sigma , sigmaRef :: R.Ref Sigmax.Sigma
) )
...@@ -43,7 +45,8 @@ controlsCpt :: R.Memo Controls ...@@ -43,7 +45,8 @@ controlsCpt :: R.Memo Controls
controlsCpt = R.memo' $ here.component "controls" cpt where controlsCpt = R.memo' $ here.component "controls" cpt where
cpt { fa2Ref cpt { fa2Ref
, noverlapRef , noverlapRef
-- , reloadForest , reloadForest
, session
, sigmaRef , sigmaRef
} _ = do } _ = do
-- | States -- | States
...@@ -54,7 +57,9 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -54,7 +57,9 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, forceAtlasState , forceAtlasState
, noverlapState , noverlapState
, graph , graph
, graphId
, graphStage , graphStage
, hyperdataGraph
, labelRenderedSizeThreshold , labelRenderedSizeThreshold
, labelSize , labelSize
, mouseSelectorSize , mouseSelectorSize
...@@ -67,6 +72,8 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -67,6 +72,8 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, sideTab , sideTab
} <- GraphStore.use } <- GraphStore.use
graphId' <- R2.useLive' graphId
hyperdataGraph' <- R2.useLive' hyperdataGraph
forceAtlasState' <- R2.useLive' forceAtlasState forceAtlasState' <- R2.useLive' forceAtlasState
noverlapState' <- R2.useLive' noverlapState noverlapState' <- R2.useLive' noverlapState
graphStage' <- R2.useLive' graphStage graphStage' <- R2.useLive' graphStage
...@@ -169,16 +176,15 @@ controlsCpt = R.memo' $ here.component "controls" cpt where ...@@ -169,16 +176,15 @@ controlsCpt = R.memo' $ here.component "controls" cpt where
, pauseNoverlapButton { state: noverlapState } , pauseNoverlapButton { state: noverlapState }
, ,
gap gap
{- , ,
cameraButton cameraButton
{ id: graphId' { id: graphId'
, forceAtlasState , forceAtlasState
, hyperdataGraph: hyperdataGraph' , hyperdataGraph: hyperdataGraph'
, reloadForest , reloadForest
, session: session , session
, sigmaRef: sigmaRef , sigmaRef: sigmaRef
} }
-}
] ]
, ,
-- View Settings -- View Settings
......
...@@ -7,7 +7,7 @@ import louvain from 'graphology-communities-louvain'; ...@@ -7,7 +7,7 @@ import louvain from 'graphology-communities-louvain';
export function _assign(graph, options) { export function _assign(graph, options) {
louvain.assign(graph, { louvain.assign(graph, {
getEdgeWeight: 'weight', getEdgeWeight: 'weight',
resolution: 2 resolution: 0.8
}); });
return graph; return graph;
} }
...@@ -16,6 +16,7 @@ import Effect.Uncurried (EffectFn1, EffectFn2, EffectFn3, EffectFn4, runEffectFn ...@@ -16,6 +16,7 @@ import Effect.Uncurried (EffectFn1, EffectFn2, EffectFn3, EffectFn4, runEffectFn
import FFI.Simple ((..), (...), (.=)) import FFI.Simple ((..), (...), (.=))
import Gargantext.Data.Louvain as DLouvain import Gargantext.Data.Louvain as DLouvain
import Gargantext.Hooks.Sigmax.Graphology as Graphology import Gargantext.Hooks.Sigmax.Graphology as Graphology
import Gargantext.Hooks.Sigmax.Operators as Operators
import Gargantext.Hooks.Sigmax.Types as Types import Gargantext.Hooks.Sigmax.Types as Types
import Record as Record import Record as Record
...@@ -34,7 +35,7 @@ assignVisible :: forall settings. Graphology.Graph -> settings -> Effect Graphol ...@@ -34,7 +35,7 @@ assignVisible :: forall settings. Graphology.Graph -> settings -> Effect Graphol
assignVisible g s = do assignVisible g s = do
n <- Graphology.copy g n <- Graphology.copy g
Graphology.updateGraphOnlyVisible n Graphology.updateGraphOnlyVisible n
assign n s assign (Operators.toUndirected n) s
-- \[{ id, community }] -> { id: community } -- \[{ id, community }] -> { id: community }
cluster :: Graphology.Graph -> DLouvain.LouvainCluster cluster :: Graphology.Graph -> DLouvain.LouvainCluster
......
'use strict';
// https://graphology.github.io/standard-library/operators
import { toUndirected } from 'graphology-operators';
export function _toUndirected(graph) {
return toUndirected(graph);
}
module Gargantext.Hooks.Sigmax.Operators where
-- FFI for operators: https://graphology.github.io/standard-library/operators
import Prelude
import Data.Array as A
import Data.Function.Uncurried (Fn1, runFn1)
import Data.Map as Map
import Data.Sequence as Seq
import Data.Set as Set
import Data.Traversable (traverse)
import Data.Tuple (Tuple(..))
import Effect (Effect)
import Gargantext.Data.Louvain as DLouvain
import Gargantext.Hooks.Sigmax.Graphology as Graphology
import Gargantext.Hooks.Sigmax.Types as Types
import Record as Record
foreign import _toUndirected :: Fn1 Graphology.Graph Graphology.Graph
toUndirected :: Graphology.Graph -> Graphology.Graph
toUndirected = runFn1 _toUndirected
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