Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
haskell-gargantext
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
148
Issues
148
List
Board
Labels
Milestones
Merge Requests
7
Merge Requests
7
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
gargantext
haskell-gargantext
Commits
797ae29e
Commit
797ae29e
authored
Oct 12, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[CLEAN] Code
parent
151b54d0
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
24 deletions
+22
-24
Graph.hs
src/Gargantext/Core/Viz/Graph.hs
+3
-3
Tools.hs
src/Gargantext/Core/Viz/Graph/Tools.hs
+19
-21
No files found.
src/Gargantext/Core/Viz/Graph.hs
View file @
797ae29e
...
...
@@ -45,7 +45,7 @@ $(deriveJSON (unPrefix "") ''Attributes)
instance
ToSchema
Attributes
data
Node
=
Node
{
node_size
::
Int
,
node_type
::
TypeNode
-- TODO NgramsType | Person
,
node_type
::
NgramsType
--
TypeNode -- TODO NgramsType | Person
,
node_id
::
Text
-- TODO NgramId
,
node_label
::
Text
,
node_x_coord
::
Double
...
...
@@ -171,7 +171,7 @@ instance Arbitrary Graph where
arbitrary
=
elements
$
[
defaultGraph
]
defaultGraph
::
Graph
defaultGraph
=
Graph
{
_graph_nodes
=
[
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
4
,
node_type
=
Terms
,
node_id
=
pack
"0"
,
node_label
=
pack
"animal"
,
node_attributes
=
Attributes
{
clust_default
=
0
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
3
,
node_type
=
Terms
,
node_id
=
pack
"1"
,
node_label
=
pack
"bird"
,
node_attributes
=
Attributes
{
clust_default
=
0
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
2
,
node_type
=
Terms
,
node_id
=
pack
"2"
,
node_label
=
pack
"boy"
,
node_attributes
=
Attributes
{
clust_default
=
1
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
2
,
node_type
=
Terms
,
node_id
=
pack
"3"
,
node_label
=
pack
"dog"
,
node_attributes
=
Attributes
{
clust_default
=
0
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
2
,
node_type
=
Terms
,
node_id
=
pack
"4"
,
node_label
=
pack
"girl"
,
node_attributes
=
Attributes
{
clust_default
=
1
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
4
,
node_type
=
Terms
,
node_id
=
pack
"5"
,
node_label
=
pack
"human body"
,
node_attributes
=
Attributes
{
clust_default
=
1
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
3
,
node_type
=
Terms
,
node_id
=
pack
"6"
,
node_label
=
pack
"object"
,
node_attributes
=
Attributes
{
clust_default
=
2
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
2
,
node_type
=
Terms
,
node_id
=
pack
"7"
,
node_label
=
pack
"pen"
,
node_attributes
=
Attributes
{
clust_default
=
2
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
2
,
node_type
=
Terms
,
node_id
=
pack
"8"
,
node_label
=
pack
"table"
,
node_attributes
=
Attributes
{
clust_default
=
2
},
node_children
=
[]
}],
_graph_edges
=
[
Edge
{
edge_source
=
pack
"0"
,
edge_target
=
pack
"0"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"0"
},
Edge
{
edge_source
=
pack
"1"
,
edge_target
=
pack
"0"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"1"
},
Edge
{
edge_source
=
pack
"1"
,
edge_target
=
pack
"1"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"2"
},
Edge
{
edge_source
=
pack
"2"
,
edge_target
=
pack
"2"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"3"
},
Edge
{
edge_source
=
pack
"2"
,
edge_target
=
pack
"5"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"4"
},
Edge
{
edge_source
=
pack
"3"
,
edge_target
=
pack
"0"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"5"
},
Edge
{
edge_source
=
pack
"3"
,
edge_target
=
pack
"1"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"6"
},
Edge
{
edge_source
=
pack
"3"
,
edge_target
=
pack
"3"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"7"
},
Edge
{
edge_source
=
pack
"4"
,
edge_target
=
pack
"4"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"8"
},
Edge
{
edge_source
=
pack
"4"
,
edge_target
=
pack
"5"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"9"
},
Edge
{
edge_source
=
pack
"5"
,
edge_target
=
pack
"5"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"10"
},
Edge
{
edge_source
=
pack
"6"
,
edge_target
=
pack
"6"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"11"
},
Edge
{
edge_source
=
pack
"7"
,
edge_target
=
pack
"6"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"12"
},
Edge
{
edge_source
=
pack
"7"
,
edge_target
=
pack
"7"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"13"
},
Edge
{
edge_source
=
pack
"8"
,
edge_target
=
pack
"6"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"14"
},
Edge
{
edge_source
=
pack
"8"
,
edge_target
=
pack
"7"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"15"
},
Edge
{
edge_source
=
pack
"8"
,
edge_target
=
pack
"8"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"16"
}],
_graph_metadata
=
Nothing
}
defaultGraph
=
Graph
{
_graph_nodes
=
[
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
4
,
node_type
=
NgramsTerms
,
node_id
=
pack
"0"
,
node_label
=
pack
"animal"
,
node_attributes
=
Attributes
{
clust_default
=
0
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
3
,
node_type
=
NgramsTerms
,
node_id
=
pack
"1"
,
node_label
=
pack
"bird"
,
node_attributes
=
Attributes
{
clust_default
=
0
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
2
,
node_type
=
NgramsTerms
,
node_id
=
pack
"2"
,
node_label
=
pack
"boy"
,
node_attributes
=
Attributes
{
clust_default
=
1
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
2
,
node_type
=
NgramsTerms
,
node_id
=
pack
"3"
,
node_label
=
pack
"dog"
,
node_attributes
=
Attributes
{
clust_default
=
0
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
2
,
node_type
=
NgramsTerms
,
node_id
=
pack
"4"
,
node_label
=
pack
"girl"
,
node_attributes
=
Attributes
{
clust_default
=
1
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
4
,
node_type
=
NgramsTerms
,
node_id
=
pack
"5"
,
node_label
=
pack
"human body"
,
node_attributes
=
Attributes
{
clust_default
=
1
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
3
,
node_type
=
NgramsTerms
,
node_id
=
pack
"6"
,
node_label
=
pack
"object"
,
node_attributes
=
Attributes
{
clust_default
=
2
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
2
,
node_type
=
NgramsTerms
,
node_id
=
pack
"7"
,
node_label
=
pack
"pen"
,
node_attributes
=
Attributes
{
clust_default
=
2
},
node_children
=
[]
},
Node
{
node_x_coord
=
0
,
node_y_coord
=
0
,
node_size
=
2
,
node_type
=
Ngrams
Terms
,
node_id
=
pack
"8"
,
node_label
=
pack
"table"
,
node_attributes
=
Attributes
{
clust_default
=
2
},
node_children
=
[]
}],
_graph_edges
=
[
Edge
{
edge_source
=
pack
"0"
,
edge_target
=
pack
"0"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"0"
},
Edge
{
edge_source
=
pack
"1"
,
edge_target
=
pack
"0"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"1"
},
Edge
{
edge_source
=
pack
"1"
,
edge_target
=
pack
"1"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"2"
},
Edge
{
edge_source
=
pack
"2"
,
edge_target
=
pack
"2"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"3"
},
Edge
{
edge_source
=
pack
"2"
,
edge_target
=
pack
"5"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"4"
},
Edge
{
edge_source
=
pack
"3"
,
edge_target
=
pack
"0"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"5"
},
Edge
{
edge_source
=
pack
"3"
,
edge_target
=
pack
"1"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"6"
},
Edge
{
edge_source
=
pack
"3"
,
edge_target
=
pack
"3"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"7"
},
Edge
{
edge_source
=
pack
"4"
,
edge_target
=
pack
"4"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"8"
},
Edge
{
edge_source
=
pack
"4"
,
edge_target
=
pack
"5"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"9"
},
Edge
{
edge_source
=
pack
"5"
,
edge_target
=
pack
"5"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"10"
},
Edge
{
edge_source
=
pack
"6"
,
edge_target
=
pack
"6"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"11"
},
Edge
{
edge_source
=
pack
"7"
,
edge_target
=
pack
"6"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"12"
},
Edge
{
edge_source
=
pack
"7"
,
edge_target
=
pack
"7"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"13"
},
Edge
{
edge_source
=
pack
"8"
,
edge_target
=
pack
"6"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"14"
},
Edge
{
edge_source
=
pack
"8"
,
edge_target
=
pack
"7"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"15"
},
Edge
{
edge_source
=
pack
"8"
,
edge_target
=
pack
"8"
,
edge_weight
=
1.0
,
edge_confluence
=
0.5
,
edge_id
=
pack
"16"
}],
_graph_metadata
=
Nothing
}
-----------------------------------------------------------
...
...
@@ -263,7 +263,7 @@ graphV3ToGraph (GraphV3 links nodes) = Graph { _graph_nodes = map nodeV32node no
nodeV32node
::
NodeV3
->
Node
nodeV32node
(
NodeV3
no_id'
(
AttributesV3
cl'
)
no_s'
no_lb'
)
=
Node
{
node_size
=
no_s'
,
node_type
=
Terms
,
node_type
=
Ngrams
Terms
,
node_id
=
cs
$
show
no_id'
,
node_label
=
no_lb'
,
node_x_coord
=
0
...
...
src/Gargantext/Core/Viz/Graph/Tools.hs
View file @
797ae29e
...
...
@@ -188,18 +188,13 @@ doSimilarityMap Conditional threshold strength myCooc = (distanceMap, toIndex ti
----------------------------------------------------------
-- | From data to Graph
type
Occurrences
=
Int
multiPartiteWith
::
MultiPartite
->
NgramsTerm
->
TypeNod
e
multiPartiteWith
(
MultiPartite
(
Partite
s1
t1
)
(
Partite
_s2
t2
))
t
=
nodeTypeWith
::
MultiPartite
->
NgramsTerm
->
NgramsTyp
e
nodeTypeWith
(
MultiPartite
(
Partite
s1
t1
)
(
Partite
_s2
t2
))
t
=
if
HashSet
.
member
t
s1
then
typeNode
t1
else
typeNode
t2
typeNode
::
NgramsType
->
TypeNode
typeNode
NgramsTerms
=
Terms
typeNode
_
=
Unknown
then
t1
else
t2
data2graph
::
ToComId
a
...
...
@@ -210,26 +205,29 @@ data2graph :: ToComId a
->
Map
(
Int
,
Int
)
Double
->
[
a
]
->
Graph
data2graph
multi
labels'
occurences
bridge
conf
partitions
=
Graph
{
_graph_nodes
=
nodes
,
_graph_edges
=
edges
,
_graph_metadata
=
Nothing
}
where
data2graph
multi
labels'
occurences
bridge
conf
partitions
=
Graph
{
_graph_nodes
=
nodes
,
_graph_edges
=
edges
,
_graph_metadata
=
Nothing
}
where
nodes
=
map
(
setCoord
ForceAtlas
labels
bridge
)
[
(
n
,
Node
{
node_size
=
maybe
0
identity
(
Map
.
lookup
(
n
,
n
)
occurences
)
,
node_type
=
multiPartiteWith
multi
l
,
node_id
=
cs
(
show
n
)
,
node_label
=
unNgramsTerm
l
,
node_type
=
nodeTypeWith
multi
labe
l
,
node_id
=
(
cs
.
show
)
n
,
node_label
=
unNgramsTerm
l
abel
,
node_x_coord
=
0
,
node_y_coord
=
0
,
node_attributes
=
Attributes
{
clust_default
=
fromMaybe
0
(
Map
.
lookup
n
community_id_by_node_id
)
}
,
node_attributes
=
Attributes
{
clust_default
=
fromMaybe
0
(
Map
.
lookup
n
community_id_by_node_id
)
}
,
node_children
=
[]
}
)
|
(
l
,
n
)
<-
labels
|
(
l
abel
,
n
)
<-
labels
,
Set
.
member
n
toKeep
]
...
...
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