Class: Graph::Edge
Overview
An edge in a graph.
Instance Attribute Summary collapse
-
#from ⇒ Object
Returns the value of attribute from.
-
#to ⇒ Object
Returns the value of attribute to.
Attributes inherited from Thingy
Instance Method Summary collapse
-
#initialize(graph, from, to) ⇒ Edge
constructor
Create a new edge in
graphfromfromtoto. -
#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.
475 476 477 478 479 |
# File 'lib/graph.rb', line 475 def initialize graph, from, to super graph self.from = from self.to = to end |
Instance Attribute Details
#from ⇒ Object
Returns the value of attribute from.
470 471 472 |
# File 'lib/graph.rb', line 470 def from @from end |
#to ⇒ Object
Returns the value of attribute to.
470 471 472 |
# File 'lib/graph.rb', line 470 def to @to end |
Instance Method Details
#to_s ⇒ Object
Returns the edge in dot syntax.
484 485 486 487 488 489 490 491 |
# File 'lib/graph.rb', line 484 def to_s fromto = "%p -> %p" % [from.name, to.name] if self.attributes? then "%-20s [ %-20s ]" % [fromto, attributes.join(',')] else fromto end end |