class FpGrowth::FpTree::Node

Attributes

children[RW]
item[RW]
lateral[RW]
parent[RW]
support[RW]

Public Class Methods

new(item=nil, support=1) click to toggle source
# File lib/fpgrowth/fp_tree/node.rb, line 6
def initialize(item=nil, support=1)
  @item = item
  @support = support
  @children = []
  @lateral = nil
  @parent = nil
end

Public Instance Methods

==(other_object) click to toggle source
# File lib/fpgrowth/fp_tree/node.rb, line 35
def ==(other_object)
  return false unless other_object
  flag = true
  flag = false if @item != other_object.item
  flag = false if @support != other_object.support
  flag = false if @children != other_object.children
  return flag
end
clone_deep() click to toggle source

Clone Node, deeply Must ignore parent and lateral, which are relative to this node in his tree, not to the clone

# File lib/fpgrowth/fp_tree/node.rb, line 27
def clone_deep
  clone = Node.new()
  clone.item = @item
  clone.support = @support
  clone.children = clone_tail_deep()
  return clone
end
clone_tail_deep() click to toggle source

Clone childrens, deeply

# File lib/fpgrowth/fp_tree/node.rb, line 16
def clone_tail_deep
  cloned_tail = []
  for child in children
    cloned_tail << child.clone_deep()
  end
  return cloned_tail
end