summaryrefslogtreecommitdiffstats
path: root/lib
diff options
context:
space:
mode:
authorluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-29 00:01:52 +0000
committerluke <luke@980ebf18-57e1-0310-9a29-db15c13687c0>2006-12-29 00:01:52 +0000
commitc4c3d77c58ae07560eafe838abbbf8271d923e57 (patch)
tree75b3b6ed486bcf4d32b8d73fc286f4d572c5e606 /lib
parentd07570b78d6c6cc670b4e6c770fb409b64c5b24d (diff)
downloadpuppet-c4c3d77c58ae07560eafe838abbbf8271d923e57.tar.gz
puppet-c4c3d77c58ae07560eafe838abbbf8271d923e57.tar.xz
puppet-c4c3d77c58ae07560eafe838abbbf8271d923e57.zip
Some tweaks to graph splicing, although I do not think it will be enough to handle some of the edge cases.
git-svn-id: https://reductivelabs.com/svn/puppet/trunk@1981 980ebf18-57e1-0310-9a29-db15c13687c0
Diffstat (limited to 'lib')
-rw-r--r--lib/puppet/pgraph.rb56
1 files changed, 37 insertions, 19 deletions
diff --git a/lib/puppet/pgraph.rb b/lib/puppet/pgraph.rb
index bd023d576..de89e0a71 100644
--- a/lib/puppet/pgraph.rb
+++ b/lib/puppet/pgraph.rb
@@ -96,7 +96,8 @@ class Puppet::PGraph < GRATR::Digraph
def splice!(other, type)
vertices.find_all { |v| v.is_a?(type) }.each do |vertex|
# Get the list of children from the other graph.
- children = other.adjacent(vertex, :direction => :out)
+ #children = other.adjacent(vertex, :direction => :out)
+ children = other.leaves(vertex)
# Just remove the container if it's empty.
if children.empty?
@@ -107,29 +108,46 @@ class Puppet::PGraph < GRATR::Digraph
# First create new edges for each of the :in edges
[:in, :out].each do |dir|
adjacent(vertex, :direction => dir, :type => :edges).each do |edge|
- children.each do |leaf|
- if dir == :in
- s = edge.source
- t = leaf
- else
- s = leaf
- t = edge.target
- end
+ if dir == :in
+ nvertex = edge.source
+ else
+ nvertex = edge.target
+ end
+ if nvertex.is_a?(type)
+ neighbors = other.leaves(nvertex)
+ else
+ neighbors = [nvertex]
+ end
- # It *appears* that we're having a problem
- # with multigraphs.
- next if edge?(s, t)
- add_edge!(s, t, edge.label)
- if cyclic?
- raise ArgumentError,
- "%s => %s results in a loop" %
- [s, t]
+ children.each do |child|
+ neighbors.each do |neighbor|
+ if dir == :in
+ s = neighbor
+ t = child
+ else
+ s = child
+ t = neighbor
+ end
+ if s.is_a?(type)
+ raise "Source %s is still a container" % s
+ end
+ if t.is_a?(type)
+ raise "Target %s is still a container" % t
+ end
+
+ # It *appears* that we're having a problem
+ # with multigraphs.
+ next if edge?(s, t)
+ add_edge!(s, t, edge.label)
+ if cyclic?
+ raise ArgumentError,
+ "%s => %s results in a loop" %
+ [s, t]
+ end
end
end
end
end
-
- # And finally, remove the vertex entirely.
remove_vertex!(vertex)
end
end