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:22:11 GMT
Github user manuzhang commented on a diff in the pull request:

    https://github.com/apache/incubator-gearpump/pull/223#discussion_r138876832
  
    --- Diff: core/src/main/scala/org/apache/gearpump/util/Graph.scala ---
    @@ -243,13 +259,34 @@ class Graph[N, E](vertexList: List[N], edgeList: List[(N, E, N)])
extends Serial
        * The node returned by Iterator is stable sorted.
        */
       def topologicalOrderIterator: Iterator[N] = {
    -    val newGraph = copy
    -    var output = List.empty[N]
    -
    -    while (!newGraph.isEmpty) {
    -      output ++= newGraph.removeZeroInDegree
    +    tryTopologicalOrderIterator.get
    +  }
    +
    +  private def tryTopologicalOrderIterator: Try[Iterator[N]] = {
    +    Try {
    +      val indegreeMap = mutable.Map.empty[N, Int]
    --- End diff --
    
    why not generate `indegreeMap` with `vertices.map` ?


---

Mime
View raw message