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.
11 12 13 |
# File 'lib/tangle/directed/edge.rb', line 11 def head @head end |
#tail ⇒ Object (readonly)
Returns the value of attribute tail.
11 12 13 |
# File 'lib/tangle/directed/edge.rb', line 11 def tail @tail end |
Instance Method Details
#each_vertex(&block) ⇒ Object
21 22 23 |
# File 'lib/tangle/directed/edge.rb', line 21 def each_vertex(&block) [@tail, @head].each(&block) end |
#head?(vertex) ⇒ Boolean
13 14 15 |
# File 'lib/tangle/directed/edge.rb', line 13 def head?(vertex) @head == vertex end |
#tail?(vertex) ⇒ Boolean
17 18 19 |
# File 'lib/tangle/directed/edge.rb', line 17 def tail?(vertex) @tail == vertex end |
#to_s ⇒ Object Also known as: inspect
25 26 27 |
# File 'lib/tangle/directed/edge.rb', line 25 def to_s "{#{@tail}-->#{@head}}" end |