Hierarchical Edge Bundle 1.0
|
00001 #pragma once 00002 #include "Vertex.h" 00003 #include "HierarchyEdge.h" 00004 #include "RelationEdge.h" 00005 #include "Hierarchy.h" 00006 00007 #include <iostream> 00008 #include <iomanip> 00009 #include <string> 00010 00011 #include <boost/ptr_container/ptr_sequence_adapter.hpp> 00012 00013 #include <boost/ptr_container/ptr_map.hpp> 00014 #include <boost/ptr_container/ptr_vector.hpp> 00015 #include <boost/assign/ptr_map_inserter.hpp> // for 'ptr_map_insert()' 00016 #include <boost/shared_ptr.hpp> 00017 #include <memory> 00018 #include <vector> 00019 #include <map> 00020 #include <algorithm> 00021 00022 using namespace std; 00023 using namespace boost; 00024 using namespace boost::assign; 00025 00026 typedef boost::shared_ptr<Vertex> VertexPtr; 00027 typedef boost::shared_ptr<HierarchyEdge> HierarchyPtr; 00028 typedef boost::shared_ptr<RelationEdge> RelationPtr; 00029 00042 class Graph 00043 { 00044 public: 00048 Graph(void); 00052 ~Graph(void); 00053 00058 void AddVertex(VertexPtr vert); 00064 VertexPtr GetVertexWithID(unsigned int id); 00069 int GetNumberOfVertices(); 00074 void RemoveVertexWithID(unsigned int id); 00079 void RemoveVertex(Vertex& vert); 00080 00085 void SetRoot(int id); 00090 VertexPtr GetRoot(); 00091 00097 HierarchyPtr GetHierarchyEdgeWithID(unsigned int id); 00102 void AddHierarchicEdge(HierarchyPtr edge); 00107 unsigned int GetNumberOfHiearchicEdges(); 00113 HierarchyPtr GetHierarchyEdgeAt(unsigned int at); 00114 00120 RelationPtr GetRelationEdgeWithID(unsigned int id); 00125 void AddRelationEdge(RelationPtr edge); 00130 unsigned int GetNumberOfRelationEdges(); 00136 RelationPtr GetRelationEdgeAt(unsigned int at); 00137 00142 void SetNumberOfHierarchies(int count); 00147 int GetNumberOfHierarchies(); 00148 00153 void AddHierarchy(Hierarchy hierarchy); 00159 void SetHierarchyAt(int level, Hierarchy hierarchy); 00165 Hierarchy GetHierarchyAt(int level); 00170 void RemoveHierarchy(int level); 00171 00177 std::vector<VertexPtr> GetVertexPtrVectorFromIDVector(std::vector<unsigned int> ids); 00178 00182 void Calculate(); 00186 void CalculateHierarchy(); 00187 /* 00188 * This method calculates a path to the root node for all nodes. 00189 */ 00190 void CalculatePathToRoot(); 00191 /* 00192 * This method calculates a path to the root 00193 * @param actPath [VertexPtr] act path 00194 * @param path [unsigned int] nodes 00195 */ 00196 void CalculatePathToRoot(VertexPtr actPath, std::vector<unsigned int> path); 00197 00203 std::vector<unsigned int> CalculatePathOverLCA(RelationPtr edge); 00210 std::vector<unsigned int> CalculatePathOverLCA(VertexPtr start, VertexPtr end); 00211 00216 std::vector<VertexPtr> GetAllVerticesWithoutChild(); 00217 protected: 00218 std::map<unsigned int, VertexPtr> m_vertices; 00219 std::map<unsigned int, HierarchyPtr> m_hierarchyedges; 00220 std::map<unsigned int, RelationPtr> m_relationedge; 00221 VertexPtr m_pkRoot; 00222 00223 vector<Hierarchy> m_hierarchy; 00224 };