@@ -233,7 +233,37 @@ class PageRankSuite extends SparkFunSuite with LocalSparkContext {
233233 assert(totalIters == 19 )
234234 assert(iterAfterHalfCheckPoint == 18 )
235235 }
236- } // end of Grid PageRank
236+ } // end of Grid PageRank with checkpoint
237+
238+ test(" Grid PageRank with checkpoint without intermediate normalization" ) {
239+ withSpark { sc =>
240+ // Check that 6 iterations in a row are equivalent
241+ // to 3 times 2 iterations without intermediate normalization
242+ val rows = 10
243+ val cols = 10
244+ val resetProb = 0.15
245+ val gridGraph = GraphGenerators .gridGraph(sc, rows, cols).cache()
246+
247+ val ranksA : Array [(VertexId , Double )] = PageRank .runWithOptions(
248+ gridGraph, numIter = 6 , resetProb, srcId = None , normalized = true
249+ ).vertices.collect()
250+
251+ val preRankGraph1 = PageRank .runWithOptions(
252+ gridGraph, numIter = 2 , resetProb, srcId = None , normalized = false
253+ )
254+
255+ val preRankGraph2 = PageRank .runWithOptionsWithPreviousPageRank(
256+ gridGraph, numIter = 2 , resetProb, srcId = None , normalized = false , preRankGraph1
257+ )
258+
259+ val ranksB : Array [(VertexId , Double )] = PageRank .runWithOptionsWithPreviousPageRank(
260+ gridGraph, numIter = 2 , resetProb, srcId = None , normalized = true , preRankGraph2
261+ ).vertices.collect()
262+
263+ // assert that all scores are equal
264+ assert(ranksA.zip(ranksB).forall{ case (rankA, rankB) => rankA == rankB })
265+ }
266+ } // end of Grid PageRank with checkpoint without intermediate normalization
237267
238268 test(" Chain PageRank" ) {
239269 withSpark { sc =>
0 commit comments