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
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
ca99d1c1
Commit
ca99d1c1
authored
Oct 18, 2022
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[WIP] Bridgeness with Confluence, ok for order 1, order 2 needs more work
parent
be6461cb
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
16 additions
and
16 deletions
+16
-16
Bridgeness.hs
src/Gargantext/Core/Viz/Graph/Bridgeness.hs
+15
-14
Tools.hs
src/Gargantext/Core/Viz/Graph/Tools.hs
+1
-2
No files found.
src/Gargantext/Core/Viz/Graph/Bridgeness.hs
View file @
ca99d1c1
...
...
@@ -19,16 +19,18 @@ TODO use Map LouvainNodeId (Map LouvainNodeId)
module
Gargantext.Core.Viz.Graph.Bridgeness
-- (bridgeness)
where
import
Debug.Trace
(
trace
)
import
Gargantext.Core.Methods.Similarities
(
Similarity
(
..
))
import
Data.IntMap
(
IntMap
)
import
Data.Map
(
Map
,
fromListWith
,
lookup
,
toList
,
mapWithKey
,
elems
)
import
Data.Maybe
(
catMaybes
)
import
Data.Ord
(
Down
(
..
))
import
Debug.Trace
(
trace
)
import
Gargantext.Prelude
import
Graph.Types
(
ClusterNode
(
..
))
import
Data.Ord
(
Down
(
..
))
import
Data.IntMap
(
IntMap
)
import
qualified
Data.IntMap
as
IntMap
import
qualified
Data.List
as
List
import
qualified
Data.Map
as
Map
import
qualified
Data.Set
as
Set
----------------------------------------------------------------------
type
Partitions
a
=
Map
(
Int
,
Int
)
Double
->
IO
[
a
]
...
...
@@ -49,12 +51,13 @@ type Bridgeness = Double
type
Confluence
=
Map
(
NodeId
,
NodeId
)
Double
bridgeness3
::
Confluence
bridgeness3
::
Similarity
->
Confluence
->
Map
(
NodeId
,
NodeId
)
Double
->
Map
(
NodeId
,
NodeId
)
Double
bridgeness3
c
m
=
Map
.
fromList
bridgeness3
sim
c
m
=
Map
.
fromList
$
map
(
\
(
ks
,
(
v1
,
_v2
))
->
(
ks
,
v1
))
$
List
.
take
n
$
List
.
take
(
if
sim
==
Conditional
then
2
*
n
else
4
*
n
)
$
List
.
sortOn
(
Down
.
(
snd
.
snd
))
$
Map
.
toList
$
trace
(
"bridgeness3 m c"
<>
show
(
m
,
c
))
$
Map
.
intersectionWithKey
(
\
k
v1
v2
->
trace
(
"intersectionWithKey "
<>
(
show
(
k
,
v1
,
v2
)))
(
v1
,
v2
))
m
c
...
...
@@ -63,7 +66,12 @@ bridgeness3 c m = Map.fromList
n
::
Int
!
n
=
trace
(
"bridgeness m size: "
<>
(
show
$
List
.
length
m'
))
$
round
$
(
fromIntegral
$
List
.
length
m'
)
/
(
50
::
Double
)
$
(
fromIntegral
$
List
.
length
m'
)
/
(
log
$
fromIntegral
nodesNumber
::
Double
)
nodesNumber
::
Int
nodesNumber
=
Set
.
size
$
Set
.
fromList
$
as
<>
bs
where
(
as
,
bs
)
=
List
.
unzip
$
Map
.
keys
m
map2intMap
::
Map
(
Int
,
Int
)
a
->
IntMap
(
IntMap
a
)
...
...
@@ -82,13 +90,6 @@ look (k1,k2) m = if k1 < k2
else
look
(
k2
,
k1
)
m
{-
n :: Int
n = Set.size $ Set.fromList $ as <> bs
where
(as, bs) = List.unzip $ Map.keys m
-}
bridgeness
::
ToComId
a
=>
Confluence
->
[
a
]
...
...
src/Gargantext/Core/Viz/Graph/Tools.hs
View file @
ca99d1c1
...
...
@@ -14,7 +14,6 @@ Portability : POSIX
module
Gargantext.Core.Viz.Graph.Tools
where
import
Debug.Trace
(
trace
)
import
Data.Aeson
import
Data.HashMap.Strict
(
HashMap
)
import
Data.Map
(
Map
)
...
...
@@ -131,7 +130,7 @@ cooc2graphWith' doPartitions multi similarity threshold strength myCooc = do
let
!
confluence'
=
BAC
.
computeConfluences
3
(
Map
.
keys
distanceMap
)
True
!
bridgeness'
=
trace
(
"bridgeness3 in tools"
<>
show
(
confluence'
,
distanceMap
))
$
bridgeness3
confluence'
distanceMap
!
bridgeness'
=
bridgeness3
similarity
confluence'
distanceMap
pure
$
data2graph
multi
ti
diag
bridgeness'
confluence'
partitions
...
...
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