X-Git-Url: https://ruin.nu/git/?a=blobdiff_plain;f=src%2Fcomponenttree.h;h=84d6270218101fbde5c71c01468837d577dae18d;hb=4462cded18dd80075c3622e5a87ca6f5f3c84f62;hp=7a99c91614f6baa6f1f65b0642e923965e6d24b8;hpb=dcd966c5fca7dca53ca1f605f70f13f019d29771;p=germs.git diff --git a/src/componenttree.h b/src/componenttree.h index 7a99c91..84d6270 100644 --- a/src/componenttree.h +++ b/src/componenttree.h @@ -22,12 +22,17 @@ #define __COMPONENTTREE_H__ #include +#include #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(); @@ -36,16 +41,44 @@ class ComponentTree { Component _comp; std::vector _children; }; + + /** + * Creates a component tree from a list of components. + */ ComponentTree(const std::vector& 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 & b); + + Node* _root; - Node _root; friend class ComponentTreeTest; };