class Bundler::Molinillo::DependencyGraph::Vertex
A vertex in a {DependencyGraph} that encapsulates a {#name} and a {#payload}
Attributes
@return [Arrary<Object>] the explicit requirements that required
this vertex
@return [DependencyGraph] the graph this vertex is a node of
@return [String] the name of the vertex
@return [Object] the payload the vertex holds
Public Class Methods
@param [DependencyGraph] graph see {#graph} @param [String] name see {#name} @param [Object] payload see {#payload}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 177 def initialize(graph, name, payload) @graph = graph @name = name @payload = payload @explicit_requirements = [] end
Public Instance Methods
@return [Boolean] whether the two vertices are equal, determined
by a recursive traversal of each {Vertex#successors}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 227 def ==(other) shallow_eql?(other) && successors == other.successors end
Is there a path from `other` to `self` following edges in the dependency graph? @return true iff there is a path following edges within this {#graph}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 259 def ancestor?(other) predecessors.include?(other) || predecessors.any? { |v| v.ancestor?(other) } end
@return [Fixnum] a hash for the vertex based upon its {#name}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 243 def hash name.hash end
@return [Array<Edge>] the edges of {#graph} that have `self` as their
{Edge#destination}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 198 def incoming_edges graph.edges.select { |e| e.destination.shallow_eql?(self) } end
@return [String] a string suitable for debugging
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 221 def inspect "#{self.class}:#{name}(#{payload.inspect})" end
@return [Array<Edge>] the edges of {#graph} that have `self` as their
{Edge#origin}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 192 def outgoing_edges graph.edges.select { |e| e.origin.shallow_eql?(self) } end
Is there a path from `self` to `other` following edges in the dependency graph? @return true iff there is a path following edges within this {#graph}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 250 def path_to?(other) successors.include?(other) || successors.any? { |v| v.path_to?(other) } end
@return [Set<Vertex>] the vertices of {#graph} that have an edge with
`self` as their {Edge#destination}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 204 def predecessors incoming_edges.map(&:origin).to_set end
@return [Set<Vertex>] the vertices of {#graph} where `self` is an
{#ancestor?}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 216 def recursive_successors successors + successors.map(&:recursive_successors).reduce(Set.new, &:+) end
@return [Array<Object>] all of the requirements that required
this vertex
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 186 def requirements incoming_edges.map(&:requirements).flatten + explicit_requirements end
@return [Boolean] whether the two vertices are equal, determined
solely by {#name} and {#payload} equality
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 234 def shallow_eql?(other) other && name == other.name && payload == other.payload end
@return [Set<Vertex>] the vertices of {#graph} that have an edge with
`self` as their {Edge#origin}
# File lib/bundler/vendor/molinillo/lib/molinillo/dependency_graph.rb, line 210 def successors outgoing_edges.map(&:destination).to_set end