class Graph::Edge

Attributes

from[R]
graph[R]
key[R]
to[R]
weight[RW]

Public Class Methods

new(from, to, weight: 1) click to toggle source
# File lib/graph/edge.rb, line 5
def initialize(from, to, weight: 1)
  @from = from
  @to = to
  @key = "from_#{from.key}_to_#{to.key}"
  @weight = weight
end

Public Instance Methods

to_h() click to toggle source
# File lib/graph/edge.rb, line 12
def to_h
  { from: from.key, to: to.key, weight: weight }
end

Private Instance Methods

add_to(graph) click to toggle source
# File lib/graph/edge.rb, line 18
def add_to(graph)
  @graph = graph
end