NestingTreeSubgraphNode.h 9.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422
  1. #ifndef NESTINGTREESUBGRAPHNODE_H
  2. #define NESTINGTREESUBGRAPHNODE_H
  3. #include <Common/BoostGraphWrapper.h>
  4. #include <HierarchicalLayoutGenerator/LayerNode.h>
  5. #include <Common/ConstantType.h>
  6. #include <QVector>
  7. #include <QMultiMap>
  8. #include <QSet>
  9. class LayerNode;
  10. class GRAPHLAYOUTLIBRARYSHARED_EXPORT NestingTreeSubgraphNode
  11. {
  12. public:
  13. /** @name Creators
  14. * The methods under this section are responsible for constructing
  15. * an instance of type NestingTreeSubgraphNode.
  16. */
  17. //@{
  18. NestingTreeSubgraphNode();
  19. NestingTreeSubgraphNode(SubGraph &gGraph);
  20. //@}
  21. typedef QVector< NestingTreeSubgraphNode* > VectorNestingTreeSubgraphNodesRef; /*!< Vector of pointer references to nesting trees in subgraphs as node */
  22. typedef QVectorIterator< NestingTreeSubgraphNode* > IteratorVectorNestingTreeSubgraphNodesRef; /*!< Iterator of type NestingTreeSubgraphNode* */
  23. typedef QMultiMap< int , LayerNode* > MultiMapLayerIdToLayerNodeRef; /*!< Multimap of Layer Ids to layer node references */
  24. typedef QMapIterator<int , LayerNode*> IteratorMultiMapLayerIdToLayerNodeRef; /*!< Iterator to Multimap of Layer Ids to layer node references (MultiMapLayerIdToLayerNodeRef) */
  25. private:
  26. BoostGraphWrapper m_BoostGraphWrapper;
  27. /* Boolean which tells if this nesting subgraph node represents
  28. * the main (root) boost graph or not
  29. */
  30. bool m_bIsRoot;
  31. /**< Vector of nesting tree of subgraphs as node */
  32. VectorNestingTreeSubgraphNodesRef m_vecChildNestingTreeSubgraphNode;
  33. SubGraph *m_gSubgraph; /*!< Pointer to the boost Subgraph */
  34. NestingTreeSubgraphNode *m_parentNestingTreeSubraphNode; /*!< Pointer to Parent Nesting Tree Subgraph Node */
  35. /* Multimap of vertices sortes on their 'layer id/rank'
  36. * key: layer rank or id of the layer node which belongs current Subgraph
  37. * value: corresponding node
  38. */
  39. MultiMapLayerIdToLayerNodeRef m_mapLayerIdToLayerNodeRef;
  40. int m_iMinRank; /*!< Rank of UpperBorder Vertex */
  41. int m_iMaxRank; /*!< Rank of LowerBorder Vertex */
  42. /*! QSet (internally a hash)
  43. * Contains the layer ids of vertices
  44. * which belongs to this Nesting Tree Subgraph Node
  45. */
  46. QSet< int > m_setLayerIds;
  47. double m_dAverageBarryCenter; /*!< Average Barry Center */
  48. int m_iSubgraphOrderingGraphVertexIndex; /*!< Unique nesting tree identifier */
  49. int m_iTopologocalOrder; /*!< iTopological Order according to subgraph ordering graph */
  50. public:
  51. /**
  52. This function sets the boost graph for current Nesting Tree Subgraph Node
  53. @pre none
  54. @param none
  55. @return none
  56. @throws none
  57. */
  58. void setGraph(SubGraph &gGraph);
  59. /**
  60. This function gets the boost graph for current Nesting Tree Subgraph Node
  61. @pre none
  62. @param none
  63. @return none
  64. @throws none
  65. */
  66. SubGraph& getGraph();
  67. /**
  68. This function returns parent node of current Nesting Tree Subgraph Node
  69. @pre none
  70. @param none
  71. @return reference to parent node of current Nesting Tree Subgraph Node
  72. @throws none
  73. */
  74. NestingTreeSubgraphNode& getParent();
  75. /**
  76. This function sets parent node of current Nesting Tree Subgraph Node
  77. @pre
  78. -# &parentNestingTreeSubraphNode != NULL
  79. @param none
  80. @return none
  81. @throws none
  82. */
  83. void setParentNestingTreeSubgraphNode(NestingTreeSubgraphNode &parentNestingTreeSubraphNode);
  84. /**
  85. This function returns that if current graph is Root (main) graph or not
  86. @pre none
  87. @param none
  88. @return bool
  89. graph is root (main) graph or not
  90. @throws LayoutException
  91. -# INVA
  92. */
  93. bool isRoot();
  94. /**
  95. This function adds new child Nesting Tree Subgraph Node
  96. @pre
  97. -# m_gSubgraph != NULL
  98. @param gGraph
  99. reference to the graph for which the Nesting Tree Subgraph Node is to be created
  100. @return none
  101. @throws none
  102. */
  103. NestingTreeSubgraphNode& addChildNestingTreeSubgraphNode(SubGraph &gChildGraph);
  104. /**
  105. This function returns const reference to the next level child nesting tree subgraph nodes
  106. @pre none
  107. @param none
  108. @return the vector containing next level child nesting tree subgraph nodes of current node
  109. @throws none
  110. */
  111. const VectorNestingTreeSubgraphNodesRef& getChildNestingTreeSubgraphNodes();
  112. /**
  113. This function returns iterator for m_vecChildNestingTreeSubgraphNode
  114. @pre none
  115. @param none
  116. @return iterator for vecChildNestingTreeSubgraphNode
  117. @throws none
  118. */
  119. IteratorVectorNestingTreeSubgraphNodesRef getIteratorChildNestingTreeSubgraphNodes();
  120. /**
  121. This function returns total number of child NestingTree Subgraph nodes
  122. @pre none
  123. @param none
  124. @return total number of child NestingTree Subgraph nodes
  125. @throws none
  126. */
  127. int getCountOfChildNestingTreeSubgraphNodes();
  128. /**
  129. This function returns total count of LayerNode nodes
  130. @pre none
  131. @param none
  132. @return total count of LayerNode nodes
  133. @throws none
  134. */
  135. int getCountOfLayerNodes();
  136. /**
  137. This function returns reference to Multimap containing vertices which belongs to current SubgaphNode mapped by their LayerIds
  138. @pre none
  139. @param none
  140. @return reference multimap containing vertices which belongs to current SubgaphNode mapped by their LayerIds
  141. @throws none
  142. */
  143. MultiMapLayerIdToLayerNodeRef& getMapLayerIdToLayerNodeRef();
  144. /**
  145. This function returns java style iterator for multimap of LayerNodes
  146. @pre none
  147. @param none
  148. @return java style iterator for multimap of LayerNodes
  149. @throws none
  150. */
  151. IteratorMultiMapLayerIdToLayerNodeRef getChildLayerNodesIterator();
  152. /**
  153. This function adds vertex to current NestingTreeSubgraphNode
  154. @pre none
  155. @param none
  156. @return none
  157. @throws none
  158. */
  159. void addLayerIdAndLayerNode(int iLayerRank , LayerNode* layerNodeRef);
  160. /**
  161. This function gives min rank of current Subgaph Node i.e. rank of UpperBorderVertex
  162. @pre none
  163. @param none
  164. @return integer min rank of current Subgaph Node
  165. @throws none
  166. */
  167. int getMinRank();
  168. /**
  169. This function gives max rank of current Subgaph Node i.e. rank of LowerBorderVertex
  170. @pre none
  171. @param none
  172. @return integer max rank of current Subgaph Node
  173. @throws none
  174. */
  175. int getMaxRank();
  176. /**
  177. This function tells if the provided rank value is in between the min and max rank values of the current subgraph node
  178. @pre
  179. -# iRank > 0
  180. @param iRank
  181. rank value
  182. @return the bool value for if the provided rank value lies between min and max ranks of current subgraph node
  183. @throws none
  184. */
  185. bool isBetweenMinMaxRanks(int iRank);
  186. /**
  187. This function adds layer id into a set contaning unique layer ids of all nodes belongs to current subgraph
  188. @pre none
  189. @param iLayerId
  190. layer id or rank of node
  191. @return none
  192. @throws none
  193. */
  194. void recordLayerIdRecurUp(int iLayerId);
  195. /**
  196. This function checks if provided LayerId is already present in set contaning unique layer ids of all nodes belongs to current subgraph node
  197. @pre none
  198. @param iLayerId
  199. layer id or rank of node
  200. @return boolean for if Subgraph node contains the Layer node with provided LayerId
  201. @throws none
  202. */
  203. bool doesSubgraphNodeContainLayerId(int iLayerId);
  204. /**
  205. This function calculates average barrycenter position of all nodes contained within subgraph
  206. @pre none
  207. @param none
  208. @return none
  209. @throws none
  210. */
  211. double updateAverageBarryCenter();
  212. /**
  213. This function gives average barry center position of subgraph
  214. @pre none
  215. @param none
  216. @return average barry center position
  217. @throws none
  218. */
  219. double getAverageBarryCenter();
  220. /**
  221. This function sets unique id of current NestingTreeSubgraphNode
  222. @pre none
  223. @param iUniqueNestingTreeNodeId
  224. integer value for NestingTreeSubgraphNode unique id
  225. @return none
  226. @throws none
  227. */
  228. int setSubgraphOrderingGraphVertexIndex(int iSubgraphOrderingGraphVertexIndex);
  229. /**
  230. This function gets unique id of current NestingTreeSubgraphNode
  231. @pre none
  232. @param none
  233. @return integer unique id of current NestingTreeSubgraphNode
  234. @throws none
  235. */
  236. int getSubgraphOrderingGraphVertexIndex();
  237. /**
  238. This function sets Topological Order of current NestingTreeSubgraphNode
  239. @pre none
  240. @param iTopologicalOrder
  241. integer value for NestingTreeSubgraphNode Topological Order
  242. @return none
  243. @throws none
  244. */
  245. int setTopologicalOrder(int iTopologicalOrder);
  246. /**
  247. This function gets Topological Order of current NestingTreeSubgraphNode
  248. @pre none
  249. @param none
  250. @return integer Topological Order of current NestingTreeSubgraphNode
  251. @throws none
  252. */
  253. int getTopologicalOrder();
  254. /**
  255. This function prints the subgraph name
  256. @pre none
  257. @param none
  258. @return none
  259. @throws none
  260. */
  261. void printName();
  262. };
  263. #endif // NESTINGTREESUBGRAPHNODE_H