Class: Vertex

Inherits:
Object
  • Object
show all
Defined in:
lib/mvGraph.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

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

#colorObject

Returns the value of attribute color.



179
180
181
# File 'lib/mvGraph.rb', line 179

def color
  @color
end

#distanceObject

Returns the value of attribute distance.



179
180
181
# File 'lib/mvGraph.rb', line 179

def distance
  @distance
end

#idObject

Returns the value of attribute id.



179
180
181
# File 'lib/mvGraph.rb', line 179

def id
  @id
end

#predecessorObject

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

Returns:

  • (Boolean)


191
192
193
# File 'lib/mvGraph.rb', line 191

def eql?(other_vertex)
  @id == other_vertex.id
end

#hashObject



195
196
197
# File 'lib/mvGraph.rb', line 195

def hash
  @id.hash
end

#to_sObject



199
200
201
# File 'lib/mvGraph.rb', line 199

def to_s
  "id: #{@id}, color: #{@color}, distance: #{@distance}, predecessor: \n\t\t #{@predecessor}"
end