Class: FpGrowth::FpTree::Node
- Inherits:
-
Object
- Object
- FpGrowth::FpTree::Node
- Defined in:
- lib/fpgrowth/fp_tree/node.rb
Instance Attribute Summary collapse
-
#children ⇒ Object
Returns the value of attribute children.
-
#item ⇒ Object
Returns the value of attribute item.
-
#lateral ⇒ Object
Returns the value of attribute lateral.
-
#parent ⇒ Object
Returns the value of attribute parent.
-
#support ⇒ Object
Returns the value of attribute support.
Instance Method Summary collapse
- #==(other_object) ⇒ Object
-
#clone_deep ⇒ Object
Clone Node, deeply Must ignore parent and lateral, which are relative to this node in his tree, not to the clone.
-
#clone_tail_deep ⇒ Object
Clone childrens, deeply.
-
#initialize(item = nil, support = 1) ⇒ Node
constructor
A new instance of Node.
Constructor Details
#initialize(item = nil, support = 1) ⇒ Node
Returns a new instance of Node.
6 7 8 9 10 11 12 |
# 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 |
Instance Attribute Details
#children ⇒ Object
Returns the value of attribute children.
4 5 6 |
# File 'lib/fpgrowth/fp_tree/node.rb', line 4 def children @children end |
#item ⇒ Object
Returns the value of attribute item.
4 5 6 |
# File 'lib/fpgrowth/fp_tree/node.rb', line 4 def item @item end |
#lateral ⇒ Object
Returns the value of attribute lateral.
4 5 6 |
# File 'lib/fpgrowth/fp_tree/node.rb', line 4 def lateral @lateral end |
#parent ⇒ Object
Returns the value of attribute parent.
4 5 6 |
# File 'lib/fpgrowth/fp_tree/node.rb', line 4 def parent @parent end |
#support ⇒ Object
Returns the value of attribute support.
4 5 6 |
# File 'lib/fpgrowth/fp_tree/node.rb', line 4 def support @support end |
Instance Method Details
#==(other_object) ⇒ Object
35 36 37 38 39 40 41 42 |
# 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 ⇒ Object
Clone Node, deeply Must ignore parent and lateral, which are relative to this node in his tree, not to the clone
27 28 29 30 31 32 33 |
# 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 ⇒ Object
Clone childrens, deeply
16 17 18 19 20 21 22 |
# 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 |