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
The {Column} object that this node belongs to.
The user-assigned ID of the row this node belongs to.
Public Instance Methods
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
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
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
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
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
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