Class: MGraph::Edge

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(a, b) ⇒ Edge

Returns a new instance of Edge.



7
8
9
10
# File 'lib/mgraph/edge.rb', line 7

def initialize a, b
  @vertices = [a, b].to_set.freeze
  freeze
end

Instance Attribute Details

#verticesObject (readonly)

Returns the value of attribute vertices.



5
6
7
# File 'lib/mgraph/edge.rb', line 5

def vertices
  @vertices
end

Instance Method Details

#==(other) ⇒ Object Also known as: eql?



12
13
14
# File 'lib/mgraph/edge.rb', line 12

def == other
  @vertices == other.vertices
end

#hashObject



17
18
19
# File 'lib/mgraph/edge.rb', line 17

def hash
  self.class.hash ^ @vertices.hash
end