Github user manuzhang commented on a diff in the pull request:
https://github.com/apache/incubator-gearpump/pull/223#discussion_r138883853
--- 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
--- End diff --
Then return a `Try` is better since the caller will be aware this method
may fail then.
---