Class: Newral::Graphs::Edge
- Inherits:
-
Object
- Object
- Newral::Graphs::Edge
- Defined in:
- lib/newral/graphs/edge.rb
Instance Attribute Summary collapse
-
#cost ⇒ Object
Returns the value of attribute cost.
-
#data ⇒ Object
Returns the value of attribute data.
-
#directed ⇒ Object
Returns the value of attribute directed.
-
#end_node ⇒ Object
Returns the value of attribute end_node.
-
#start_node ⇒ Object
Returns the value of attribute start_node.
Instance Method Summary collapse
-
#initialize(key: nil, start_node: nil, end_node: nil, directed: false, cost: nil, data: nil) ⇒ Edge
constructor
A new instance of Edge.
- #key ⇒ Object
- #to_s ⇒ Object
Constructor Details
#initialize(key: nil, start_node: nil, end_node: nil, directed: false, cost: nil, data: nil) ⇒ Edge
Returns a new instance of Edge.
5 6 7 8 9 10 11 12 13 |
# File 'lib/newral/graphs/edge.rb', line 5 def initialize( key:nil, start_node: nil, end_node: nil, directed: false, cost: nil, data:nil ) @key = key @start_node = start_node @end_node = end_node @directed = directed @cost = cost @data = data end |
Instance Attribute Details
#cost ⇒ Object
Returns the value of attribute cost.
4 5 6 |
# File 'lib/newral/graphs/edge.rb', line 4 def cost @cost end |
#data ⇒ Object
Returns the value of attribute data.
4 5 6 |
# File 'lib/newral/graphs/edge.rb', line 4 def data @data end |
#directed ⇒ Object
Returns the value of attribute directed.
4 5 6 |
# File 'lib/newral/graphs/edge.rb', line 4 def directed @directed end |
#end_node ⇒ Object
Returns the value of attribute end_node.
4 5 6 |
# File 'lib/newral/graphs/edge.rb', line 4 def end_node @end_node end |
#start_node ⇒ Object
Returns the value of attribute start_node.
4 5 6 |
# File 'lib/newral/graphs/edge.rb', line 4 def start_node @start_node end |
Instance Method Details
#key ⇒ Object
15 16 17 |
# File 'lib/newral/graphs/edge.rb', line 15 def key @key || "#{ @start_node }#{ directed ? '=>' : '<=>' }#{ @end_node }" end |
#to_s ⇒ Object
19 20 21 |
# File 'lib/newral/graphs/edge.rb', line 19 def to_s key end |