class Graphsrb::Node
This class represents a single entry in a adjacency list.
Attributes
vertex[R]
weight[R]
Public Class Methods
new(vertex_id, args={})
click to toggle source
Creates a new node
# File lib/graphsrb/node.rb, line 7 def initialize(vertex_id, args={}) @vertex = Graphsrb::Vertex.new(vertex_id) @weight = args.fetch(:weight, 1) end
Public Instance Methods
==(node)
click to toggle source
Compares two nodes. Two nodes are equal if their vertices
are equal.
# File lib/graphsrb/node.rb, line 18 def ==(node) vertex == node.vertex end
update_weight(w)
click to toggle source
Updates weight
# File lib/graphsrb/node.rb, line 13 def update_weight(w) @weight = w end