Commit 1fa83144 authored by Alfredo Di Napoli's avatar Alfredo Di Napoli

Add correctness tests for community algos

parent 86ddc5ed
...@@ -167,13 +167,29 @@ communityTest = testGroup "Community" ...@@ -167,13 +167,29 @@ communityTest = testGroup "Community"
communityCorrectnessTests :: TestTree communityCorrectnessTests :: TestTree
communityCorrectnessTests = testGroup "Clustering" [ communityCorrectnessTests = testGroup "Clustering" [
testCase "spinglass" spinglassClustering testCase "spinglass" spinglassClustering
, testCase "leiden" leidenClustering
, testCase "infomap" infomapClustering
] ]
where where
runAlgo :: CommunityMethod -> IO [[Int]]
runAlgo = withSeed 1 . findCommunity testGraph Nothing Nothing
spinglassClustering :: Assertion spinglassClustering :: Assertion
spinglassClustering = do spinglassClustering = do
clusters <- withSeed 1 $ findCommunity testGraph Nothing Nothing spinglass clusters <- runAlgo spinglass
clusters @?= [[3,4], [0,1,2]] clusters @?= [[3,4], [0,1,2]]
leidenClustering :: Assertion
leidenClustering = do
clusters <- runAlgo leiden
clusters @?= [[0,1,2,3,4]]
infomapClustering :: Assertion
infomapClustering = do
clusters <- runAlgo infomap
clusters @?= [[0,1,2,3,4]]
testGraph :: Graph 'U () () testGraph :: Graph 'U () ()
testGraph = mkGraphUfromEdges [(0,1),(1,2),(2,0),(2,3),(3,4),(4,2)] testGraph = mkGraphUfromEdges [(0,1),(1,2),(2,0),(2,3),(3,4),(4,2)]
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment