#define __COMPONENTTREE_H__
#include <vector>
+#include <map>
#include "misc.h"
-class ComponentTreeTest;
-
+/**
+ * Creates and holds a component tree.
+ */
class ComponentTree {
public:
+ /**
+ * A node in the component tree.
+ */
struct Node {
Node(Node* parent, Component comp);
~Node();
Component _comp;
std::vector<Node*> _children;
};
+
+ /**
+ * Creates a component tree from a list of components.
+ */
ComponentTree(const std::vector<Component>& components);
~ComponentTree();
+ /**
+ * Transforms the tree into the minimal tree containing all unoriented componentes.
+ * \todo come up with a better name
+ */
+ void makeUnoriented();
+
+ /**
+ * Count the number of leaves in the component tree.
+ * This is the number of hurdles, if makeUnoriented has been called.
+ */
+ size_t countLeaves();
+
+ /**
+ * Number of short branches.
+ * If makeUnoriented has been called and countLeaves is >= 3
+ * then we have a super hurdle if short branches = 0.
+ */
+ size_t shortBranches();
+
private:
//Disable these, at least for now.
void operator=(const ComponentTree&){};
- ComponentTree(const ComponentTree&): _root(0,Component()){};
+ ComponentTree(const ComponentTree&): _root(0){};
+
+ void removeOriented(Node* n);
+ size_t countLeaves(Node* n);
+ void branches (Node* n, std::map<Node*,size_t> & b);
+
+ Node* _root;
- Node _root;
friend class ComponentTreeTest;
};