Commit 3b72b59b authored by Przemyslaw Kaminski's avatar Przemyslaw Kaminski

[sigma] attempt at fixing sigmaDiff (not compiling yet)

parent 2fa0f2d8
......@@ -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 $
......
......@@ -88,8 +88,8 @@ cameraButton { id
, show $ fromEnum $ DDT.hour nowt
, show $ fromEnum $ DDT.minute nowt
, show $ fromEnum $ DDT.second nowt ]
edges <- Sigmax.getEdges s
nodes <- Sigmax.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
......
......@@ -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
......@@ -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
......
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