Turi Create
4.0
|
#include <toolkits/pattern_mining/fp_node.hpp>
Public Member Functions | |
fp_node (const size_t &id=ROOT_ID, const size_t &node_depth=0) | |
fp_node * | add_child (const size_t &child_id) |
fp_node * | get_child (const size_t &child_id) const |
std::vector< size_t > | get_path_to_root () |
bool | is_closed () const |
void | erase () |
Nodes for the FP-Tree data structure
Note: FP-Nodes should only be created via shared pointers std::make_shared<fp_node>(size_t id)
Members: item_id is the size_teger index of items in the tree (e.g. 0 -> Dog, 1 -> Cat) Note: m_id = -1 should be reserved for the root node. item_count is the frequency of the index (e.g. 'Dog' occurs m_count times) depth is the depth of the node in the tree parent_node is the node's parent in the tree children_node are the node's children in the tree next_node is the next location of a node with the same item_id
Definition at line 42 of file fp_node.hpp.
turi::pattern_mining::fp_node::fp_node | ( | const size_t & | id = ROOT_ID , |
const size_t & | node_depth = 0 |
||
) |
Construct New Node Args: id (size_t) - item id for node (Note: ROOT_ID is reserved for root) depth (size_t) - depth of node in tree
fp_node* turi::pattern_mining::fp_node::add_child | ( | const size_t & | child_id | ) |
Add Child Node Adds a new child node with id if one does not currently exist. Current node will be set as child node's parent. Args: child_id (size_t) - id for child node (Note: ROOT_ID is reserved) Returns: A pointer to the child node
void turi::pattern_mining::fp_node::erase | ( | ) |
Delete pointer to self from parent (if a parent exists)
fp_node* turi::pattern_mining::fp_node::get_child | ( | const size_t & | child_id | ) | const |
Get Child Node Gets a pointer to the child node with id Args: child_id (size_t) - id for child node (Note: ROOT_ID is reserved) Returns: A pointer to the child node, nullptr if no child exists
std::vector<size_t> turi::pattern_mining::fp_node::get_path_to_root | ( | ) |
Get set on path to root from current node. Returns: set (vector of size_t) - set of item ids on path to root
bool turi::pattern_mining::fp_node::is_closed | ( | ) | const |
Check if node is a closed node. A node is closed if it's support is greater than any of its children. Once closed, a node will remain closed.
Returns: is_closed (bool) - whether the node is closed