Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
C
clustering-louvain
Project
Project
Details
Activity
Releases
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
1
Issues
1
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
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
clustering-louvain
Commits
2b1d848a
Commit
2b1d848a
authored
Mar 29, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[ILouvain] fix paths
parent
8c5e1f13
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
35 additions
and
41 deletions
+35
-41
FLouvain.hs
src/Data/Graph/Clustering/FLouvain.hs
+2
-2
HLouvain.hs
src/Data/Graph/Clustering/HLouvain.hs
+6
-6
ILouvain.hs
src/Data/Graph/Clustering/ILouvain.hs
+27
-33
No files found.
src/Data/Graph/Clustering/FLouvain.hs
View file @
2b1d848a
{-|
{-|
Module : Data.Graph.Clustering.FLouvain
Module : Data.Graph.Clustering.FLouvain
Description : Purely functional (Inductive) Louvain clustering
Description : Purely functional (Inductive) Louvain clustering
Copyright : (c)
Alexandre Delanoë,
CNRS, 2020-Present
Copyright : (c) CNRS, 2020-Present
License : AGPL + CECILL v3
License : AGPL + CECILL v3
Maintainer :
alexandre.delanoe+louvain@iscpif.fr
Maintainer :
contact@gargantext.org
Stability : experimental
Stability : experimental
Portability : POSIX
Portability : POSIX
...
...
src/Data/Graph/Clustering/HLouvain.hs
View file @
2b1d848a
...
@@ -103,7 +103,7 @@ toDendo :: DynGraph gr
...
@@ -103,7 +103,7 @@ toDendo :: DynGraph gr
->
Dendogram
->
Dendogram
toDendo
g
n
=
Dendogram
[
Gram
n
]
s
toDendo
g
n
=
Dendogram
[
Gram
n
]
s
where
where
s
=
modularity
g
(
Set
.
singleton
n
)
s
=
h
modularity
g
(
Set
.
singleton
n
)
toDendoD
::
DynGraph
gr
toDendoD
::
DynGraph
gr
=>
gr
n
e
=>
gr
n
e
...
@@ -173,17 +173,17 @@ class HasScore a
...
@@ -173,17 +173,17 @@ class HasScore a
instance
HasScore
Dendogram
instance
HasScore
Dendogram
where
where
hasScore
::
DynGraph
gr
=>
gr
a
b
->
Dendogram
->
Double
hasScore
::
DynGraph
gr
=>
gr
a
b
->
Dendogram
->
Double
hasScore
g
m
=
modularity
g
(
nodesD
m
)
hasScore
g
m
=
h
modularity
g
(
nodesD
m
)
instance
HasScore
[
Dendogram
]
instance
HasScore
[
Dendogram
]
where
where
hasScore
g
ds
=
modularity
g
(
Set
.
unions
$
map
nodesD
ds
)
hasScore
g
ds
=
h
modularity
g
(
Set
.
unions
$
map
nodesD
ds
)
modulare
::
DynGraph
gr
=>
gr
a
b
->
Set
Node
->
Double
modulare
::
DynGraph
gr
=>
gr
a
b
->
Set
Node
->
Double
modulare
=
modularity
modulare
=
h
modularity
modularity
::
DynGraph
gr
=>
gr
a
b
->
Set
Node
->
Double
h
modularity
::
DynGraph
gr
=>
gr
a
b
->
Set
Node
->
Double
modularity
gr
ns
=
coverage
-
edgeDensity
h
modularity
gr
ns
=
coverage
-
edgeDensity
where
where
coverage
::
Double
coverage
::
Double
coverage
=
sizeSubGraph
/
sizeAllGraph
coverage
=
sizeSubGraph
/
sizeAllGraph
...
...
src/Data/Graph/Clustering/ILouvain.hs
View file @
2b1d848a
...
@@ -7,7 +7,8 @@ Maintainer : alexandre.delanoe+louvain@iscpif.fr
...
@@ -7,7 +7,8 @@ Maintainer : alexandre.delanoe+louvain@iscpif.fr
Stability : experimental
Stability : experimental
Portability : POSIX
Portability : POSIX
ILouvain: really inductive Graph
ILouvain: really inductive Graph clustering with destructives updates
-}
-}
module
Data.Graph.Clustering.ILouvain
module
Data.Graph.Clustering.ILouvain
...
@@ -28,40 +29,44 @@ type HyperContext a b = Context (Gr () a) b
...
@@ -28,40 +29,44 @@ type HyperContext a b = Context (Gr () a) b
-- TODO Later (hypothesis still)
-- TODO Later (hypothesis still)
-- type StreamGraph a b = Gr a (Gr () b)
-- type StreamGraph a b = Gr a (Gr () b)
{-
convergence :: HyperGraph a b -> HyperGraph a b
convergence g = if m - m' > 0.1 then g else g'
where
m = modularity g (hnodes g )
m' = modularity g' (hnodes g')
g' = step g
-}
toNodes
::
HyperGraph
a
a
->
[[
Node
]]
toNodes
g
=
map
(
\
n
->
hnodes
g
n
)
(
nodes
g
)
toNodes
g
=
map
(
\
n
->
hnodes
g
n
)
(
nodes
g
)
iLouvain
::
(
Eq
a
)
=>
HyperGraph
a
a
->
HyperGraph
a
a
iLouvain
::
Eq
a
=>
HyperGraph
a
a
->
HyperGraph
a
a
iLouvain
g
=
iLouvain'
g
$
nodes
g
iLouvain
g
=
iLouvain'
g
(
iLouvain'
g
g
)
iLouvain'
::
HyperGraph
a
a
->
[
Node
]
->
HyperGraph
a
a
iLouvain'
::
(
Eq
a
)
iLouvain'
g
[ ]
=
g
=>
HyperGraph
a
a
iLouvain'
g
[
_
]
=
g
->
HyperGraph
a
a
iLouvain'
g
ns
=
foldl'
(
\
g1
n
->
step'
g
g1
n
$
neighbors
g1
n
)
g
ns
->
HyperGraph
a
a
iLouvain'
g0
g
=
iLouvain''
g
$
filter
(
\
n
->
elem
n
(
nodes
g
))
ps
where
ps
=
path'
g0
iLouvain''
::
HyperGraph
a
a
->
[
Node
]
->
HyperGraph
a
a
iLouvain''
g
[ ]
=
g
iLouvain''
g
[
_
]
=
g
iLouvain''
g
ns
=
foldl'
(
\
g1
n
->
step'
g
g1
n
$
neighbors
g1
n
)
g
ns
step'
::
HyperGraph
a
b
step'
::
HyperGraph
a
b
->
HyperGraph
a
a
->
HyperGraph
a
a
->
Node
->
Node
->
[
Node
]
->
[
Node
]
->
HyperGraph
a
a
->
HyperGraph
a
a
step'
g
g'
n
ns
=
foldl'
(
\
g1
n'
->
case
match
n
g1
of
step'
g
g'
n
ns
=
(
Nothing
,
_
)
->
g1
foldl'
(
\
g1
n'
->
case
match
n
g1
of
(
Just
_
,
_
)
->
step
g
g1
n
n'
)
g'
ns
(
Nothing
,
_
)
->
g1
(
Just
_
,
_
)
->
step
g
g1
n
n'
)
g'
ns
step
::
HyperGraph
a
b
step
::
HyperGraph
a
b
->
HyperGraph
a
a
->
HyperGraph
a
a
->
Node
->
Node
->
Node
->
Node
->
HyperGraph
a
a
->
HyperGraph
a
a
step
g
g'
n1
n2
=
--
trace (show n1 :: Text) $
step
g
g'
n1
n2
=
trace
(
show
n1
::
Text
)
$
if
s2
>
0
&&
s2
>
s1
if
s2
>
0
&&
s2
>
s1
then
mv
g'
[
n1
]
[
n2
]
then
mv
g'
[
n1
]
[
n2
]
else
g'
else
g'
...
@@ -81,10 +86,11 @@ hdeg = undefined
...
@@ -81,10 +86,11 @@ hdeg = undefined
------------------------------------------------------------------------
------------------------------------------------------------------------
-- TODO go depth in HyperGraph (modularity at level/depth)
-- TODO go depth in HyperGraph (modularity at level/depth)
imodularity
::
HyperGraph
a
b
->
[
Node
]
->
Double
imodularity
::
HyperGraph
a
b
->
[
Node
]
->
Double
imodularity
g
ns
=
H
.
modularity
g
(
fromList
ns
)
imodularity
g
ns
=
H
.
hmodularity
g
(
fromList
ns'
)
where
ns'
=
concat
$
map
(
\
n
->
hnodes
g
n
)
ns
------------------------------------------------------------------------
------------------------------------------------------------------------
toHyperGraph
::
Gr
()
Double
->
HyperGraph
Double
Double
toHyperGraph
::
Gr
()
Double
->
HyperGraph
Double
Double
toHyperGraph
g
=
nmap
(
\
_
->
empty
)
g
toHyperGraph
g
=
nmap
(
\
_
->
empty
)
g
------------------------------------------------------------------------
------------------------------------------------------------------------
...
@@ -175,18 +181,6 @@ merge = ufold (&)
...
@@ -175,18 +181,6 @@ merge = ufold (&)
------------------------------------------------------------------------
------------------------------------------------------------------------
test_mv
::
Ord
a
=>
HyperGraph
a
a
->
Node
->
Node
->
Bool
test_mv
::
Ord
a
=>
HyperGraph
a
a
->
Node
->
Node
->
Bool
test_mv
g
a
b
=
(
mv
(
mv
g
[
a
]
[
b
])
[
b
,
a
]
[]
)
==
g
test_mv
g
a
b
=
(
mv
(
mv
g
[
a
]
[
b
])
[
b
,
a
]
[]
)
==
g
------------------------------------------------------------------------
-- | Recursive Node of Graph
{-
rnodes :: RGraph -> [Node]
rnodes Empty = []
rnodes g = concat $ map (\(x1, x2) -> [x1] <> rnodes x2) $ labNodes g
rlabNodes :: Graph' a b -> [LNode a]
rlabNodes Empty' = []
rlabNodes g = labNodes g
-}
------------------------------------------------------------------------
------------------------------------------------------------------------
-- Paths in the Graph to be tested
-- Paths in the Graph to be tested
-- Directed graph strategy
-- Directed graph strategy
...
...
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