Class: Tangle::Directed::Edge
Overview
An edge in a directed graph
Instance Attribute Summary collapse
-
#head ⇒ Object
readonly
Returns the value of attribute head.
-
#tail ⇒ Object
readonly
Returns the value of attribute tail.
Attributes inherited from Edge
Attributes included from Mixin::Initialize
Instance Method Summary collapse
- #each_vertex(&block) ⇒ Object
- #head?(vertex) ⇒ Boolean
- #tail?(vertex) ⇒ Boolean
- #to_s ⇒ Object (also: #inspect)
Methods inherited from Edge
#[], #include?, #initialize, #loop?, #walk
Constructor Details
This class inherits a constructor from Tangle::Edge
Instance Attribute Details
#head ⇒ Object (readonly)
Returns the value of attribute head.
9 10 11 |
# File 'lib/tangle/directed/edge.rb', line 9 def head @head end |
#tail ⇒ Object (readonly)
Returns the value of attribute tail.
9 10 11 |
# File 'lib/tangle/directed/edge.rb', line 9 def tail @tail end |
Instance Method Details
#each_vertex(&block) ⇒ Object
19 20 21 |
# File 'lib/tangle/directed/edge.rb', line 19 def each_vertex(&block) [@tail, @head].each(&block) end |
#head?(vertex) ⇒ Boolean
11 12 13 |
# File 'lib/tangle/directed/edge.rb', line 11 def head?(vertex) @head == vertex end |
#tail?(vertex) ⇒ Boolean
15 16 17 |
# File 'lib/tangle/directed/edge.rb', line 15 def tail?(vertex) @tail == vertex end |
#to_s ⇒ Object Also known as: inspect
23 24 25 |
# File 'lib/tangle/directed/edge.rb', line 23 def to_s "{#{@tail}-->#{@head}}" end |