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