Module: Puppet::Util::Graph
- Defined in:
- lib/vendor/puppet/util/graph.rb
Overview
A module that handles the small amount of graph stuff in Puppet.
Instance Method Summary collapse
-
#to_graph(graph = nil, &block) ⇒ Object
Make a graph where each of our children gets converted to the receiving end of an edge.
Instance Method Details
#to_graph(graph = nil, &block) ⇒ Object
Make a graph where each of our children gets converted to the receiving end of an edge. Call the same thing on all of our children, optionally using a block
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/vendor/puppet/util/graph.rb', line 9 def to_graph(graph = nil, &block) # Allow our calling function to send in a graph, so that we # can call this recursively with one graph. graph ||= Puppet::SimpleGraph.new self.each do |child| unless block_given? and ! yield(child) graph.add_edge(self, child) child.to_graph(graph, &block) if child.respond_to?(:to_graph) end end # Do a topsort, which will throw an exception if the graph is cyclic. graph end |