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
3b5169dd
Commit
3b5169dd
authored
Oct 12, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[STASH] back to old work
parent
797ae29e
Changes
3
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
38 additions
and
21 deletions
+38
-21
Clustering.hs
src-test/Graph/Clustering.hs
+0
-1
Bridgeness.hs
src/Gargantext/Core/Viz/Graph/Bridgeness.hs
+35
-18
Tools.hs
src/Gargantext/Core/Viz/Graph/Tools.hs
+3
-2
No files found.
src-test/Graph/Clustering.hs
View file @
3b5169dd
...
...
@@ -22,7 +22,6 @@ import Test.Hspec
import
Data.HashMap.Strict
(
HashMap
)
import
qualified
Data.HashMap.Strict
as
HashMap
import
qualified
Data.List
as
List
import
Gargantext.Core.Viz.Graph.Tools
(
PartitionMethod
(
..
))
import
Gargantext.Core.Viz.Graph.Tools.IGraph
(
spinglass
)
import
Gargantext.Core.Methods.Similarities
(
Similarity
(
..
))
...
...
src/Gargantext/Core/Viz/Graph/Bridgeness.hs
View file @
3b5169dd
...
...
@@ -26,8 +26,6 @@ import Gargantext.Prelude
import
Graph.Types
(
ClusterNode
(
..
))
import
qualified
Data.Map
as
DM
----------------------------------------------------------------------
type
Partitions
a
=
Map
(
Int
,
Int
)
Double
->
IO
[
a
]
----------------------------------------------------------------------
...
...
@@ -45,19 +43,19 @@ instance ToComId ClusterNode where
----------------------------------------------------------------------
type
Bridgeness
=
Double
bridgeness
::
ToComId
a
=>
Bridgeness
bridgeness
::
ToComId
a
=>
Bridgeness
->
[
a
]
->
Map
(
NodeId
,
NodeId
)
Double
->
Map
(
NodeId
,
NodeId
)
Double
bridgeness
=
bridgeness'
nodeId2comId
bridgeness'
::
(
a
->
(
Int
,
Int
))
bridgeness
=
bridgenessWith
nodeId2comId
where
bridgenessWith
::
(
a
->
(
Int
,
Int
))
->
Bridgeness
->
[
a
]
->
Map
(
Int
,
Int
)
Double
->
Map
(
Int
,
Int
)
Double
bridgeness'
f
b
ns
=
DM
.
fromList
bridgenessWith
f
b
ns
=
DM
.
fromList
.
concat
.
DM
.
elems
.
filterComs
b
...
...
@@ -95,3 +93,22 @@ filterComs _b m = DM.filter (\n -> length n > 0) $ mapWithKey filter' m
a'
=
fromIntegral
$
length
a
t
::
Double
t
=
fromIntegral
$
length
$
concat
$
elems
m
--------------------------------------------------------------
{--
Compute the median of a list
From: https://hackage.haskell.org/package/dsp-0.2.5.1/docs/src/Numeric.Statistics.Median.html
Compute the center of the list in a more lazy manner
and thus halves memory requirement.
-}
median
::
(
Ord
a
,
Fractional
a
)
=>
[
a
]
->
a
median
[]
=
panic
"medianFast: empty list has no median"
median
zs
=
let
recurse
(
x0
:
_
)
(
_
:
[]
)
=
x0
recurse
(
x0
:
x1
:
_
)
(
_
:
_
:
[]
)
=
(
x0
+
x1
)
/
2
recurse
(
_
:
xs
)
(
_
:
_
:
ys
)
=
recurse
xs
ys
recurse
_
_
=
panic
"median: this error cannot occur in the way 'recurse' is called"
in
recurse
zs
zs
src/Gargantext/Core/Viz/Graph/Tools.hs
View file @
3b5169dd
...
...
@@ -97,7 +97,8 @@ cooc2graphWith :: PartitionMethod
->
IO
Graph
cooc2graphWith
Spinglass
=
cooc2graphWith'
(
spinglass
1
)
cooc2graphWith
Confluence
=
cooc2graphWith'
(
\
x
->
pure
$
BAC
.
defaultClustering
x
)
cooc2graphWith
Infomap
=
cooc2graphWith'
(
infomap
"--silent --two-level -N2"
)
cooc2graphWith
Infomap
=
cooc2graphWith'
(
infomap
"-v -N2"
)
--cooc2graphWith Infomap = cooc2graphWith' (infomap "--silent --two-level -N2")
-- TODO: change these options, or make them configurable in UI?
...
...
@@ -132,8 +133,8 @@ cooc2graphWith' doPartitions multi similarity threshold strength myCooc = do
where
(
as
,
bs
)
=
List
.
unzip
$
Map
.
keys
distanceMap
n'
=
Set
.
size
$
Set
.
fromList
$
as
<>
bs
!
bridgeness'
=
bridgeness
(
fromIntegral
nodesApprox
)
partitions
distanceMap
!
confluence'
=
BAC
.
computeConfluences
3
(
Map
.
keys
bridgeness'
)
True
!
bridgeness'
=
bridgeness
(
fromIntegral
nodesApprox
)
partitions
distanceMap
pure
$
data2graph
multi
ti
diag
bridgeness'
confluence'
partitions
type
Reverse
=
Bool
...
...
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