diff options
| author | Luke Kanies <luke@madstop.com> | 2008-02-13 14:55:14 -0600 |
|---|---|---|
| committer | Luke Kanies <luke@madstop.com> | 2008-02-13 14:55:14 -0600 |
| commit | a42c3ae7eba819053d8f01a339a9c865092d15e2 (patch) | |
| tree | d717814d67b1c9b68bfd04dbd107b616824e0be7 /lib | |
| parent | d406353d3435ed6c8f4949fb35a15411a7a14d80 (diff) | |
Fixed #1021 -- the problem was that my method of determining
the in-degree sometimes resulted in a lower number than the
number of in-edges.
Diffstat (limited to 'lib')
| -rw-r--r-- | lib/puppet/simple_graph.rb | 15 |
1 files changed, 9 insertions, 6 deletions
diff --git a/lib/puppet/simple_graph.rb b/lib/puppet/simple_graph.rb index 503e4814c..48f393f77 100644 --- a/lib/puppet/simple_graph.rb +++ b/lib/puppet/simple_graph.rb @@ -51,10 +51,12 @@ class Puppet::SimpleGraph # Create methods for returning the degree and edges. [:in, :out].each do |direction| - define_method("%s_degree" % direction) do - @adjacencies[direction].length - end - + # LAK:NOTE If you decide to create methods for directly + # testing the degree, you'll have to get the values and flatten + # the results -- you might have duplicate edges, which can give + # a false impression of what the degree is. That's just + # as expensive as just getting the edge list, so I've decided + # to only add this method. define_method("%s_edges" % direction) do @adjacencies[direction].values.flatten end @@ -126,8 +128,9 @@ class Puppet::SimpleGraph # Collect each of our vertices, with the number of in-edges each has. @vertices.each do |name, wrapper| - zeros << wrapper if wrapper.in_degree == 0 - degree[wrapper.vertex] = wrapper.in_edges + edges = wrapper.in_edges + zeros << wrapper if edges.length == 0 + degree[wrapper.vertex] = edges end # Iterate over each 0-degree vertex, decrementing the degree of |
