29 #include "../../common/WStringUtils.h"
30 #include "WTreeNode.h"
33 : std::enable_shared_from_this<
WTreeNode >(),
40 : std::enable_shared_from_this<
WTreeNode >()
42 const std::vector< size_t >& nodes = dendrogram.
getParents();
43 const std::vector< double >& heights = dendrogram.
getHeights();
45 size_t n = heights.size();
47 std::map< size_t, WTreeNode::SPtr > map;
55 height = heights[
index - n - 1 ];
62 size_t parent = nodes[
index ];
63 map[ parent ]->addChild( map[
index ] );
91 child->m_parent = shared_from_this();
Hirachical binary tree datastructure with spatial layout information called dendrogram.
const std::vector< size_t > & getParents() const
Returns const reference to the internal parents array.
const std::vector< double > & getHeights() const
Const reference to the heights array.
A node in a tree, holding an index, a level in the tree and pointers to its child nodes.
void addChild(WTreeNode::SPtr child)
Adds a childnode to this node.
WTreeNode(size_t index, double level)
Constructs a new TreeNode.
double m_level
Stores the level of this node.
WTreeNode::SPtr getParent()
Returns the parent node of this node.
WTreeNode::SPtr m_parent
Stores the parent node.
~WTreeNode()
Default destructor.
double level()
Returns the level of the TreeNode.
std::vector< WTreeNode::SPtr > getChildren()
Returns the child nodes of this node.
size_t index()
Returns the index of the TreeNode.
size_t m_index
Stores the index of this node.
std::shared_ptr< WTreeNode > SPtr
Shared pointer abbreviation.
std::vector< WTreeNode::SPtr > m_children
Stores the childnodes of this node.