summaryrefslogtreecommitdiffstats
path: root/lib/puppet
diff options
context:
space:
mode:
Diffstat (limited to 'lib/puppet')
-rw-r--r--lib/puppet/simple_graph.rb7
1 files changed, 7 insertions, 0 deletions
diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb
index 73a6bdfed..c6afa4b68 100644
--- a/lib/puppet/simple_graph.rb
+++ b/lib/puppet/simple_graph.rb
@@ -116,6 +116,13 @@ class Puppet::SimpleGraph
def directed?
true
end
+
+ # Determine all of the leaf nodes below a given vertex.
+ def leaves(vertex, direction = :out)
+ tree = tree_from_vertex(vertex, direction)
+ l = tree.keys.find_all { |c| adjacent(c, :direction => direction).empty? }
+ return l
+ end
# Collect all of the edges that the passed events match. Returns
# an array of edges.