wpi.associations.arminerSequence
Class ItemsetPrefixTree

java.lang.Object
  extended bywpi.associations.arminerSequence.ItemsetPrefixTree

public class ItemsetPrefixTree
extends java.lang.Object

A prefix tree used for indexing itemsets. This implementation assumes that all event items of the same name will be numbered consecutively. If the code that generates the first level of candidate itemsets is changed this condition must be ensured.

Version:
1.0
Author:
Keith A. Pray (kap@wpi.edu)

Nested Class Summary
private  class ItemsetPrefixTree.HashNode
           
 
Field Summary
private static int debug
          Specifies debug info level 0: no debug info 1: input to methods 2: and out from methods 3: and all sorts of stuff
private  int level
          Tracks the current level for pretty printing of tree
private  ItemsetPrefixTree.HashNode root
          The root node of the tree
private  int size
          The number of itemsets indexed
 
Constructor Summary
ItemsetPrefixTree()
          Create a new empty SET.
 
Method Summary
 void add(ARMinerItemset itemset)
          Add a new itemset in the itemset prefix tree.
 ARMinerItemset getItemset(ARMinerItemset itemset)
          Returns the itemset contained in the prefix tree for a given itemset.
 java.util.Vector getItemsets()
          Return the itemsets of the ItemsetPrefixTree.
 void getItemsets(ItemsetPrefixTree.HashNode node, java.util.Vector vector)
          Return the itemsets of the ItemsetPrefixTree starting from the specified node.
private  ItemsetPrefixTree.HashNode getNode(ARMinerItemset itemset)
          Return the node for a given itemset.
static void main(java.lang.String[] args)
          Main method for testing purposes.
 int size()
          Returns the number of itemsets indexed.
 java.lang.String toString()
          Return a string representation of the ItemsetPrefixTree.
private  void traversePrint(ItemsetPrefixTree.HashNode node, java.lang.StringBuffer sb)
          A private method which gets called recursively to retrieve itemsets from each node of the ItemsetPrefixTree and print them to a String.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

root

private ItemsetPrefixTree.HashNode root
The root node of the tree


level

private int level
Tracks the current level for pretty printing of tree


size

private int size
The number of itemsets indexed


debug

private static final int debug
Specifies debug info level 0: no debug info 1: input to methods 2: and out from methods 3: and all sorts of stuff

See Also:
Constant Field Values
Constructor Detail

ItemsetPrefixTree

public ItemsetPrefixTree()
Create a new empty SET.

Method Detail

size

public int size()
Returns the number of itemsets indexed.

Returns:
the number of itemsets indexed

add

public void add(ARMinerItemset itemset)
Add a new itemset in the itemset prefix tree. If there is an existing itemset in the prefix tree that represents the same regular and event items as the itemset specified it will be replaced by the specified itemset.

Parameters:
itemset - the itemset to be added
Throws:
java.lang.IllegalArgumentException - itemset is null or is empty

getItemset

public ARMinerItemset getItemset(ARMinerItemset itemset)
Returns the itemset contained in the prefix tree for a given itemset. Event items with the same name are not considered unique so the returned itemset, if any, may not contain the exact same items. This is very useful for looking up conceptually duplicate itemsets.

Parameters:
itemset - the itemset to use to find the indexed itemset in the prefix tree
Returns:
the itemset, null if not found

getNode

private ItemsetPrefixTree.HashNode getNode(ARMinerItemset itemset)
Return the node for a given itemset.

Parameters:
itemset - the itemset for which we want to obtain the node
Returns:
the node representing the itemset, null if not found
Throws:
java.lang.IllegalArgumentException - itemset is null or is empty

getItemsets

public java.util.Vector getItemsets()
Return the itemsets of the ItemsetPrefixTree.

Returns:
a vector containing the itemsets from the ItemsetPrefixTree

getItemsets

public void getItemsets(ItemsetPrefixTree.HashNode node,
                        java.util.Vector vector)
Return the itemsets of the ItemsetPrefixTree starting from the specified node.

Parameters:
node - the node to start collecting itemsets from
vector - the vector to add itemsets to

traversePrint

private void traversePrint(ItemsetPrefixTree.HashNode node,
                           java.lang.StringBuffer sb)
A private method which gets called recursively to retrieve itemsets from each node of the ItemsetPrefixTree and print them to a String.

Parameters:
node - node to traverse

toString

public java.lang.String toString()
Return a string representation of the ItemsetPrefixTree.

Returns:
string representation of ItemsetPrefixTree

main

public static void main(java.lang.String[] args)
Main method for testing purposes. -t option specifies the cache file to load itemset from.