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
89722cf7
Commit
89722cf7
authored
Mar 28, 2020
by
Alexandre Delanoë
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[Debug] first iteration ok, needs more clustering and conv to fixed point.
parent
aaed14eb
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
14 additions
and
11 deletions
+14
-11
clustering-louvain.cabal
clustering-louvain.cabal
+2
-1
package.yaml
package.yaml
+1
-0
ILouvain.hs
src/Data/Graph/Clustering/ILouvain.hs
+11
-10
No files found.
clustering-louvain.cabal
View file @
89722cf7
...
...
@@ -4,7 +4,7 @@ cabal-version: 1.12
--
-- see: https://github.com/sol/hpack
--
-- hash:
e1e53adbd24148d990b70f078530a01370effd8531413470ea9947aa095bf247
-- hash:
34278ee95f4de4f41ad7ba7e08818b4a24fad95acd67aa0a682a260b2db2832e
name: clustering-louvain
version: 0.1.0.0
...
...
@@ -44,6 +44,7 @@ library
, hxt
, parsec
, protolude
, simple-reflect
, text
, turtle
, vector
...
...
package.yaml
View file @
89722cf7
...
...
@@ -49,6 +49,7 @@ library:
-
parsec
-
turtle
-
foldl
-
simple-reflect
tests
:
louvain-test
:
main
:
Spec.hs
...
...
src/Data/Graph/Clustering/ILouvain.hs
View file @
89722cf7
...
...
@@ -13,6 +13,7 @@ ILouvain: really inductive Graph
module
Data.Graph.Clustering.ILouvain
where
import
Debug.SimpleReflect
import
Data.Set
(
fromList
)
import
Data.Maybe
(
catMaybes
,
maybe
)
import
Data.List
(
zip
,
cycle
)
...
...
@@ -36,12 +37,10 @@ convergence g = if m - m' > 0.1 then g else g'
g' = step g
-}
toNodes
g
=
map
(
\
n
->
hnodes
g
n
)
(
nodes
g
)
iLouvain
::
(
Eq
a
)
=>
HyperGraph
a
a
->
[[
Node
]]
iLouvain
g
=
toNodes
$
iLouvain'
g
$
path'
g
where
toNodes
g
=
map
(
\
n
->
hnodes
g
n
)
(
nodes
g
)
iLouvain
::
(
Eq
a
)
=>
HyperGraph
a
a
->
HyperGraph
a
a
iLouvain
g
=
iLouvain'
g
$
nodes
g
iLouvain'
::
HyperGraph
a
a
->
[
Node
]
->
HyperGraph
a
a
iLouvain'
g
[ ]
=
g
...
...
@@ -53,14 +52,16 @@ step' :: HyperGraph a b
->
Node
->
[
Node
]
->
HyperGraph
a
a
step'
g
g'
n
ns
=
foldl'
(
\
g1
n'
->
step
g
g1
n
n'
)
g'
ns
step'
g
g'
n
ns
=
foldl'
(
\
g1
n'
->
case
match
n
g1
of
(
Nothing
,
_
)
->
g1
(
Just
_
,
_
)
->
step
g
g1
n
n'
)
g'
ns
step
::
HyperGraph
a
b
->
HyperGraph
a
a
->
Node
->
Node
->
HyperGraph
a
a
step
g
g'
n1
n2
=
step
g
g'
n1
n2
=
-- trace (show n1 :: Text) $
if
s2
>
0
&&
s2
>
s1
then
mv
g'
[
n1
]
[
n2
]
else
g'
...
...
@@ -73,10 +74,10 @@ hnodes :: HyperGraph a b -> Node -> [Node]
hnodes
g
n
=
case
match
n
g
of
(
Nothing
,
_
)
->
[]
(
Just
(
p
,
n
,
l
,
s
),
_
)
->
n
:
nodes
l
{-
hdeg :: Graph gr => gr a b -> Node -> Maybe Int
hdeg = undefined
-}
------------------------------------------------------------------------
-- TODO go depth in HyperGraph (modularity at level/depth)
imodularity
::
HyperGraph
a
b
->
[
Node
]
->
Double
...
...
@@ -135,7 +136,7 @@ mv g [a] [b] = case a == b of
True
->
panic
"mv, impossible: moved node is same as destination"
False
->
mv'
g
a
b
mv
g
[
a
,
b
]
[ ]
=
case
match
a
g
of
(
Nothing
,
_
)
->
panic
"mv: fst Node of Path does not exist"
(
Nothing
,
_
)
->
panic
$
"mv: fst Node of Path does not exist: "
<>
show
a
(
Just
(
p
,
n
,
l
,
s
),
g1
)
->
case
match
b
l
of
(
Just
(
p'
,
n'
,
l'
,
s'
),
g2
)
->
(
p'
,
n'
,
g2
,
s'
)
&
((
p
,
n
,
delNode
b
l
,
s
)
...
...
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