Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix louvain's result format #2

Merged
merged 1 commit into from
Oct 20, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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)
}
}