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
153
Issues
153
List
Board
Labels
Milestones
Merge Requests
9
Merge Requests
9
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
670bc6c8
Commit
670bc6c8
authored
Apr 27, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[GRAPH] Distances
parent
7879431c
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
20 additions
and
12 deletions
+20
-12
Distances.hs
src/Gargantext/Viz/Graph/Distances.hs
+7
-0
Conditional.hs
src/Gargantext/Viz/Graph/Distances/Conditional.hs
+6
-5
Distributional.hs
src/Gargantext/Viz/Graph/Distances/Distributional.hs
+4
-4
Tools.hs
src/Gargantext/Viz/Graph/Tools.hs
+3
-3
No files found.
src/Gargantext/Viz/Graph/Distances.hs
View file @
670bc6c8
...
...
@@ -17,9 +17,16 @@ module Gargantext.Viz.Graph.Distances
where
import
Data.Array.Accelerate
import
Gargantext.Viz.Graph.Distances.Matrice
(
measureConditional
,
distributional
)
data
Distance
=
Conditional
|
Distributional
measure
::
Distance
->
Matrix
Int
->
Matrix
Double
measure
Conditional
=
measureConditional
measure
Distributional
=
distributional
src/Gargantext/Viz/Graph/Distances/Conditional.hs
View file @
670bc6c8
...
...
@@ -99,7 +99,7 @@ conditional m = filterMat (threshold m') m'
-- | Top specific or generic
sg
=
opWith
(
-
)
xs
ys
-- sg = ( xs - ys) / (2 * (x.shape[0] - 1))
nodes_kept
::
[
Int
]
nodes_kept
=
take
k'
$
S
.
toList
$
foldl'
(
\
s
(
n1
,
n2
)
->
insert
[
n1
,
n2
]
s
)
S
.
empty
...
...
@@ -111,7 +111,7 @@ conditional m = filterMat (threshold m') m'
insert
as
s
=
foldl'
(
\
s'
a
->
S
.
insert
a
s'
)
s
as
k'
=
2
*
k
k
=
10
dico_nodes
::
Map
Int
Int
dico_nodes
=
M
.
fromList
$
zip
([
1
..
]
::
[
Int
])
nodes_kept
--dico_nodes_rev = M.fromList $ zip nodes_kept [1..]
...
...
@@ -120,12 +120,13 @@ conditional m = filterMat (threshold m') m'
(
length
nodes_kept
)
(
\
(
i
,
j
)
->
getElem
((
M
.!
)
dico_nodes
i
)
((
M
.!
)
dico_nodes
j
)
x'
)
threshold
m''
=
V
.
minimum
$
V
.
map
(
\
cId
->
V
.
maximum
$
getCol
cId
m''
)
(
V
.
enumFromTo
1
(
nOf
Col
m''
))
threshold
m''
=
V
.
minimum
$
V
.
map
(
\
cId
->
V
.
maximum
$
getCol
cId
m''
)
(
V
.
enumFromTo
1
(
nOf
Col
m''
)
)
filterMat
t
m''
=
mapAll
(
\
x
->
filter'
t
x
)
m''
where
filter'
t'
x
=
case
(
x
>=
t'
)
of
True
->
x
False
->
0
------------------------------------------------------------------------
src/Gargantext/Viz/Graph/Distances/Distributional.hs
View file @
670bc6c8
...
...
@@ -39,7 +39,7 @@ distributional m = filter (\((x,y), d) -> foldl' (&&) True (conditions x y d) )
]
distriList
=
toListsWithIndex
distriMatrix
distriMatrix
=
ri
(
mi
m
)
distriMap
=
M
.
fromList
$
distriList
miniMax'
=
miniMax
distriMatrix
...
...
@@ -60,11 +60,11 @@ mi m = matrix c r createMat
(
c
,
r
)
=
(
nOf
Col
m
,
nOf
Row
m
)
createMat
(
x
,
y
)
=
doMi
x
y
m
doMi
x
y
m'
=
if
x
==
y
then
0
else
(
max
(
log
(
doMi'
x
y
m'
))
0
)
doMi'
x
y
m'
=
(
getElem
x
y
m
)
/
(
cross
x
y
m
/
total
m'
)
cross
x
y
m'
=
(
V
.
sum
$
ax
Col
x
y
m
)
*
(
V
.
sum
$
ax
Row
x
y
m'
)
ax
::
Axis
->
Int
->
Int
->
Matrix
a
->
Vector
a
...
...
src/Gargantext/Viz/Graph/Tools.hs
View file @
670bc6c8
...
...
@@ -26,7 +26,7 @@ import Gargantext.Prelude
import
Gargantext.Core.Statistics
import
Gargantext.Viz.Graph
import
Gargantext.Viz.Graph.Bridgeness
(
bridgeness
)
import
Gargantext.Viz.Graph.Distances
.Matrice
(
measureConditional
)
import
Gargantext.Viz.Graph.Distances
(
Distance
(
..
),
measure
)
import
Gargantext.Viz.Graph.Index
(
createIndices
,
toIndex
,
map2mat
,
mat2map
,
Index
)
import
Gargantext.Viz.Graph.IGraph
(
mkGraphUfromEdges
)
import
Gargantext.Viz.Graph.Proxemy
(
confluence
)
...
...
@@ -48,7 +48,7 @@ cooc2graph' threshold myCooc = distanceMap
(
ti
,
_
)
=
createIndices
myCooc
myCooc'
=
toIndex
ti
myCooc
matCooc
=
map2mat
0
(
Map
.
size
ti
)
$
Map
.
filter
(
>
1
)
myCooc'
distanceMat
=
measureConditional
matCooc
distanceMat
=
measure
Conditional
matCooc
distanceMap
=
Map
.
filter
(
>
threshold
)
$
mat2map
distanceMat
...
...
@@ -60,7 +60,7 @@ cooc2graph threshold myCooc = do
(
ti
,
_
)
=
createIndices
myCooc
myCooc'
=
toIndex
ti
myCooc
matCooc
=
map2mat
0
(
Map
.
size
ti
)
$
Map
.
filter
(
>
1
)
myCooc'
distanceMat
=
measureConditional
matCooc
distanceMat
=
measure
Conditional
matCooc
distanceMap
=
Map
.
filter
(
>
threshold
)
$
mat2map
distanceMat
nodesApprox
::
Int
...
...
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