class Bundler::Molinillo::DependencyGraph::Vertex

A vertex in a {DependencyGraph} that encapsulates a {#name} and a {#payload}

Attributes

explicit_requirements[R]

@return [Arrary<Object>] the explicit requirements that required

this vertex
graph[RW]

@return [DependencyGraph] the graph this vertex is a node of

name[RW]

@return [String] the name of the vertex

payload[RW]

@return [Object] the payload the vertex holds

Public Class Methods

new(graph, name, payload) click to toggle source

@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

==(other) click to toggle source

@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
Also aliased as: eql?
ancestor?(other) click to toggle source

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
Also aliased as: is_reachable_from?
descendent?(other)
Alias for: path_to?
eql?(other)
Alias for: ==
hash() click to toggle source

@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
incoming_edges() click to toggle source

@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
inspect() click to toggle source

@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
is_reachable_from?(other)
Alias for: ancestor?
outgoing_edges() click to toggle source

@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
path_to?(other) click to toggle source

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
Also aliased as: descendent?
predecessors() click to toggle source

@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
recursive_successors() click to toggle source

@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
requirements() click to toggle source

@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
shallow_eql?(other) click to toggle source

@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
successors() click to toggle source

@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