gearpump-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From manuzhang <...@git.apache.org>
Subject [GitHub] incubator-gearpump pull request #223: [GEARPUMP-349] Optimize Graph topologi...
Date Thu, 14 Sep 2017 12:07:14 GMT
Github user manuzhang commented on a diff in the pull request:

    https://github.com/apache/incubator-gearpump/pull/223#discussion_r138873545
  
    --- Diff: core/src/main/scala/org/apache/gearpump/util/Graph.scala ---
    @@ -81,28 +86,35 @@ class Graph[N, E](vertexList: List[N], edgeList: List[(N, E, N)])
extends Serial
        * out degree
        */
       def outDegreeOf(node: N): Int = {
    -    edges.count(_._1 == node)
    +    outgoingEdgesOf(node).size
       }
     
       /**
        * in degree
        */
       def inDegreeOf(node: N): Int = {
    -    edges.count(_._3 == node)
    +    incomingEdgesOf(node).size
       }
     
       /**
        * out going edges.
        */
       def outgoingEdgesOf(node: N): List[(N, E, N)] = {
    -    edges.filter(_._1 == node)
    +    _outEdges.getOrElse(node, List.empty)
       }
     
       /**
        * incoming edges.
        */
       def incomingEdgesOf(node: N): List[(N, E, N)] = {
    -    edges.filter(_._3 == node)
    +    _inEdges.getOrElse(node, List.empty)
    +  }
    +
    +  /**
    +   * adjacent vertices.
    +   */
    +  def adjacentVertices(node: N): List[N] = {
    --- End diff --
    
    how about vertices of incoming edges ?


---

Mime
View raw message