summaryrefslogtreecommitdiffstats
path: root/lib/puppet/pgraph.rb
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-17 22:19:49 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-17 22:19:49 +0000
commit10dbb17ed1b2241618f13973d02e17de1dd4e44f (patch)
tree1619f774897304979ff26cf5dfc5df7eb53bfbb2 /lib/puppet/pgraph.rb
parentb01ffe6fa50e92a4586199096c1f6995ad8dd617 (diff)
downloadpuppet-10dbb17ed1b2241618f13973d02e17de1dd4e44f.tar.gz
puppet-10dbb17ed1b2241618f13973d02e17de1dd4e44f.tar.xz
puppet-10dbb17ed1b2241618f13973d02e17de1dd4e44f.zip
Some more graph optimizations; I think I am now close enough that I am basically just going to spend a bit more time making sure the modeling is right in the transactions, and then walk away for now.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1947 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib/puppet/pgraph.rb')
-rw-r--r--lib/puppet/pgraph.rb17
1 files changed, 9 insertions, 8 deletions
diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb
index 56363f9a9..ce7bc52b8 100644
--- a/lib/puppet/pgraph.rb
+++ b/lib/puppet/pgraph.rb
@@ -60,8 +60,8 @@ class Puppet::PGraph < GRATR::Digraph
# Determine all of the leaf nodes below a given vertex.
def leaves(vertex, type = :dfs)
tree = tree_from_vertex(vertex, type)
- leaves = tree.keys.find_all { |c| adjacent(c, :direction => :out).empty? }
- return leaves
+ l = tree.keys.find_all { |c| adjacent(c, :direction => :out).empty? }
+ return l
end
# Collect all of the edges that the passed events match. Returns
@@ -100,32 +100,33 @@ class Puppet::PGraph < GRATR::Digraph
# to the leaves instead
next unless vertex.is_a?(type)
- leaves = other.leaves(vertex)
- if leaves.empty?
+ #oleaves = other.leaves(vertex)
+ oleaves = other.adjacent(vertex, :direction => :out)
+ if oleaves.empty?
remove_vertex!(vertex)
next
end
# First create new edges for each of the :in edges
adjacent(vertex, :direction => :in, :type => :edges).each do |edge|
- leaves.each do |leaf|
+ oleaves.each do |leaf|
add_edge!(edge.source, leaf, edge.label)
if cyclic?
raise ArgumentError,
"%s => %s results in a loop" %
- [up, leaf]
+ [edge.source, leaf]
end
end
end
# Then for each of the out edges
adjacent(vertex, :direction => :out, :type => :edges).each do |edge|
- leaves.each do |leaf|
+ oleaves.each do |leaf|
add_edge!(leaf, edge.target, edge.label)
if cyclic?
raise ArgumentError,
"%s => %s results in a loop" %
- [leaf, down]
+ [leaf, edge.target]
end
end
end