def compute_post_order(graph, start_node)
      i = 1
      result = []
      visited = Set.new
      post_order_df = proc do |node|
        visited << node
        node.real_successors.each do |successor|
          post_order_df.call(successor) unless visited.include?(successor)
        end
        result << node
        node.post_order_number = i
        i += 1
      end
      post_order_df.call(start_node)
      result
    end
def compute_post_order(graph, start_node)
      i = 1
      result = []
      visited = Set.new
      post_order_df = proc do |node|
        visited << node
        node.real_successors.each do |successor|
          post_order_df.call(successor) unless visited.include?(successor)
        end
        result << node
        node.post_order_number = i
        i += 1
      end
      post_order_df.call(start_node)
      result
    end
Good idea: depth-first ordering. found some slides about it:
 http://pages.cs.wisc.edu/~fischer/cs701.f08/lectures/Lecture18.4up.pdf