Class: Graph::Edge

Inherits:
Thingy show all
Defined in:
lib/graph.rb

Overview

An edge in a graph.

Instance Attribute Summary collapse

Attributes inherited from Thingy

#attributes, #graph

Instance Method Summary collapse

Methods inherited from Thingy

#attributes?, #initialize_copy, #label

Constructor Details

#initialize(graph, from, to) ⇒ Edge

Create a new edge in graph from from to to.



554
555
556
557
558
# File 'lib/graph.rb', line 554

def initialize graph, from, to
  super graph
  self.from = from
  self.to = to
end

Instance Attribute Details

#fromObject

:nodoc:



549
550
551
# File 'lib/graph.rb', line 549

def from
  @from
end

#toObject

:nodoc:



549
550
551
# File 'lib/graph.rb', line 549

def to
  @to
end

Instance Method Details

#decorate(decorate) ⇒ Object

Sets the decorate attribute. Decorate connects the label to the deg with a line



564
565
566
# File 'lib/graph.rb', line 564

def decorate decorate
  self.attributes << "decorate = #{decorate}"
end

#to_sObject

Returns the edge in dot syntax.



572
573
574
575
576
577
578
579
# File 'lib/graph.rb', line 572

def to_s
  fromto = "%p -> %p" % [from.name, to.name]
  if self.attributes? then
    "%-20s [ %-20s ]" % [fromto, attributes.join(',')]
  else
    fromto
  end
end