Method: Puppet::Graph::SimpleGraph#path_between
- Defined in:
- lib/puppet/graph/simple_graph.rb
#path_between(f, t) ⇒ Object
Return an array of the edge-sets between a series of n+1 vertices (f=v0,v1,v2…t=vn)
connecting the two given vertices. The ith edge set is an array containing all the
edges between v(i) and v(i+1); these are (by definition) never empty.
* if f == t, the list is empty
* if they are adjacent the result is an array consisting of
a single array (the edges from f to t)
* and so on by induction on a vertex m between them
* if there is no path from f to t, the result is nil
This implementation is not particularly efficient; it’s used in testing where clarity
is more important than last-mile efficiency.
429 430 431 432 433 434 435 436 437 438 439 440 |
# File 'lib/puppet/graph/simple_graph.rb', line 429 def path_between(f, t) if f == t [] elsif direct_dependents_of(f).include?(t) [edges_between(f, t)] elsif dependents(f).include?(t) m = (dependents(f) & direct_dependencies_of(t)).first path_between(f, m) + path_between(m, t) else nil end end |