Skip to content
This repository has been archived by the owner on Oct 18, 2021. It is now read-only.

Commit

Permalink
Merge pull request #165 from Nicole00/louvain
Browse files Browse the repository at this point in the history
fix louvain's result format
  • Loading branch information
Nicole00 authored Oct 14, 2021
2 parents cb3186c + 8a83712 commit 4cd75f0
Show file tree
Hide file tree
Showing 3 changed files with 29 additions and 3 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -365,9 +365,8 @@ object CommUtil {
// return the collections of communities
def getCommunities(G: Graph[VertexData, Double]): RDD[Row] = {
val communities = G.vertices
.map(x => {
Row(x._1, x._2.cId)
})
.flatMapValues(_.innerVertices)
.map(value => { Row(value._2, value._1) })
communities
}
}
Expand Down
19 changes: 19 additions & 0 deletions nebula-algorithm/src/test/resources/edge_noWeight.csv
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
1 2
1 7
1 4
2 0
2 4
2 5
2 6
3 0
3 7
4 0
4 10
5 7
5 11
6 7
6 11
8 9
8 10
8 11
9 12
Original file line number Diff line number Diff line change
Expand Up @@ -18,5 +18,13 @@ class LouvainAlgoSuite {
val louvainConfig = new LouvainConfig(5, 2, 1.0)
val louvainResult = LouvainAlgo.apply(spark, data, louvainConfig, false)
assert(louvainResult.count() == 4)

val dataWithoutWith = spark.read
.option("header", false)
.option("delimiter", " ")
.csv("src/test/resources/edge_noWeight.csv")
.select("_c0", "_c1")
val louvainResult1 = LouvainAlgo.apply(spark, dataWithoutWith, louvainConfig, false)
assert(louvainResult1.count() == 13)
}
}

0 comments on commit 4cd75f0

Please sign in to comment.