Class: MGraph::Edge
- Inherits:
-
Object
- Object
- MGraph::Edge
- Defined in:
- lib/mgraph/edge.rb
Instance Attribute Summary collapse
-
#vertices ⇒ Object
readonly
Returns the value of attribute vertices.
Instance Method Summary collapse
- #==(other) ⇒ Object (also: #eql?)
- #hash ⇒ Object
-
#initialize(a, b) ⇒ Edge
constructor
A new instance of Edge.
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
#vertices ⇒ Object (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 |
#hash ⇒ Object
17 18 19 |
# File 'lib/mgraph/edge.rb', line 17 def hash self.class.hash ^ @vertices.hash end |