class Graph::Node

Nodes in the graph.

Public Class Methods

new(graph, name) click to toggle source

Create a new Node. Takes a parent graph and a name.

Calls superclass method
# File lib/graph.rb, line 598
def initialize graph, name
  super graph
  self.name = name
end

Public Instance Methods

>>(name) click to toggle source

Create a new node with name and an edge between them pointing from self to the new node.

# File lib/graph.rb, line 607
def >> name
  self[name] # creates node and edge
  self
end
[](dep_name) click to toggle source

Returns the edge between self and dep_name.

# File lib/graph.rb, line 617
def [] dep_name
  graph.edges[name][dep_name]
end
connected?() click to toggle source

Is this node connected to the graph?

# File lib/graph.rb, line 582
def connected?
  edges = graph.edges

  edges.include?(name) or edges.any? { |from, deps| deps.include? name }
end
orphan?() click to toggle source

Is this node an orphan? (ie, not connected?)

# File lib/graph.rb, line 591
def orphan?
  not connected?
end
to_s() click to toggle source

Returns the node in dot syntax.

# File lib/graph.rb, line 624
def to_s
  if self.attributes? then
    "%-20p [ %-20s ]" % [name, attributes.join(',')]
  else
    "#{name.inspect}"
  end
end