Skip to content

Commit 62c7b78

Browse files
committed
In Analytics, take PageRank numIter
1 parent d64e8d4 commit 62c7b78

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

graphx/src/main/scala/org/apache/spark/graphx/lib/Analytics.scala

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,12 +58,14 @@ object Analytics extends Logging {
5858
var outFname = ""
5959
var numEPart = 4
6060
var partitionStrategy: Option[PartitionStrategy] = None
61+
var numIterOpt: Option[Int] = None
6162

6263
options.foreach{
6364
case ("tol", v) => tol = v.toFloat
6465
case ("output", v) => outFname = v
6566
case ("numEPart", v) => numEPart = v.toInt
6667
case ("partStrategy", v) => partitionStrategy = Some(pickPartitioner(v))
68+
case ("numIter", v) => numIterOpt = Some(v.toInt)
6769
case (opt, _) => throw new IllegalArgumentException("Invalid option: " + opt)
6870
}
6971

@@ -80,7 +82,10 @@ object Analytics extends Logging {
8082
println("GRAPHX: Number of vertices " + graph.vertices.count)
8183
println("GRAPHX: Number of edges " + graph.edges.count)
8284

83-
val pr = graph.pageRank(tol).vertices.cache()
85+
val pr = (numIterOpt match {
86+
case Some(numIter) => PageRank.run(graph, numIter)
87+
case None => PageRank.runUntilConvergence(graph, tol)
88+
}).vertices.cache()
8489

8590
println("GRAPHX: Total rank: " + pr.map(_._2).reduce(_ + _))
8691

0 commit comments

Comments
 (0)