# 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:                 if child.respond_to?(:to_graph)
22:                     child.to_graph(graph, &block)
23:                 end
24:             end
25:         end
26: 
27:         # Do a topsort, which will throw an exception if the graph is cyclic.
28: 
29:         graph
30:     end