Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
P
purescript-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
Grégoire Locqueville
purescript-gargantext
Commits
3b72b59b
Commit
3b72b59b
authored
Sep 29, 2022
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[sigma] attempt at fixing sigmaDiff (not compiling yet)
parent
2fa0f2d8
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
33 additions
and
25 deletions
+33
-25
Layout.purs
src/Gargantext/Components/GraphExplorer/Layout.purs
+5
-0
Buttons.purs
src/Gargantext/Components/GraphExplorer/Toolbar/Buttons.purs
+2
-2
Sigmax.purs
src/Gargantext/Hooks/Sigmax.purs
+25
-9
Types.purs
src/Gargantext/Hooks/Sigmax/Types.purs
+1
-14
No files found.
src/Gargantext/Components/GraphExplorer/Layout.purs
View file @
3b72b59b
...
...
@@ -265,6 +265,11 @@ graphViewCpt = R.memo' $ here.component "graphView" cpt where
, selectedNodeIds'
, showEdges' }
R.useEffect' $ do
here.log2 "[graphView] selectedNodeIds'" $ A.fromFoldable selectedNodeIds'
let (SigmaxT.Graph { nodes: n }) = transformedGraph
here.log2 "[graphView] transformedGraph nodes" $ A.fromFoldable n
-- | Render
-- |
pure $
...
...
src/Gargantext/Components/GraphExplorer/Toolbar/Buttons.purs
View file @
3b72b59b
...
...
@@ -88,8 +88,8 @@ cameraButton { id
, show $ fromEnum $ DDT.hour nowt
, show $ fromEnum $ DDT.minute nowt
, show $ fromEnum $ DDT.second nowt ]
edges <- Sigma
x
.getEdges s
nodes <- Sigma
x
.getNodes s
edges <- Sigma.getEdges s
nodes <- Sigma.getNodes s
let graphData = GET.GraphData $ hyperdataGraph { edges = map GEU.stEdgeToGET edges
, nodes = GEU.normalizeNodes $ map GEU.stNodeToGET nodes }
let cameras = map Sigma.toCamera $ Sigma.cameras s
...
...
src/Gargantext/Hooks/Sigmax.purs
View file @
3b72b59b
...
...
@@ -234,9 +234,31 @@ performDiff sigma g = do
--Sigma.killForceAtlas2 sigma
where
sigmaGraph = Sigma.graph sigma
sigmaEdgeIds = Graphology.edgeIds sigmaGraph
sigmaNodeIds = Graphology.nodeIds sigmaGraph
{add: Tuple addEdges addNodes, remove: Tuple removeEdges removeNodes} = ST.sigmaDiff sigmaEdgeIds sigmaNodeIds g
{add: Tuple addEdges addNodes, remove: Tuple removeEdges removeNodes} = sigmaDiff sigmaGraph g
-- | Compute a diff between current sigma graph and whatever is set via custom controls
sigmaDiff :: Graphology.Graph -> ST.Graph -> Record ST.SigmaDiff
sigmaDiff graph g@(ST.Graph {nodes, edges}) = {add, remove, update}
where
add = Tuple addEdges addNodes
remove = Tuple removeEdges removeNodes
-- TODO
update = Tuple Seq.empty Seq.empty
addG = ST.edgesFilter (\e -> not (Set.member e.id sigmaEdgeIds)) $
ST.nodesFilter (\n -> not (Set.member n.id sigmaNodeIds)) g
addEdges = ST.graphEdges addG
addNodes = ST.graphNodes addG
removeEdges = Set.difference sigmaEdgeIds (Set.fromFoldable $ Seq.map _.id edges)
removeNodes = Set.difference sigmaNodeIds (Set.fromFoldable $ Seq.map _.id nodes)
sigmaNodeIds = Graphology.nodeIds graph
sigmaEdgeIds = Graphology.edgeIds graph
-- DEPRECATED
markSelectedEdges :: Sigma.Sigma -> ST.EdgeIds -> ST.EdgesMap -> Effect Unit
...
...
@@ -268,9 +290,3 @@ markSelectedNodes sigma selectedNodeIds graphNodes = do
_ <- pure $ (n .= "color") newColor
pure unit
Sigma.refresh sigma
getEdges :: Sigma.Sigma -> Effect (Array (Record ST.Edge))
getEdges sigma = Sigma.getEdges sigma
getNodes :: Sigma.Sigma -> Effect (Array (Record ST.Node))
getNodes sigma = Sigma.getNodes sigma
src/Gargantext/Hooks/Sigmax/Types.purs
View file @
3b72b59b
...
...
@@ -84,6 +84,7 @@ type SigmaDiff =
(
add :: Tuple (Seq.Seq (Record Edge)) (Seq.Seq (Record Node))
, remove :: Tuple EdgeIds NodeIds
, update :: Tuple (Seq.Seq (Record Edge)) (Seq.Seq (Record Node))
)
graphEdges :: SGraph -> Seq.Seq (Record Edge)
...
...
@@ -124,20 +125,6 @@ sub graph (Graph {nodes, edges}) = newGraph
filteredEdges = edgesFilter edgeFilterFunc graph
newGraph = nodesFilter (\n -> not (Set.member n.id nodeIds)) filteredEdges
-- | Compute a diff between current sigma graph and whatever is set via customer controls
sigmaDiff :: EdgeIds -> NodeIds -> SGraph -> Record SigmaDiff
sigmaDiff sigmaEdges sigmaNodes g@(Graph {nodes, edges}) = {add, remove}
where
add = Tuple addEdges addNodes
remove = Tuple removeEdges removeNodes
addG = edgesFilter (\e -> not (Set.member e.id sigmaEdges)) $ nodesFilter (\n -> not (Set.member n.id sigmaNodes)) g
addEdges = graphEdges addG
addNodes = graphNodes addG
removeEdges = Set.difference sigmaEdges (Set.fromFoldable $ Seq.map _.id edges)
removeNodes = Set.difference sigmaNodes (Set.fromFoldable $ Seq.map _.id nodes)
neighbours :: SGraph -> Seq.Seq (Record Node) -> Seq.Seq (Record Node)
neighbours g nodes = Seq.fromFoldable $ Set.unions [Set.fromFoldable nodes, sources, targets]
where
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment