Method: Puppet::Graph::SimpleGraph#add_edge
- Defined in:
- lib/puppet/graph/simple_graph.rb
#add_edge(e, *a) ⇒ Object
Add a new edge. The graph user has to create the edge instance, since they have to specify what kind of edge it is.
301 302 303 304 305 306 307 308 309 310 311 312 313 314 |
# File 'lib/puppet/graph/simple_graph.rb', line 301 def add_edge(e, *a) return add_relationship(e, *a) unless a.empty? e = Puppet::Relationship.from_data_hash(e) if e.is_a?(Hash) @upstream_from.clear @downstream_from.clear add_vertex(e.source) add_vertex(e.target) # Avoid multiple lookups here. This code is performance critical arr = (@in_to[e.target][e.source] ||= []) arr << e unless arr.include?(e) arr = (@out_from[e.source][e.target] ||= []) arr << e unless arr.include?(e) end |