Class: ArtDecomp::Bipainter
- Inherits:
-
Object
- Object
- ArtDecomp::Bipainter
- Defined in:
- lib/art-decomp/bipainter.rb
Instance Method Summary collapse
- #blankets ⇒ Object
-
#initialize(beta_q, beta_v, seps) ⇒ Bipainter
constructor
A new instance of Bipainter.
Constructor Details
#initialize(beta_q, beta_v, seps) ⇒ Bipainter
Returns a new instance of Bipainter.
3 4 5 6 7 8 9 10 11 12 |
# File 'lib/art-decomp/bipainter.rb', line 3 def initialize beta_q, beta_v, seps raise 'non-disjoint beta_v' unless beta_v.ints.pairs.all? { |a, b| (a & b).zero? } @beta_v = beta_v @qv_colours = {} @g_colours = {} @qv_forbidden = Hash.new { |h, k| h[k] = Set[] } @g_forbidden = Hash.new { |h, k| h[k] = Set[] } @qv_graph = Graph.new beta_q, seps - beta_v.seps @g_graph = Graph.new beta_q * beta_v, seps end |
Instance Method Details
#blankets ⇒ Object
14 15 16 17 18 19 20 21 |
# File 'lib/art-decomp/bipainter.rb', line 14 def blankets colour_next_vertex! until painted? qv_blocks = Hash.new 0 g_blocks = Hash.new 0 @qv_colours.each { |vertex, colour| qv_blocks[colour] |= vertex } @g_colours.each { |vertex, colour| g_blocks[colour] |= vertex } [Blanket.new(qv_blocks.values), Blanket.new(g_blocks.values)] end |