Class: GraphUtils::DirectedEdge
- Inherits:
-
Object
- Object
- GraphUtils::DirectedEdge
- Defined in:
- lib/GraphUtils.rb
Overview
Represents a directed edge in a graph.
Instance Attribute Summary collapse
-
#endVertex ⇒ Object
readonly
Returns the value of attribute endVertex.
-
#startVertex ⇒ Object
readonly
Returns the value of attribute startVertex.
Instance Method Summary collapse
- #==(edge) ⇒ Object
- #include?(v) ⇒ Boolean
-
#initialize(startVertex, endVertex) ⇒ DirectedEdge
constructor
A new instance of DirectedEdge.
- #to_s ⇒ Object
Constructor Details
#initialize(startVertex, endVertex) ⇒ DirectedEdge
Returns a new instance of DirectedEdge.
206 207 208 209 |
# File 'lib/GraphUtils.rb', line 206 def initialize(startVertex, endVertex) @startVertex = startVertex @endVertex = endVertex end |
Instance Attribute Details
#endVertex ⇒ Object (readonly)
Returns the value of attribute endVertex.
205 206 207 |
# File 'lib/GraphUtils.rb', line 205 def endVertex @endVertex end |
#startVertex ⇒ Object (readonly)
Returns the value of attribute startVertex.
205 206 207 |
# File 'lib/GraphUtils.rb', line 205 def startVertex @startVertex end |
Instance Method Details
#==(edge) ⇒ Object
215 216 217 |
# File 'lib/GraphUtils.rb', line 215 def ==(edge) edge.kind_of?(DirectedEdge) and @startVertex == edge.startVertex and @endVertex == edge.endVertex end |
#include?(v) ⇒ Boolean
211 212 213 |
# File 'lib/GraphUtils.rb', line 211 def include?(v) v == startVertex or v == endVertex end |
#to_s ⇒ Object
219 220 221 |
# File 'lib/GraphUtils.rb', line 219 def to_s @startVertex.to_s + " -> " + @endVertex.to_s end |