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
51818eb6
Commit
51818eb6
authored
Jan 08, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Graph] edgeWeight selector by edge weight index in sorted list
parent
98d0e992
Changes
5
Show whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
35 additions
and
23 deletions
+35
-23
GraphExplorer.purs
src/Gargantext/Components/GraphExplorer.purs
+16
-14
Controls.purs
src/Gargantext/Components/GraphExplorer/Controls.purs
+13
-5
RangeControl.purs
src/Gargantext/Components/GraphExplorer/RangeControl.purs
+1
-1
Types.purs
src/Gargantext/Components/GraphExplorer/Types.purs
+2
-2
Types.purs
src/Gargantext/Hooks/Sigmax/Types.purs
+3
-1
No files found.
src/Gargantext/Components/GraphExplorer.purs
View file @
51818eb6
...
...
@@ -2,8 +2,7 @@ module Gargantext.Components.GraphExplorer where
import Gargantext.Prelude hiding (max,min)
import DOM.Simple.Types (Element)
import Data.Foldable (foldMap)
import Data.Array as A
import Data.FoldableWithIndex (foldMapWithIndex)
import Data.Int (toNumber)
import Data.Map as Map
...
...
@@ -13,6 +12,7 @@ import Data.Sequence as Seq
import Data.Set as Set
import Data.Tuple (fst, snd, Tuple(..))
import Data.Tuple.Nested ((/\))
import DOM.Simple.Types (Element)
import Effect.Aff (Aff)
import Math (log)
import Partial.Unsafe (unsafePartial)
...
...
@@ -251,8 +251,8 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxTypes.Graph {nodes, edges}
color = GET.intColor (cDef n.attributes)
gargType = unsafePartial $ fromJust $ Types.modeFromString n.type_
nodesMap = SigmaxTypes.nodesMap nodes
edges = foldMap
edgeFn
r.edges
edgeFn (GET.Edge e) = Seq.singleton { id : e.id_
edges = foldMap
WithIndex edgeFn $ A.sortWith (\(GET.Edge {weight}) -> weight)
r.edges
edgeFn
i
(GET.Edge e) = Seq.singleton { id : e.id_
, color
, confluence : e.confluence
, hidden : false
...
...
@@ -261,7 +261,9 @@ convert (GET.GraphData r) = Tuple r.metaData $ SigmaxTypes.Graph {nodes, edges}
, sourceNode
, target : e.target
, targetNode
, weight : e.weight }
, weight : e.weight
, weightIdx: i
}
where
sourceNode = unsafePartial $ fromJust $ Map.lookup e.source nodesMap
targetNode = unsafePartial $ fromJust $ Map.lookup e.target nodesMap
...
...
@@ -325,7 +327,7 @@ transformGraph controls graph = SigmaxTypes.Graph {nodes: newNodes, edges: newEd
-- else
-- edge { hidden = true }
edgeWeightFilter :: Record SigmaxTypes.Edge -> Boolean
edgeWeightFilter edge@{ weight
} = Range.within (fst controls.edgeWeight) weight
edgeWeightFilter edge@{ weight
Idx } = Range.within (fst controls.edgeWeight) $ toNumber weightIdx
edgeInGraph :: SigmaxTypes.SelectedNodeIds -> Record SigmaxTypes.Edge -> Boolean
edgeInGraph nodeIds e = (Set.member e.source nodeIds) && (Set.member e.target nodeIds)
...
...
src/Gargantext/Components/GraphExplorer/Controls.purs
View file @
51818eb6
...
...
@@ -8,6 +8,7 @@ module Gargantext.Components.GraphExplorer.Controls
) where
import Data.Array as A
import Data.Int as I
import Data.Maybe (Maybe(..), maybe)
import Data.Sequence as Seq
import Data.Set as Set
...
...
@@ -116,10 +117,14 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
let edgeConfluenceMax = maybe 100.0 _.confluence $ A.last edgesConfluenceSorted
let edgeConfluenceRange = Range.Closed { min: edgeConfluenceMin, max: edgeConfluenceMax }
let edgesWeightSorted = A.sortWith (_.weight) $ Seq.toUnfoldable $ SigmaxTypes.graphEdges props.graph
let edgeWeightMin = maybe 0.0 _.weight $ A.head edgesWeightSorted
let edgeWeightMax = maybe 100.0 _.weight $ A.last edgesWeightSorted
let edgeWeightRange = Range.Closed { min: edgeWeightMin, max: edgeWeightMax }
--let edgesWeightSorted = A.sortWith (_.weight) $ Seq.toUnfoldable $ SigmaxTypes.graphEdges props.graph
--let edgeWeightMin = maybe 0.0 _.weight $ A.head edgesWeightSorted
--let edgeWeightMax = maybe 100.0 _.weight $ A.last edgesWeightSorted
--let edgeWeightRange = Range.Closed { min: edgeWeightMin, max: edgeWeightMax }
let edgeWeightRange = Range.Closed {
min: 0.0
, max: I.toNumber $ Seq.length $ SigmaxTypes.graphEdges props.graph
}
let nodesSorted = A.sortWith (_.size) $ Seq.toUnfoldable $ SigmaxTypes.graphNodes props.graph
let nodeSizeMin = maybe 0.0 _.size $ A.head nodesSorted
...
...
@@ -159,7 +164,10 @@ controlsCpt = R.hooksComponent "GraphControls" cpt
useGraphControls :: SigmaxTypes.SGraph -> R.Hooks (Record Controls)
useGraphControls graph = do
edgeConfluence <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 }
edgeWeight <- R.useState' $ Range.Closed { min: 0.0, max: 1.0 }
edgeWeight <- R.useState' $ Range.Closed {
min: 0.0
, max: I.toNumber $ Seq.length $ SigmaxTypes.graphEdges graph
}
forceAtlasState <- R.useState' SigmaxTypes.InitialRunning
graphStage <- R.useState' Graph.Init
multiSelectEnabled <- R.useState' false
...
...
src/Gargantext/Components/GraphExplorer/RangeControl.purs
View file @
51818eb6
...
...
@@ -54,7 +54,7 @@ edgeWeightControl (Range.Closed { min, max }) (state /\ setState) =
, sliderProps: {
bounds: Range.Closed { min, max }
, initialValue: state
, epsilon:
0.01
, epsilon:
1.0
, step: 1.0
, width: 10.0
, height: 5.0
...
...
src/Gargantext/Components/GraphExplorer/Types.purs
View file @
51818eb6
...
...
@@ -24,11 +24,11 @@ newtype Cluster = Cluster { clustDefault :: Int }
derive instance newtypeCluster :: Newtype Cluster _
newtype Edge = Edge
{ id_ :: String
{ confluence :: Number
, id_ :: String
, source :: String
, target :: String
, weight :: Number
, confluence :: Number
}
derive instance newtypeEdge :: Newtype Edge _
...
...
src/Gargantext/Hooks/Sigmax/Types.purs
View file @
51818eb6
...
...
@@ -53,7 +53,9 @@ type Edge =
, sourceNode :: Record Node
, target :: NodeId
, targetNode :: Record Node
, weight :: Number )
, weight :: Number
, weightIdx :: Int
)
type SelectedNodeIds = Set.Set NodeId
type SelectedEdgeIds = Set.Set EdgeId
...
...
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