Class: ArtDecomp::Bipainter

Inherits:
Object
  • Object
show all
Defined in:
lib/art-decomp/bipainter.rb

Instance Method Summary collapse

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

#blanketsObject



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