Add test for mapReduceTriplets in GraphSuite

This commit is contained in:
Ankur Dave 2013-11-09 04:23:38 -08:00
parent bf4e45e685
commit aa24b0bbe8

View file

@ -33,6 +33,18 @@ class GraphSuite extends FunSuite with LocalSparkContext {
}
}
test("mapReduceTriplets") {
withSpark(new SparkContext("local", "test")) { sc =>
val n = 3
val star = Graph(sc.parallelize((1 to n).map(x => (0: Vid, x: Vid))))
val neighborDegreeSums = star.mapReduceTriplets(
edge => Array((edge.srcId, edge.dstAttr), (edge.dstId, edge.srcAttr)),
(a: Int, b: Int) => a + b)
assert(neighborDegreeSums.collect().toSet === (0 to n).map(x => (x, n)).toSet)
}
}
test("aggregateNeighbors") {
withSpark(new SparkContext("local", "test")) { sc =>
val n = 3