]> ruin.nu Git - germs.git/blobdiff - src/componenttree.h
added .gitignore files
[germs.git] / src / componenttree.h
index 7a99c91614f6baa6f1f65b0642e923965e6d24b8..816059c29b7fe3c14463bbaf023c905b2907f834 100644 (file)
 #define __COMPONENTTREE_H__
 
 #include <vector>
+#include <map>
 #include "misc.h"
 
-class ComponentTreeTest;
-
 class ComponentTree {
        public:
                struct Node {
@@ -36,16 +35,35 @@ class ComponentTree {
                        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();
+
+               size_t countLeaves();
+
+               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;
 };