class Graphsrb::Vertex

This class represents a graph vertex.

Attributes

id[R]

Public Class Methods

new(id) click to toggle source

Creates a vertex given its id, a nonnegative integer.

# File lib/graphsrb/vertex.rb, line 7
def initialize(id)
  raise Graphsrb::VertexInitializationError, 'Vertex id may not be nil' if id.nil?
  @id = id
end

Public Instance Methods

!=(vertex) click to toggle source
# File lib/graphsrb/vertex.rb, line 17
def !=(vertex)
  id != vertex.id
end
==(vertex) click to toggle source

Compares two vertices. Two vertices are equal if their +id+s are equal.

# File lib/graphsrb/vertex.rb, line 13
def ==(vertex)
  id == vertex.id
end
eql?(other) click to toggle source
# File lib/graphsrb/vertex.rb, line 21
def eql?(other)
  self == other
end
hash() click to toggle source
# File lib/graphsrb/vertex.rb, line 29
def hash
  self.id
end
to_s() click to toggle source
# File lib/graphsrb/vertex.rb, line 25
def to_s
  self.id.to_s
end