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
157
Issues
157
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
0eea2d3c
Commit
0eea2d3c
authored
Dec 03, 2021
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FEAT] Order 2 fixed with filtered edges (finally...:)
parent
546419c5
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
43 additions
and
17 deletions
+43
-17
Conditional.hs
src/Gargantext/Core/Methods/Distances/Conditional.hs
+5
-11
Tools.hs
src/Gargantext/Core/Viz/Graph/Tools.hs
+3
-0
Utils.hs
src/Gargantext/Core/Viz/Graph/Utils.hs
+35
-6
No files found.
src/Gargantext/Core/Methods/Distances/Conditional.hs
View file @
0eea2d3c
...
...
@@ -15,16 +15,18 @@ Motivation and definition of the @Conditional@ distance.
module
Gargantext.Core.Methods.Distances.Conditional
where
import
Control.DeepSeq
(
NFData
)
import
Control.Parallel.Strategies
(
parList
,
rdeepseq
,
using
)
import
Data.Hashable
(
Hashable
)
import
Data.List
(
unzip
)
import
Data.Maybe
(
catMaybes
)
import
Gargantext.Prelude
import
Gargantext.Core.Viz.Graph.Utils
(
getMax
)
import
qualified
Data.HashMap.Strict
as
Map
import
qualified
Data.Set
as
Set
import
Control.DeepSeq
(
NFData
)
type
HashMap
=
Map
.
HashMap
type
HashMap
=
Map
.
HashMap
------------------------------------------------------------------------
-- First version as first implementation
-- - qualitatively verified
...
...
@@ -51,14 +53,6 @@ conditional m' = Map.fromList $ ((catMaybes results') `using` parList rdeepseq)
(
x
,
y
)
=
unzip
$
Map
.
keys
m
getMax
::
(
a
,
a
)
->
Maybe
Double
->
Maybe
Double
->
Maybe
((
a
,
a
),
Double
)
getMax
(
i
,
j
)
(
Just
d
)
Nothing
=
Just
((
i
,
j
),
d
)
getMax
(
i
,
j
)
Nothing
(
Just
d
)
=
Just
((
j
,
i
),
d
)
getMax
ij
(
Just
di
)
(
Just
dj
)
=
if
di
>=
dj
then
getMax
ij
(
Just
di
)
Nothing
else
getMax
ij
Nothing
(
Just
dj
)
getMax
_
_
_
=
Nothing
src/Gargantext/Core/Viz/Graph/Tools.hs
View file @
0eea2d3c
...
...
@@ -26,6 +26,7 @@ import Gargantext.Core.Methods.Distances (Distance(..), measure)
import
Gargantext.Core.Methods.Graph.BAC.Proxemy
(
confluence
)
import
Gargantext.Core.Statistics
import
Gargantext.Core.Viz.Graph
import
Gargantext.Core.Viz.Graph.Utils
(
edgesFilter
)
import
Gargantext.Core.Viz.Graph.Bridgeness
(
bridgeness
,
Partitions
,
ToComId
(
..
))
import
Gargantext.Core.Viz.Graph.Index
(
createIndices
,
toIndex
,
map2mat
,
mat2map
,
Index
,
MatrixShape
(
..
))
import
Gargantext.Core.Viz.Graph.Tools.IGraph
(
mkGraphUfromEdges
,
spinglass
)
...
...
@@ -50,6 +51,7 @@ defaultClustering x = spinglass 1 x
-------------------------------------------------------------
type
Threshold
=
Double
cooc2graph'
::
Ord
t
=>
Distance
->
Double
->
Map
(
t
,
t
)
Int
...
...
@@ -151,6 +153,7 @@ doDistanceMap Distributional threshold myCooc = (distanceMap, toIndex ti diag, t
$
List
.
take
links
$
List
.
sortOn
snd
$
Map
.
toList
$
edgesFilter
$
Map
.
filter
(
>
threshold
)
$
mat2map
similarities
...
...
src/Gargantext/Core/Viz/Graph/Utils.hs
View file @
0eea2d3c
...
...
@@ -17,14 +17,16 @@ These functions are used for Vector.Matrix only.
module
Gargantext.Core.Viz.Graph.Utils
where
import
Data.Map
(
Map
)
import
Data.Matrix
hiding
(
identity
)
import
Data.Vector
(
Vector
)
import
qualified
Data.Vector
as
V
import
qualified
Data.List
as
L
import
qualified
Data.Map
as
Map
import
Gargantext.Prelude
import
Data.List
(
unzip
)
import
qualified
Data.Vector
as
V
import
Data.Maybe
(
catMaybes
)
import
qualified
Data.Set
as
Set
------------------------------------------------------------------------
-- | Some utils to build the matrix from cooccurrence results
...
...
@@ -63,8 +65,35 @@ toListsWithIndex m = concat' $ zip [1..] $ map (\c -> zip [1..] c) $ toLists m
concat'
::
[(
Int
,
[(
Int
,
a
)])]
->
[((
Int
,
Int
),
a
)]
concat'
xs
=
L
.
concat
$
map
(
\
(
x
,
ys
)
->
map
(
\
(
y
,
a
)
->
((
x
,
y
),
a
))
ys
)
xs
------------------------------------------------------------------------
-- Utils to manage Graphs
edgesFilter
::
(
Ord
a
,
Ord
b
)
=>
Map
(
a
,
a
)
b
->
Map
(
a
,
a
)
b
edgesFilter
m
=
Map
.
fromList
$
catMaybes
results
where
results
=
[
let
ij
=
Map
.
lookup
(
i
,
j
)
m
ji
=
Map
.
lookup
(
j
,
i
)
m
in
getMax
(
i
,
j
)
ij
ji
|
i
<-
keys
,
j
<-
keys
,
i
<
j
]
keys
=
Set
.
toList
$
Set
.
fromList
(
x
<>
y
)
(
x
,
y
)
=
unzip
$
Map
.
keys
m
getMax
::
Ord
b
=>
(
a
,
a
)
->
Maybe
b
->
Maybe
b
->
Maybe
((
a
,
a
),
b
)
getMax
(
i
,
j
)
(
Just
d
)
Nothing
=
Just
((
i
,
j
),
d
)
getMax
(
i
,
j
)
Nothing
(
Just
d
)
=
Just
((
j
,
i
),
d
)
getMax
ij
(
Just
di
)
(
Just
dj
)
=
if
di
>=
dj
then
getMax
ij
(
Just
di
)
Nothing
else
getMax
ij
Nothing
(
Just
dj
)
getMax
_
_
_
=
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