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
Hide 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
module
Gargantext.Viz.Graph.API
where
import
Debug.Trace
(
trace
)
import
Control.Lens
(
set
,
(
^.
),
_Just
,
(
^?
))
import
Control.Monad.IO.Class
(
liftIO
)
import
Data.Maybe
(
Maybe
(
..
))
...
...
@@ -106,11 +107,12 @@ computeGraph cId nt v = do
lIds
<-
selectNodesWithUsername
NodeList
userMaster
ngs
<-
filterListWithRoot
GraphTerm
<$>
mapTermListRoot
[
lId
]
nt
myCooc
<-
Map
.
filter
(
>
1
)
<$>
getCoocByNgrams
(
Diagonal
False
)
<$>
groupNodesByNgrams
ngs
<$>
getNodesByNgramsOnlyUser
cId
(
lIds
<>
[
lId
])
nt
(
Map
.
keys
ngs
)
myCooc
<-
Map
.
filter
(
>
1
)
<$>
getCoocByNgrams
(
Diagonal
True
)
<$>
groupNodesByNgrams
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
pure
graph'
...
...
src/Gargantext/Viz/Graph/Tools.hs
View file @
668f5819
...
...
@@ -35,15 +35,17 @@ import qualified Data.Vector.Storable as Vec
import
qualified
Data.Map
as
Map
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
let
(
ti
,
_
)
=
createIndices
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
distanceMap
=
Map
.
filter
(
>
0.01
)
$
mat2map
distanceMat
distanceMap
=
Map
.
filter
(
>
threshold
)
$
mat2map
distanceMat
partitions
<-
case
Map
.
size
distanceMap
>
0
of
True
->
cLouvain
distanceMap
...
...
@@ -57,11 +59,12 @@ cooc2graph threshold myCooc = do
----------------------------------------------------------
-- | From data to Graph
data2graph
::
[(
Text
,
Int
)]
->
Map
(
Int
,
Int
)
Int
->
Map
(
Int
,
Int
)
Double
->
Map
(
Int
,
Int
)
Double
->
[
LouvainNode
]
->
IO
Graph
data2graph
::
[(
Text
,
Int
)]
->
Map
(
Int
,
Int
)
Int
->
Map
(
Int
,
Int
)
Double
->
Map
(
Int
,
Int
)
Double
->
[
LouvainNode
]
->
IO
Graph
data2graph
labels
coocs
bridge
conf
partitions
=
do
let
community_id_by_node_id
=
Map
.
fromList
[
(
n
,
c
)
|
LouvainNode
n
c
<-
partitions
]
...
...
@@ -83,9 +86,11 @@ data2graph labels coocs bridge conf partitions = do
let
edges
=
[
Edge
{
edge_source
=
cs
(
show
s
)
,
edge_target
=
cs
(
show
t
)
,
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
)
}
|
(
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
...
...
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