# File lib/puppet/util/graph.rb, line 12
12:   def to_graph(graph = nil, &block)
13:     # Allow our calling function to send in a graph, so that we
14:     # can call this recursively with one graph.
15:     graph ||= Puppet::SimpleGraph.new
16: 
17:     self.each do |child|
18:       unless block_given? and ! yield(child)
19:         graph.add_edge(self, child)
20: 
21:         child.to_graph(graph, &block) if child.respond_to?(:to_graph)
22:       end
23:     end
24: 
25:     # Do a topsort, which will throw an exception if the graph is cyclic.
26: 
27:     graph
28:   end