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
2bb0ebb2
Commit
2bb0ebb2
authored
Mar 24, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FLouvain] delta Q formula using newtypes
parent
2afa4fd0
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
27 additions
and
6 deletions
+27
-6
.gitignore
.gitignore
+7
-0
FLouvain.hs
src/Data/Graph/Clustering/FLouvain.hs
+18
-4
stack.yaml
stack.yaml
+2
-2
No files found.
.gitignore
0 → 100644
View file @
2bb0ebb2
.DS_Store
.stack-work
.idea
*.log
tmp/
src/Data/Graph/Clustering/FLouvain.hs
View file @
2bb0ebb2
...
...
@@ -98,6 +98,10 @@ newtype TotWeightSum = TotWeightSum { unTotWeightSum :: Double }
newtype
Community
=
Community
{
unCommunity
::
([
Node
],
InWeightSum
,
TotWeightSum
)
}
comNodes
::
Community
->
[
Node
]
comNodes
(
Community
(
ns
,
_
,
_
))
=
ns
comInWeightSum
::
Community
->
InWeightSum
comInWeightSum
(
Community
(
_
,
inWeightSum
,
_
))
=
inWeightSum
comTotWeightSum
::
Community
->
TotWeightSum
comTotWeightSum
(
Community
(
_
,
_
,
totWeightSum
))
=
totWeightSum
type
CGrNode
=
Node
type
CGrEdge
=
(
InWeightSum
,
TotWeightSum
)
...
...
@@ -111,10 +115,20 @@ type CGr = Gr Community CGrEdge
modularity
::
Gr
a
b
->
CGr
->
Double
modularity
gr
cgr
=
0.0
type
Delta
a
b
=
Gr
a
b
->
Node
->
Community
->
Double
type
Delta
=
Community
->
Weight
->
Weight
->
Weight
->
Double
-- | Delta Q function from Louvain paper (2).
delta
::
Delta
a
b
delta
gr
n
(
Community
(
ns
,
inWeightSum
,
totWeightSum
))
=
0.0
delta
::
Delta
delta
com
ki
kin
m
=
acc
-
dec
where
inWeightSum
=
comInWeightSum
com
totWeightSum
=
comTotWeightSum
com
acc
=
accL
-
accR
*
accR
accL
=
0.5
*
(
unInWeightSum
inWeightSum
+
2.0
*
(
unWeight
kin
))
/
(
unWeight
m
)
accR
=
0.5
*
(
unTotWeightSum
totWeightSum
+
unWeight
ki
)
/
(
unWeight
m
)
dec
=
decL
-
decM
*
decM
-
decR
*
decR
decL
=
0.5
*
(
unInWeightSum
inWeightSum
)
/
(
unWeight
m
)
decM
=
0.5
*
(
unTotWeightSum
totWeightSum
)
/
(
unWeight
m
)
decR
=
0.5
*
(
unWeight
ki
)
/
(
unWeight
m
)
-- | One iteration step takes the graph and existing communities as a graph and
-- computes new community graph
...
...
@@ -137,7 +151,7 @@ step (p, v, l, s) cgr = cgr
moves
=
case
mNc
of
Nothing
->
Nothing
Just
nc
->
Just
(
makeMove
OutOf
nc
,
ma
keMove
Into
<$>
ncs
)
,
ma
p
(
makeMove
Into
)
ncs
)
makeMove
::
Direction
->
LNode
Community
->
LNode
Community
makeMove
direction
(
cn
,
c
)
=
(
cn
,
moveNodeWithNeighbours
(
p
<>
s
)
v
direction
c
)
...
...
stack.yaml
View file @
2bb0ebb2
...
...
@@ -18,7 +18,7 @@
#
# resolver: ./custom-snapshot.yaml
# resolver: https://example.com/snapshots/2018-01-01.yaml
resolver
:
lts-1
1.10
resolver
:
lts-1
4.27
# User packages to be built.
# Various formats can be used as shown in the example below.
...
...
@@ -62,4 +62,4 @@ packages:
# extra-lib-dirs: [/path/to/dir]
#
# Allow a newer minor version of GHC than the snapshot specifies
# compiler-check: newer-minor
\ No newline at end of file
# compiler-check: newer-minor
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