Class: Vertex
- Inherits:
-
Object
- Object
- Vertex
- Defined in:
- lib/mvGraph.rb
Instance Attribute Summary collapse
-
#color ⇒ Object
Returns the value of attribute color.
-
#distance ⇒ Object
Returns the value of attribute distance.
-
#id ⇒ Object
Returns the value of attribute id.
-
#predecessor ⇒ Object
Returns the value of attribute predecessor.
Instance Method Summary collapse
- #==(other_vertex) ⇒ Object
- #eql?(other_vertex) ⇒ Boolean
- #hash ⇒ Object
-
#initialize(id) ⇒ Vertex
constructor
A new instance of Vertex.
- #to_s ⇒ Object
Constructor Details
#initialize(id) ⇒ Vertex
Returns a new instance of Vertex.
180 181 182 183 184 185 |
# File 'lib/mvGraph.rb', line 180 def initialize(id) @id = id @color = "white" @distance = 2**32 @predecessor = nil end |
Instance Attribute Details
#color ⇒ Object
Returns the value of attribute color.
179 180 181 |
# File 'lib/mvGraph.rb', line 179 def color @color end |
#distance ⇒ Object
Returns the value of attribute distance.
179 180 181 |
# File 'lib/mvGraph.rb', line 179 def distance @distance end |
#id ⇒ Object
Returns the value of attribute id.
179 180 181 |
# File 'lib/mvGraph.rb', line 179 def id @id end |
#predecessor ⇒ Object
Returns the value of attribute predecessor.
179 180 181 |
# File 'lib/mvGraph.rb', line 179 def predecessor @predecessor end |
Instance Method Details
#==(other_vertex) ⇒ Object
187 188 189 |
# File 'lib/mvGraph.rb', line 187 def ==(other_vertex) @id == other_vertex.id end |
#eql?(other_vertex) ⇒ Boolean
191 192 193 |
# File 'lib/mvGraph.rb', line 191 def eql?(other_vertex) @id == other_vertex.id end |
#hash ⇒ Object
195 196 197 |
# File 'lib/mvGraph.rb', line 195 def hash @id.hash end |
#to_s ⇒ Object
199 200 201 |
# File 'lib/mvGraph.rb', line 199 def to_s "id: #{@id}, color: #{@color}, distance: #{@distance}, predecessor: \n\t\t #{@predecessor}" end |