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
1acd124c
Commit
1acd124c
authored
Mar 27, 2020
by
Przemyslaw Kaminski
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
[FLouvain] test -- fix weights (<= 1.0)
parent
df34c362
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
13 additions
and
10 deletions
+13
-10
FLouvainSpec.hs
test/FLouvainSpec.hs
+13
-10
No files found.
test/FLouvainSpec.hs
View file @
1acd124c
...
...
@@ -18,7 +18,7 @@ import Data.Graph.FGL
simpleGraph
::
FGraph
()
()
simpleGraph
=
mkFGraph'
[
(
1
,
2
,
1.0
)
,
(
2
,
3
,
2.0
)
,
(
2
,
3
,
0.5
)
]
simpleLGraph
::
FGraph
Text
()
...
...
@@ -26,18 +26,21 @@ simpleLGraph = mkFGraph [ (1, "one")
,
(
2
,
"two"
)
,
(
3
,
"three"
)]
[
(
1
,
2
,
1.0
)
,
(
2
,
3
,
1.0
)
]
,
(
2
,
3
,
0.5
)
]
spec
::
Spec
spec
=
do
describe
"FLouvain tests"
$
do
it
"graphWeight computes correctly"
$
do
graphWeight
simpleGraph
`
shouldBe
`
GraphWeightSum
3.0
assertApproxEqual
"graphWeights don't match"
0.00001
1.5
(
unGraphWeightSum
$
graphWeight
simpleGraph
)
it
"nodeWeightSum computes correctly"
$
do
nodeWeightSum
(
DGI
.
context
simpleGraph
1
)
`
shouldBe
`
NodeWeightSum
1.0
nodeWeightSum
(
DGI
.
context
simpleGraph
2
)
`
shouldBe
`
NodeWeightSum
3.0
nodeWeightSum
(
DGI
.
context
simpleGraph
3
)
`
shouldBe
`
NodeWeightSum
2.0
nodeWeightSum
(
DGI
.
context
simpleGraph
2
)
`
shouldBe
`
NodeWeightSum
1.5
nodeWeightSum
(
DGI
.
context
simpleGraph
3
)
`
shouldBe
`
NodeWeightSum
0.5
it
"replaceLNode works correctly"
$
do
let
replaced
=
replaceLNode
simpleLGraph
(
1
,
"ONE"
)
...
...
@@ -55,8 +58,8 @@ spec = do
Protolude
.
map
comInWeightSum
communities
`
shouldBe
`
[
iws0
,
iws0
,
iws0
]
Protolude
.
map
comTotWeightSum
communities
`
shouldBe
`
[
TotWeightSum
1.0
,
TotWeightSum
3.0
,
TotWeightSum
2.0
]
,
TotWeightSum
1.5
,
TotWeightSum
0.5
]
it
"nodeComWeightSum computes correctly"
$
do
let
cgr
=
initialCGr
simpleGraph
...
...
@@ -69,9 +72,9 @@ spec = do
nodeComWeightSum
fstCom
(
DGI
.
context
simpleGraph
3
)
`
shouldBe
`
NodeComWeightSum
0.0
nodeComWeightSum
sndCom
(
DGI
.
context
simpleGraph
1
)
`
shouldBe
`
NodeComWeightSum
1.0
nodeComWeightSum
sndCom
(
DGI
.
context
simpleGraph
2
)
`
shouldBe
`
NodeComWeightSum
0.0
nodeComWeightSum
sndCom
(
DGI
.
context
simpleGraph
3
)
`
shouldBe
`
NodeComWeightSum
2.0
nodeComWeightSum
sndCom
(
DGI
.
context
simpleGraph
3
)
`
shouldBe
`
NodeComWeightSum
0.5
nodeComWeightSum
trdCom
(
DGI
.
context
simpleGraph
1
)
`
shouldBe
`
NodeComWeightSum
0.0
nodeComWeightSum
trdCom
(
DGI
.
context
simpleGraph
2
)
`
shouldBe
`
NodeComWeightSum
2.0
nodeComWeightSum
trdCom
(
DGI
.
context
simpleGraph
2
)
`
shouldBe
`
NodeComWeightSum
0.5
nodeComWeightSum
trdCom
(
DGI
.
context
simpleGraph
3
)
`
shouldBe
`
NodeComWeightSum
0.0
it
"modularity computes correctly"
$
do
...
...
@@ -114,7 +117,7 @@ spec = do
intoOutOf
ctx
com
=
moveNodeWithContext
ctx
OutOf
$
moveNodeWithContext
ctx
Into
com
outOfInto
ctx
com
=
moveNodeWithContext
ctx
Into
$
moveNodeWithContext
ctx
OutOf
com
newCom1
`
shouldBe
`
Community
(
[]
,
InWeightSum
0.0
,
TotWeightSum
0.0
)
newCom2
`
shouldBe
`
Community
([
1
,
2
],
InWeightSum
1.0
,
TotWeightSum
2.0
)
newCom2
`
shouldBe
`
Community
([
1
,
2
],
InWeightSum
1.0
,
TotWeightSum
0.5
)
-- TODO moveNodeWithContext ctx Into (moveNodeWithContext ctx OutOf) is an
-- identity, this can be used in QuickCheck testing
...
...
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