class Doku::DancingLinks::LinkMatrix::Node

This class represents a normal node in Knuth’s {LinkMatrix}. Every node belongs to a column and a row, and it represents the fact that the row (i.e. set) “covers” the column.

Attributes

column[RW]

The {Column} object that this node belongs to.

row_id[RW]

The user-assigned ID of the row this node belongs to.

Public Instance Methods

choose() click to toggle source

Removes a row from the {LinkMatrix} by covering every column that it touches.

# File lib/doku/dancing_links.rb, line 254
def choose
  nodes_rightward.each do |node|
    node.column.cover
  end
end
choose_except_self_column() click to toggle source

Removes a row from the {LinkMatrix} by covering every column that it touches EXCEPT self.column, which is assumed to already be covered. This represents (tentatively) choosing the node’s row to be in our exact cover. When that choice is proven to not work, this action can be efficiently undone with {#unchoose_except_self_column}.

# File lib/doku/dancing_links.rb, line 267
def choose_except_self_column
  nodes_except_self_rightward.each do |node|
    node.column.cover
  end
end
nodes()
Alias for: nodes_rightward
nodes_except_self()
nodes_except_self_leftward() click to toggle source

All nodes in the same row, starting with self and going to the left, but not including self.

# File lib/doku/dancing_links.rb, line 244
def nodes_except_self_leftward
  LinkEnumerator.new :left, self
end
nodes_except_self_rightward() click to toggle source

All nodes in the same row, starting with self and going to the right, but not including self.

# File lib/doku/dancing_links.rb, line 238
def nodes_except_self_rightward
  LinkEnumerator.new :right, self
end
Also aliased as: nodes_except_self
nodes_rightward() click to toggle source

All nodes in the same row, starting with self and going to the right.

# File lib/doku/dancing_links.rb, line 232
def nodes_rightward
  LinkEnumerator.new :right, self, true
end
Also aliased as: nodes
unchoose_except_self_column() click to toggle source

Undoes the effect of {#choose_except_self_column}, putting the nodes of the row back into the {LinkMatrix}.

# File lib/doku/dancing_links.rb, line 275
def unchoose_except_self_column
  nodes_except_self_leftward.each do |node|
    node.column.uncover
  end
end