Class: Graph::Edge
Overview
An edge in a graph.
Instance Attribute Summary collapse
-
#from ⇒ Object
:nodoc:.
-
#to ⇒ Object
:nodoc:.
Attributes inherited from Thingy
Instance Method Summary collapse
-
#decorate(decorate) ⇒ Object
Sets the decorate attribute.
-
#initialize(graph, from, to) ⇒ Edge
constructor
Create a new edge in
graph
fromfrom
toto
. -
#to_s ⇒ Object
Returns the edge in dot syntax.
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
.
570 571 572 573 574 |
# File 'lib/graph.rb', line 570 def initialize graph, from, to super graph self.from = from self.to = to end |
Instance Attribute Details
Instance Method Details
#decorate(decorate) ⇒ Object
Sets the decorate attribute. Decorate connects the label to the deg with a line
580 581 582 |
# File 'lib/graph.rb', line 580 def decorate decorate self.attributes << "decorate = #{decorate}" end |
#to_s ⇒ Object
Returns the edge in dot syntax.
588 589 590 591 592 593 594 595 |
# File 'lib/graph.rb', line 588 def to_s fromto = "%p -> %p" % [from.name, to.name] if self.attributes? then "%-20s [ %-20s ]" % [fromto, attributes.join(',')] else fromto end end |