Class: NetworkX::GlobalRelabelThreshold
- Inherits:
-
Object
- Object
- NetworkX::GlobalRelabelThreshold
- Defined in:
- lib/networkx/flow/utils.rb
Overview
Helper class for preflow push algorithm
Instance Method Summary collapse
- #add_work(work) ⇒ Object
- #clear_work ⇒ Object
-
#initialize(num1, num2, freq) ⇒ GlobalRelabelThreshold
constructor
A new instance of GlobalRelabelThreshold.
- #reached? ⇒ Boolean
Constructor Details
#initialize(num1, num2, freq) ⇒ GlobalRelabelThreshold
Returns a new instance of GlobalRelabelThreshold.
37 38 39 40 41 |
# File 'lib/networkx/flow/utils.rb', line 37 def initialize(num1, num2, freq) freq = freq.nil? ? Float::INFINITY : freq @threshold = (num1 + num2) / freq @work = 0 end |
Instance Method Details
#add_work(work) ⇒ Object
43 44 45 |
# File 'lib/networkx/flow/utils.rb', line 43 def add_work(work) @work += work end |
#clear_work ⇒ Object
51 52 53 |
# File 'lib/networkx/flow/utils.rb', line 51 def clear_work @work = 0 end |
#reached? ⇒ Boolean
47 48 49 |
# File 'lib/networkx/flow/utils.rb', line 47 def reached? @work >= @threshold end |