00001
00007 #ifndef TREE_HPP
00008 #define TREE_HPP
00009
00010 #include <vector>
00011 #include <string>
00012
00015 struct Edge
00016 {
00017 unsigned int u;
00018 unsigned int v;
00019 };
00020
00026 class Tree
00027 {
00028 public:
00032 Tree();
00033
00048 Tree( unsigned int order, int *levelSequence );
00049
00057 Tree( const Tree & that );
00058
00063 ~Tree();
00064
00069 unsigned int getOrder() const { return mOrder; };
00079 unsigned int getDegree( unsigned int v ) const { if( v < mOrder ) return mDegrees[v]; return 0; };
00080
00088 std::vector<Edge> getEdges() const;
00096 void getDegreeSequence( std::vector<unsigned int> & degreeSequence ) const;
00106 void getPathNums( std::vector<unsigned int> & pathNums ) const;
00107
00111 void print() const;
00112
00120 Tree & operator=( const Tree & rhs );
00121
00122 private:
00138 void pathNumsDfs( unsigned int i, unsigned int count, bool *& visited, std::vector<unsigned int> & pathNums ) const;
00139
00140 unsigned int mOrder;
00141 unsigned int *mDegrees;
00142 unsigned int *mOffsets;
00143 unsigned int *mAdjArray;
00144 };
00145
00146 #endif
00147