aboutsummaryrefslogtreecommitdiff
path: root/graphx/src/test/scala
diff options
context:
space:
mode:
authorJoseph E. Gonzalez <joseph.e.gonzalez@gmail.com>2014-01-13 13:40:16 -0800
committerJoseph E. Gonzalez <joseph.e.gonzalez@gmail.com>2014-01-13 13:40:16 -0800
commit80e4d98dc656e20dacbd8cdbf92d4912673b42ae (patch)
tree22622dfd12a721ac8f773d8856602c63e18729c8 /graphx/src/test/scala
parent8ca97739741152cce30adfce80aee4462b5a04f2 (diff)
downloadspark-80e4d98dc656e20dacbd8cdbf92d4912673b42ae.tar.gz
spark-80e4d98dc656e20dacbd8cdbf92d4912673b42ae.tar.bz2
spark-80e4d98dc656e20dacbd8cdbf92d4912673b42ae.zip
Improving documentation and identifying potential bug in CC calculation.
Diffstat (limited to 'graphx/src/test/scala')
-rw-r--r--graphx/src/test/scala/org/apache/spark/graphx/lib/ConnectedComponentsSuite.scala30
1 files changed, 30 insertions, 0 deletions
diff --git a/graphx/src/test/scala/org/apache/spark/graphx/lib/ConnectedComponentsSuite.scala b/graphx/src/test/scala/org/apache/spark/graphx/lib/ConnectedComponentsSuite.scala
index 66612b381f..86da8f1b46 100644
--- a/graphx/src/test/scala/org/apache/spark/graphx/lib/ConnectedComponentsSuite.scala
+++ b/graphx/src/test/scala/org/apache/spark/graphx/lib/ConnectedComponentsSuite.scala
@@ -80,4 +80,34 @@ class ConnectedComponentsSuite extends FunSuite with LocalSparkContext {
}
} // end of reverse chain connected components
+ test("Connected Components on a Toy Connected Graph") {
+ withSpark { sc =>
+ // Create an RDD for the vertices
+ val users: RDD[(VertexID, (String, String))] =
+ sc.parallelize(Array((3L, ("rxin", "student")), (7L, ("jgonzal", "postdoc")),
+ (5L, ("franklin", "prof")), (2L, ("istoica", "prof")),
+ (4L, ("peter", "student"))))
+ // Create an RDD for edges
+ val relationships: RDD[Edge[String]] =
+ sc.parallelize(Array(Edge(3L, 7L, "collab"), Edge(5L, 3L, "advisor"),
+ Edge(2L, 5L, "colleague"), Edge(5L, 7L, "pi"),
+ Edge(4L, 0L, "student"), Edge(5L, 0L, "colleague")))
+ // Edges are:
+ // 2 ---> 5 ---> 3
+ // | \
+ // V \|
+ // 4 ---> 0 7
+ //
+ // Define a default user in case there are relationship with missing user
+ val defaultUser = ("John Doe", "Missing")
+ // Build the initial Graph
+ val graph = Graph(users, relationships, defaultUser)
+ val ccGraph = graph.connectedComponents(undirected = true)
+ val vertices = ccGraph.vertices.collect
+ for ( (id, cc) <- vertices ) {
+ assert(cc == 0)
+ }
+ }
+ } // end of toy connected components
+
}