# File lib/puppet/simple_graph.rb, line 321
321:     def splice!(other, type)
322:         # We have to get the container list via a topological sort on the
323:         # configuration graph, because otherwise containers that contain
324:         # other containers will add those containers back into the
325:         # graph.  We could get a similar affect by only setting relationships
326:         # to container leaves, but that would result in many more
327:         # relationships.
328:         containers = other.topsort.find_all { |v| v.is_a?(type) and vertex?(v) }
329:         containers.each do |container|
330:             # Get the list of children from the other graph.
331:             children = other.adjacent(container, :direction => :out)
332: 
333:             # Just remove the container if it's empty.
334:             if children.empty?
335:                 remove_vertex!(container)
336:                 next
337:             end
338: 
339:             # First create new edges for each of the :in edges
340:             [:in, :out].each do |dir|
341:                 edges = adjacent(container, :direction => dir, :type => :edges)
342:                 edges.each do |edge|
343:                     children.each do |child|
344:                         if dir == :in
345:                             s = edge.source
346:                             t = child
347:                         else
348:                             s = child
349:                             t = edge.target
350:                         end
351: 
352:                         add_edge(s, t, edge.label)
353:                     end
354: 
355:                     # Now get rid of the edge, so remove_vertex! works correctly.
356:                     remove_edge!(edge)
357:                 end
358:             end
359:             remove_vertex!(container)
360:         end
361:     end