Method: Puppet::Graph::SimpleGraph#initialize
- Defined in:
- lib/puppet/graph/simple_graph.rb
#initialize ⇒ SimpleGraph
All public methods of this class must maintain (assume ^ ensure) the following invariants, where “=~=” means equiv. up to order:
@in_to.keys =~= @out_to.keys =~= all vertices
@in_to.values.collect { |x| x.values }.flatten =~= @out_from.values.collect { |x| x.values }.flatten =~= all edges
@in_to[v1][v2] =~= @out_from[v2][v1] =~= all edges from v1 to v2
@in_to [v].keys =~= vertices with edges leading to v
@out_from[v].keys =~= vertices with edges leading from v
no operation may shed reference loops (for gc)
recursive operation must scale with the depth of the spanning trees, or better (e.g. no recursion over the set
of all vertices, etc.)
This class is intended to be used with DAGs. However, if the graph has a cycle, it will not cause non-termination of any of the algorithms.
28 29 30 31 32 33 |
# File 'lib/puppet/graph/simple_graph.rb', line 28 def initialize @in_to = {} @out_from = {} @upstream_from = {} @downstream_from = {} end |