You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@gearpump.apache.org by ma...@apache.org on 2017/03/03 13:08:02 UTC

incubator-gearpump git commit: [GEARPUMP-288] Skip getAcyclicCopy on acyclic graph

Repository: incubator-gearpump
Updated Branches:
  refs/heads/master 07d8d51e7 -> 4d8c02dfe


[GEARPUMP-288] Skip getAcyclicCopy on acyclic graph

Author: manuzhang <ow...@gmail.com>

Closes #166 from manuzhang/GEARPUMP-288.


Project: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/repo
Commit: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/commit/4d8c02df
Tree: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/tree/4d8c02df
Diff: http://git-wip-us.apache.org/repos/asf/incubator-gearpump/diff/4d8c02df

Branch: refs/heads/master
Commit: 4d8c02dfe878aac692e13e97054a2d7b6b7c3148
Parents: 07d8d51
Author: manuzhang <ow...@gmail.com>
Authored: Fri Mar 3 21:07:28 2017 +0800
Committer: manuzhang <ow...@gmail.com>
Committed: Fri Mar 3 21:07:37 2017 +0800

----------------------------------------------------------------------
 core/src/main/scala/org/apache/gearpump/util/Graph.scala | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/incubator-gearpump/blob/4d8c02df/core/src/main/scala/org/apache/gearpump/util/Graph.scala
----------------------------------------------------------------------
diff --git a/core/src/main/scala/org/apache/gearpump/util/Graph.scala b/core/src/main/scala/org/apache/gearpump/util/Graph.scala
index 2ea552c..609b133 100644
--- a/core/src/main/scala/org/apache/gearpump/util/Graph.scala
+++ b/core/src/main/scala/org/apache/gearpump/util/Graph.scala
@@ -318,8 +318,12 @@ class Graph[N, E](vertexList: List[N], edgeList: List[(N, E, N)]) extends Serial
    * http://www.drdobbs.com/database/topological-sorting/184410262
    */
   def topologicalOrderWithCirclesIterator: Iterator[N] = {
-    val topo = getAcyclicCopy().topologicalOrderIterator
-    topo.flatMap(_.sortBy(_indexs(_)).iterator)
+    if (hasCycle()) {
+      val topo = getAcyclicCopy().topologicalOrderIterator
+      topo.flatMap(_.sortBy(_indexs(_)).iterator)
+    } else {
+      topologicalOrderIterator
+    }
   }
 
   private def getAcyclicCopy(): Graph[mutable.MutableList[N], E] = {