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
195
Issues
195
List
Board
Labels
Milestones
Merge Requests
12
Merge Requests
12
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
668f5819
Commit
668f5819
authored
Dec 04, 2019
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[GRAPH] fix diag data.
parent
aa986303
Pipeline
#643
canceled with stage
Changes
2
Pipelines
1
Show whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
22 additions
and
15 deletions
+22
-15
API.hs
src/Gargantext/Viz/Graph/API.hs
+6
-4
Tools.hs
src/Gargantext/Viz/Graph/Tools.hs
+16
-11
No files found.
src/Gargantext/Viz/Graph/API.hs
View file @
668f5819
...
@@ -24,6 +24,7 @@ Portability : POSIX
...
@@ -24,6 +24,7 @@ Portability : POSIX
module
Gargantext.Viz.Graph.API
module
Gargantext.Viz.Graph.API
where
where
import
Debug.Trace
(
trace
)
import
Control.Lens
(
set
,
(
^.
),
_Just
,
(
^?
))
import
Control.Lens
(
set
,
(
^.
),
_Just
,
(
^?
))
import
Control.Monad.IO.Class
(
liftIO
)
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Maybe
(
Maybe
(
..
))
import
Data.Maybe
(
Maybe
(
..
))
...
@@ -106,11 +107,12 @@ computeGraph cId nt v = do
...
@@ -106,11 +107,12 @@ computeGraph cId nt v = do
lIds
<-
selectNodesWithUsername
NodeList
userMaster
lIds
<-
selectNodesWithUsername
NodeList
userMaster
ngs
<-
filterListWithRoot
GraphTerm
<$>
mapTermListRoot
[
lId
]
nt
ngs
<-
filterListWithRoot
GraphTerm
<$>
mapTermListRoot
[
lId
]
nt
myCooc
<-
Map
.
filter
(
>
1
)
<$>
getCoocByNgrams
(
Diagonal
False
)
myCooc
<-
Map
.
filter
(
>
1
)
<$>
getCoocByNgrams
(
Diagonal
True
)
<$>
groupNodesByNgrams
ngs
<$>
groupNodesByNgrams
ngs
<$>
getNodesByNgramsOnlyUser
cId
(
lIds
<>
[
lId
])
nt
(
Map
.
keys
ngs
)
<$>
getNodesByNgramsOnlyUser
cId
(
lIds
<>
[
lId
])
nt
(
Map
.
keys
ngs
)
graph
<-
liftIO
$
cooc2graph
0
myCooc
graph
<-
trace
(
show
myCooc
)
$
liftIO
$
cooc2graph
0
myCooc
let
graph'
=
set
graph_metadata
(
Just
metadata
)
graph
let
graph'
=
set
graph_metadata
(
Just
metadata
)
graph
pure
graph'
pure
graph'
...
...
src/Gargantext/Viz/Graph/Tools.hs
View file @
668f5819
...
@@ -35,15 +35,17 @@ import qualified Data.Vector.Storable as Vec
...
@@ -35,15 +35,17 @@ import qualified Data.Vector.Storable as Vec
import
qualified
Data.Map
as
Map
import
qualified
Data.Map
as
Map
import
qualified
Data.List
as
List
import
qualified
Data.List
as
List
type
Threshold
=
Int
type
Threshold
=
Double
cooc2graph
::
Threshold
->
(
Map
(
Text
,
Text
)
Int
)
->
IO
Graph
cooc2graph
::
Threshold
->
(
Map
(
Text
,
Text
)
Int
)
->
IO
Graph
cooc2graph
threshold
myCooc
=
do
cooc2graph
threshold
myCooc
=
do
let
(
ti
,
_
)
=
createIndices
myCooc
let
(
ti
,
_
)
=
createIndices
myCooc
myCooc'
=
toIndex
ti
myCooc
myCooc'
=
toIndex
ti
myCooc
matCooc
=
map2mat
(
0
)
(
Map
.
size
ti
)
$
Map
.
filter
(
>
threshold
)
myCooc'
matCooc
=
map2mat
0
(
Map
.
size
ti
)
$
Map
.
filter
(
>
(
round
threshold
)
)
myCooc'
distanceMat
=
measureConditional
matCooc
distanceMat
=
measureConditional
matCooc
distanceMap
=
Map
.
filter
(
>
0.01
)
$
mat2map
distanceMat
distanceMap
=
Map
.
filter
(
>
threshold
)
$
mat2map
distanceMat
partitions
<-
case
Map
.
size
distanceMap
>
0
of
partitions
<-
case
Map
.
size
distanceMap
>
0
of
True
->
cLouvain
distanceMap
True
->
cLouvain
distanceMap
...
@@ -57,7 +59,8 @@ cooc2graph threshold myCooc = do
...
@@ -57,7 +59,8 @@ cooc2graph threshold myCooc = do
----------------------------------------------------------
----------------------------------------------------------
-- | From data to Graph
-- | From data to Graph
data2graph
::
[(
Text
,
Int
)]
->
Map
(
Int
,
Int
)
Int
data2graph
::
[(
Text
,
Int
)]
->
Map
(
Int
,
Int
)
Int
->
Map
(
Int
,
Int
)
Double
->
Map
(
Int
,
Int
)
Double
->
Map
(
Int
,
Int
)
Double
->
Map
(
Int
,
Int
)
Double
->
[
LouvainNode
]
->
[
LouvainNode
]
...
@@ -83,9 +86,11 @@ data2graph labels coocs bridge conf partitions = do
...
@@ -83,9 +86,11 @@ data2graph labels coocs bridge conf partitions = do
let
edges
=
[
Edge
{
edge_source
=
cs
(
show
s
)
let
edges
=
[
Edge
{
edge_source
=
cs
(
show
s
)
,
edge_target
=
cs
(
show
t
)
,
edge_target
=
cs
(
show
t
)
,
edge_weight
=
d
,
edge_weight
=
d
,
edge_confluence
=
maybe
(
panic
"E: data2graph edges"
)
identity
$
Map
.
lookup
(
s
,
t
)
conf
,
edge_confluence
=
maybe
0
identity
$
Map
.
lookup
(
s
,
t
)
conf
-- , edge_confluence = maybe (panic "E: data2graph edges") identity $ Map.lookup (s,t) conf
,
edge_id
=
cs
(
show
i
)
}
,
edge_id
=
cs
(
show
i
)
}
|
(
i
,
((
s
,
t
),
d
))
<-
zip
([
0
..
]
::
[
Integer
])
(
Map
.
toList
bridge
)
]
|
(
i
,
((
s
,
t
),
d
))
<-
zip
([
0
..
]
::
[
Integer
])
(
Map
.
toList
bridge
),
s
/=
t
]
pure
$
Graph
nodes
edges
Nothing
pure
$
Graph
nodes
edges
Nothing
...
...
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