Class: NetworkX::GlobalRelabelThreshold

Inherits:
Object
  • Object
show all
Defined in:
lib/networkx/flow/utils.rb

Overview

Helper class for preflow push algorithm

Instance Method Summary collapse

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_workObject



51
52
53
# File 'lib/networkx/flow/utils.rb', line 51

def clear_work
  @work = 0
end

#reached?Boolean

Returns:

  • (Boolean)


47
48
49
# File 'lib/networkx/flow/utils.rb', line 47

def reached?
  @work >= @threshold
end