Class: Graphsrb::Node
- Inherits:
-
Object
- Object
- Graphsrb::Node
- Defined in:
- lib/graphsrb/node.rb
Overview
This class represents a single entry in a adjacency list.
Instance Attribute Summary collapse
-
#vertex ⇒ Object
readonly
Returns the value of attribute vertex.
-
#weight ⇒ Object
readonly
Returns the value of attribute weight.
Instance Method Summary collapse
-
#==(node) ⇒ Object
Compares two nodes.
-
#initialize(vertex_id, args = {}) ⇒ Node
constructor
Creates a new node.
-
#update_weight(w) ⇒ Object
Updates weight.
Constructor Details
Instance Attribute Details
#vertex ⇒ Object (readonly)
Returns the value of attribute vertex.
4 5 6 |
# File 'lib/graphsrb/node.rb', line 4 def vertex @vertex end |
#weight ⇒ Object (readonly)
Returns the value of attribute weight.
4 5 6 |
# File 'lib/graphsrb/node.rb', line 4 def weight @weight end |
Instance Method Details
#==(node) ⇒ Object
Compares two nodes. Two nodes are equal if their vertices are equal.
18 19 20 |
# File 'lib/graphsrb/node.rb', line 18 def ==(node) vertex == node.vertex end |
#update_weight(w) ⇒ Object
Updates weight
13 14 15 |
# File 'lib/graphsrb/node.rb', line 13 def update_weight(w) @weight = w end |