Class: NetworkX::CurrentEdge
- Inherits:
-
Object
- Object
- NetworkX::CurrentEdge
- Defined in:
- lib/networkx/flow/utils.rb
Overview
Helper class for preflow push algorithm
Instance Attribute Summary collapse
-
#curr ⇒ Object
readonly
Returns the value of attribute curr.
-
#edges ⇒ Object
readonly
Returns the value of attribute edges.
Instance Method Summary collapse
-
#get ⇒ Object
-
#initialize(edges) ⇒ CurrentEdge
constructor
A new instance of CurrentEdge.
-
#move_to_next ⇒ Object
Constructor Details
#initialize(edges) ⇒ CurrentEdge
Returns a new instance of CurrentEdge.
6 7 8 9 10 11 12 |
# File 'lib/networkx/flow/utils.rb', line 6 def initialize(edges) @edges = edges @index = {} @n = edges.length @curr = 0 edges.each_with_index { |(key, _value), idx| @index[idx] = key } end |
Instance Attribute Details
#curr ⇒ Object (readonly)
Returns the value of attribute curr.
4 5 6 |
# File 'lib/networkx/flow/utils.rb', line 4 def curr @curr end |
#edges ⇒ Object (readonly)
Returns the value of attribute edges.
4 5 6 |
# File 'lib/networkx/flow/utils.rb', line 4 def edges @edges end |
Instance Method Details
#get ⇒ Object
14 15 16 |
# File 'lib/networkx/flow/utils.rb', line 14 def get [@index[@curr], @edges[@index[@curr]]] end |
#move_to_next ⇒ Object
18 19 20 21 22 |
# File 'lib/networkx/flow/utils.rb', line 18 def move_to_next @temp = @curr @curr = (@curr + 1) % @n raise StopIteration if @temp == @n - 1 end |