Class: Gem::Resolver::Molinillo::DependencyGraph::Vertex (Ruby 2.3.4)

In Files

  • rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb

Class/Module Index [+]

Quicksearch

Gem::Resolver::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
incoming_edges[RW]

@return [Array<Edge>] the edges of {#graph} that have `self` as their

{Edge#destination}
name[RW]

@return [String] the name of the vertex

outgoing_edges[RW]

@return [Array<Edge>] the edges of {#graph} that have `self` as their

{Edge#origin}
payload[RW]

@return [Object] the payload the vertex holds

root[RW]

@return [Boolean] whether the vertex is considered a root vertex

root?[RW]

@return [Boolean] whether the vertex is considered a root vertex

Public Class Methods

new(name, payload)

Initializes a vertex with the given name and payload. @param [String] name see {#name} @param [Object] payload see {#payload}

 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 188
def initialize(name, payload)
  @name = name
  @payload = payload
  @explicit_requirements = []
  @outgoing_edges = []
  @incoming_edges = []
end
            

Public Instance Methods

==(other)

@return [Boolean] whether the two vertices are equal, determined

by a recursive traversal of each {Vertex#successors}
 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 247
def ==(other)
  shallow_eql?(other) &&
    successors.to_set == other.successors.to_set
end
            
Also aliased as: eql?
ancestor?(other)

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 rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 280
def ancestor?(other)
  other.path_to?(self)
end
            
Also aliased as: is_reachable_from?
descendent?(other)
Alias for: path_to?
eql?(other)
Alias for: ==
hash()

@return [Fixnum] a hash for the vertex based upon its {#name}

 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 264
def hash
  name.hash
end
            
inspect()

@return [String] a string suitable for debugging

 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 241
def inspect
  "#{self.class}:#{name}(#{payload.inspect})"
end
            
is_reachable_from?(other)
Alias for: ancestor?
path_to?(other)

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 rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 271
def path_to?(other)
  equal?(other) || successors.any? { |v| v.path_to?(other) }
end
            
Also aliased as: descendent?
predecessors()

@return [Array<Vertex>] the vertices of {#graph} that have an edge with

`self` as their {Edge#destination}
 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 212
def predecessors
  incoming_edges.map(&:origin)
end
            
recursive_predecessors()

@return [Array<Vertex>] the vertices of {#graph} where `self` is a

{#descendent?}
 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 218
def recursive_predecessors
  vertices = predecessors
  vertices += vertices.map(&:recursive_predecessors).flatten(1)
  vertices.uniq!
  vertices
end
            
recursive_successors()

@return [Array<Vertex>] the vertices of {#graph} where `self` is an

{#ancestor?}
 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 233
def recursive_successors
  vertices = successors
  vertices += vertices.map(&:recursive_successors).flatten(1)
  vertices.uniq!
  vertices
end
            
requirements()

@return [Array<Object>] all of the requirements that required

this vertex
 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 198
def requirements
  incoming_edges.map(&:requirement) + explicit_requirements
end
            
shallow_eql?(other)

@param [Vertex] other the other vertex to compare to @return [Boolean] whether the two vertices are equal, determined

solely by {#name} and {#payload} equality
 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 255
def shallow_eql?(other)
  other &&
    name == other.name &&
    payload == other.payload
end
            
successors()

@return [Array<Vertex>] the vertices of {#graph} that have an edge with

`self` as their {Edge#origin}
 
               # File rubygems/resolver/molinillo/lib/molinillo/dependency_graph.rb, line 227
def successors
  outgoing_edges.map(&:destination)
end