You are viewing a plain text version of this content. The canonical link for it is here.
Posted to reviews@spark.apache.org by dbtsai <gi...@git.apache.org> on 2015/11/02 07:32:19 UTC

[GitHub] spark pull request: [SPARK-11432][GraphX] Personalized PageRank sh...

Github user dbtsai commented on a diff in the pull request:

    https://github.com/apache/spark/pull/9386#discussion_r43599996
  
    --- Diff: graphx/src/main/scala/org/apache/spark/graphx/lib/PageRank.scala ---
    @@ -104,17 +104,25 @@ object PageRank extends Logging {
           graph: Graph[VD, ED], numIter: Int, resetProb: Double = 0.15,
           srcId: Option[VertexId] = None): Graph[Double, Double] =
       {
    +    val personalized = srcId isDefined
         // Initialize the PageRank graph with each edge attribute having
    -    // weight 1/outDegree and each vertex with attribute 1.0.
    +    // weight 1/outDegree and each vertex with attribute resetProb.
    +    // When running personalized pagerank, only the source vertex
    +    // has an attribute resetProb. All others are set to 0.
         var rankGraph: Graph[Double, Double] = graph
           // Associate the degree with each vertex
           .outerJoinVertices(graph.outDegrees) { (vid, vdata, deg) => deg.getOrElse(0) }
           // Set the weight on the edges based on the degree
           .mapTriplets( e => 1.0 / e.srcAttr, TripletFields.Src )
           // Set the vertex attributes to the initial pagerank values
    -      .mapVertices( (id, attr) => resetProb )
    +      .mapVertices( (id, attr) => {
    +        if (personalized) {
    +          if (id == srcId.get) resetProb else 0.0
    +        } else {
    +          resetProb
    +        }
    +      })
     
    -    val personalized = srcId isDefined
         val src: VertexId = srcId.getOrElse(-1L)
    --- End diff --
    
    Move up `val src: VertexId = srcId.getOrElse(-1L) ` to `val personalized = srcId isDefined`


---
If your project is set up for it, you can reply to this email and have your
reply appear on GitHub as well. If your project does not have this feature
enabled and wishes so, or if the feature is enabled but not working, please
contact infrastructure at infrastructure@apache.org or file a JIRA ticket
with INFRA.
---

---------------------------------------------------------------------
To unsubscribe, e-mail: reviews-unsubscribe@spark.apache.org
For additional commands, e-mail: reviews-help@spark.apache.org