HierarchicalLayouter.h 48 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390139113921393139413951396139713981399140014011402140314041405140614071408140914101411141214131414141514161417141814191420142114221423142414251426142714281429143014311432143314341435143614371438143914401441144214431444144514461447144814491450145114521453145414551456145714581459146014611462146314641465146614671468146914701471147214731474147514761477147814791480148114821483148414851486148714881489149014911492149314941495149614971498149915001501150215031504150515061507150815091510151115121513151415151516151715181519152015211522152315241525152615271528152915301531153215331534153515361537153815391540154115421543154415451546154715481549155015511552155315541555155615571558155915601561156215631564156515661567156815691570157115721573157415751576157715781579158015811582158315841585158615871588158915901591159215931594159515961597159815991600160116021603160416051606160716081609161016111612161316141615161616171618161916201621162216231624162516261627162816291630163116321633163416351636163716381639164016411642164316441645164616471648164916501651165216531654165516561657165816591660166116621663166416651666166716681669167016711672167316741675167616771678167916801681168216831684168516861687168816891690169116921693169416951696169716981699170017011702170317041705170617071708170917101711171217131714171517161717171817191720172117221723172417251726172717281729173017311732173317341735173617371738173917401741174217431744174517461747174817491750175117521753175417551756175717581759176017611762176317641765176617671768176917701771177217731774177517761777177817791780178117821783178417851786178717881789179017911792179317941795179617971798179918001801180218031804
  1. #ifndef HIERARCHICALLAYOUTER_H
  2. #define HIERARCHICALLAYOUTER_H
  3. #include <GraphLayoutLibrary_global.h>
  4. #include <Common/BoostGraphWrapper.h>
  5. #include <common/GraphCycleHandler.h>
  6. #include <Common/CustomDFSVisitors.h>
  7. #include <Common/LayoutUtility.h>
  8. #include <Common/ConstantType.h>
  9. #include <boost/graph/breadth_first_search.hpp>
  10. #include <HierarchicalLayoutGenerator/HierarchicalLayoutTypedefs.h>
  11. #include <HierarchicalLayoutGenerator/SubgraphOrderingGraph.h>
  12. #include <HierarchicalLayoutGenerator/SubgraphOrderingGraphDFSVisitor.h>
  13. #include <QHash>
  14. #include <array>
  15. #include <QQueue>
  16. #include <QStack>
  17. #include <QtAlgorithms>
  18. #include <boost/circular_buffer.hpp>
  19. //Required to assess time taken by Hierarcical Layout Processes
  20. #include <QTime>
  21. #include <QFile>
  22. #include <HierarchicalLayoutGenerator/HierarchicalLayoutTestingConstants.h>
  23. #include <QObject>
  24. #define UNDEFINED_POS INT_MIN
  25. #define INFINITY_INT INT_MAX
  26. #define HORIZONTAL_UNIT_SPACE 1
  27. //This macro allows or denies if the calculated bend points are to be added to respective edges
  28. //if its value is 'true' then the bend points will be added to edges which should have them and subsequently
  29. //graphml writer will write them in output graphml
  30. //It is introduced to set to avoid bend points in output , because 'ScoMos' application does not
  31. //handle bend points
  32. #define ALLOW_BEND_POINTS false
  33. /**
  34. * @brief The HierarchicalLayouter class
  35. *
  36. * The class generates hierarchical layout of a graph.
  37. */
  38. class GRAPHLAYOUTLIBRARYSHARED_EXPORT HierarchicalLayouter
  39. {
  40. public:
  41. /** @name Creators
  42. * The methods under this section are responsible for constructing
  43. * an instance of type HierarchicalLayouter.
  44. */
  45. //@{
  46. /**
  47. Constructs new object of type HierarchicalLayouter.
  48. @pre none
  49. @param none
  50. @return none
  51. @throw none
  52. */
  53. HierarchicalLayouter();
  54. //@}
  55. /** @name Modifiers
  56. * The methods under this section are responsible for modifying
  57. * an instance of HierarchicalLayouter.
  58. */
  59. //@{
  60. /**
  61. This function accepts boost graph and lay it out hierarchical manner.
  62. @pre
  63. -# gGraph != NULL
  64. @param gGraph
  65. reference to the graph
  66. @param iNodeSeparation
  67. constant to decide separation between adjucent nodes
  68. @param iEdgeSeparation
  69. constant to decide separation between edge to nodes and other edges
  70. @param iLayerSeparation
  71. constant to decide separation between layers in hierarchy
  72. @param iBorderMargin
  73. constant to decide margin for cluster (subgraph) border
  74. @return none
  75. @throws none
  76. */
  77. void applyHierarchicalLayout(SubGraph &gGraph, int iNodeSeparation, int iEdgeSeparation, int iLayerSeparation, int iBorderMargin);
  78. /**
  79. This function accepts boost graph and lay it out hierarchically
  80. @pre
  81. -# gGraph != NULL
  82. @param gGraph
  83. reference to the graph
  84. @return none
  85. @throws none
  86. */
  87. void applyHierarchicalLayout(SubGraph &gGraph);
  88. /**
  89. This function sets execution log csv file name
  90. @pre
  91. -# m_sExecutionLogFileName.isEmpty() == false
  92. @param m_sExecutionLogFileName
  93. execution log filename string
  94. @return none
  95. @throws none
  96. */
  97. void setExecutionLogFileName(QString sFileName);
  98. //@}
  99. QString m_sExecutionLogFileName; /*!< Name of log file >*/
  100. SubGraph *m_gMainGraph; /*!< Pointer reference to main graph object >*/
  101. /** @name Queries
  102. * The methods under this section are responsible for accessing
  103. * an instance of type HierarchicalLayouter.
  104. */
  105. //@{
  106. /**
  107. This function returns final crossings present in the graph if the value is set
  108. @pre none
  109. @param none
  110. @return none
  111. @throws none
  112. */
  113. int getFinalCrossings();
  114. //@}
  115. /*! This is map of all layers, key is the integer value of the rank of each layer,
  116. * value is pointer to the layer of LayerNodes
  117. */
  118. private:
  119. /** Map of layer ids (integer) to layer references **/
  120. MapLayerIdToLayerRef m_mapLayeredGraph;
  121. /** Boost graph wrapper object **/
  122. BoostGraphWrapper m_BoostGraphWrapper;
  123. ConstantType<int> m_iNestingDepth; /*!< Nesting depth of the graph >*/
  124. ConstantType<int> m_iRankDifferenceInLayers; /*!< Rank difference between two layers >*/
  125. ConstantType<int> m_iTotalLayers; /*!< Total number of layers in graph >*/
  126. /*! 'VertexPair' type is defined to use to store the source and target vertices of edge
  127. Because once the edge is deleted from graph the EdgeDescriptor becomes invalid */
  128. typedef std::pair<VertexDescriptor , VertexDescriptor > VertexPair;
  129. //Map of deleted long edges with their dummy vertices
  130. QMap<VertexPair , QVector<VertexDescriptor> * > m_mapDeletedLongEdgesToDummyVertex;
  131. typedef QMapIterator<VertexPair , QVector<VertexDescriptor> * > IteratorMapDeletedLongEdgeToVectorDummyVertex;
  132. //Map of reversed edges
  133. QMultiMap<VertexDescriptor , VertexDescriptor> m_mapReversedEdges;
  134. QMultiMap<VertexPair , EdgeProperties*> m_mapDeletedEdgeProperties; /*!< Map of vertex pairs to deleted edge properties >*/
  135. QMultiMap<VertexPair , EdgeProperties*> m_mapReversedEdgeProperties; /*!< Map of vertex pairs to reversed edge properties >*/
  136. QMultiMap<VertexPair, EdgeDescriptor> m_mapVertexPairToReversedEdgeDescriptor; /*!< Map of vertex pairs to edge >*/
  137. /*! This is global hash map of layer nodes, to which the Layered
  138. * Graph and Nesting Tree will point so the changes will be
  139. * consistent throughout because the use of these common
  140. * data objects
  141. */
  142. QHash<VertexDescriptor , LayerNode*> hashVertexToLayerNode;
  143. typedef QHashIterator<VertexDescriptor , LayerNode*> IteratorHashVertexToLayerNode;
  144. MapLayerIdtoReducedNestedTreeRef m_mapLayerReducedNestedTree;
  145. /*! Nesting tree stores the ownership relation of vertices to
  146. * their direct parent graph and from subgraphs to their parent graphs
  147. */
  148. NestingTreeSubgraphNode m_rootNestingTreeSubgraphNode;
  149. QVector<int> m_vecSortedRanks; /*!< sorted vector of ranks >*/
  150. //*************************************************************************
  151. int m_iFinalCrossings; /*!< Final crossing counter >*/
  152. //******************************POSITIONING *******************************
  153. typedef QVector<double> QVectorDouble; /*!< vector of double >*/
  154. typedef QVector<QMap<int , double> > VecMapShiftClass; /*!< Vector for holding shift value of classes of vertices from BK algorithm >*/
  155. double dDelta;
  156. ConstantType<int> m_iReductionParameterHorizontal; /*!< This parameter decides the total number of pixels per unit horizontal position >*/
  157. ConstantType<int> m_iNodeSeparation; /*!< Node separation >*/
  158. ConstantType<int> m_iEdgeSeparation; /*!< Edge separation >*/
  159. ConstantType<int> m_iRankSeparation; /*!< Rank separation >*/
  160. ConstantType<int> m_iBorderMargin; /*!< Edge separation >*/
  161. //*************************************************************************
  162. /**
  163. This function counts the graphs nesting depth
  164. @pre
  165. -# gGraph != NULL
  166. @param gGraph
  167. reference to the graph
  168. @return none
  169. @throws none
  170. */
  171. int getGraphNestingDepth(SubGraph& gGraph);
  172. /**
  173. This function creates a nested tree by adding border nodes and nesting edges
  174. @pre
  175. -# gGraph != NULL
  176. @param gGraph
  177. reference to the graph
  178. @return none
  179. @throws BoostException
  180. @throws LayoutException
  181. @throws MemoryException
  182. */
  183. void createNestingGraph(SubGraph &gGraph);
  184. /**
  185. This function adds upper and lower border vertices and nesting edges in the child graph and sets the references to the vChildUpperBorder and vChildLowerBorder vertices.
  186. @pre
  187. -# gGraph != NULL
  188. @param gGraph
  189. reference to the child graph
  190. @param vUpperChildNode
  191. reference to the upper border vertex of child graph
  192. @param vLowerChildNode
  193. reference to the lower border vertex of child graph
  194. @return none
  195. @throws none
  196. */
  197. void addNestingToChildByRecur(SubGraph& gGraph , VertexDescriptor& vUpperBorder , VertexDescriptor& vLowerBorder);
  198. /**
  199. This function assigns ranks to every vertex in the tree graph
  200. @pre
  201. -# gGraph != NULL
  202. @param gGraph
  203. reference to the graph
  204. @return none
  205. @throws LayoutException
  206. -# REQUIRED_PARAMETER_NOT_SET if nesting depth is not set
  207. -# INVALID_OPERATION if upper border vertex index is not less by 1 than lower border vertex
  208. @throws BoostException
  209. @throws MemoryException
  210. */
  211. void assignVertexRanks(SubGraph &gGraph , VertexDescriptor vRootVertex);
  212. /**
  213. This function adjusts vertices rank
  214. @pre
  215. -# gGraph != NULL
  216. @param gGraph
  217. reference to the graph
  218. @return none
  219. @throws LayoutException
  220. -# REQUIRED_PARAMETER_NOT_SET if nesting depth is not set
  221. */
  222. void adjustVertexRanks(SubGraph &gGraph);
  223. /**
  224. This function pulls assigned ranks of every vertex if it can be pulled up. This reduces some long edges and therefor the dummy nodes
  225. @pre
  226. -# gGraph != NULL
  227. @param gGraph
  228. reference to the graph
  229. @return none
  230. @throws LayoutException
  231. -# REQUIRED_PARAMETER_NOT_SET if nesting depth is not set
  232. -# INAVALID_OPERATION if upper border vertex index is not less by 1 than lower border vertex
  233. */
  234. void pullUpVertexRanks(SubGraph &gGraph , VertexDescriptor vRootVertex);
  235. /**
  236. This function pulls assigned ranks of every vertex if it can be pulled up. This reduces some long edges and therefor the dummy nodes
  237. @pre
  238. -# gGraph != NULL
  239. @param gGraph
  240. reference to the graph
  241. @return none
  242. @throws none
  243. */
  244. void pullAndSpreadUpVertexRanks(SubGraph &gGraph , VertexDescriptor vRootVertex);
  245. /**
  246. This function records unique rank values and sort them
  247. @pre none
  248. @param none
  249. @return none
  250. @throws none
  251. */
  252. void recordUniqueRankAndSort();
  253. /**
  254. This function removes nesting long edges
  255. @pre none
  256. @param none
  257. @return none
  258. @throws none
  259. */
  260. void removeNestingEdges();
  261. /**
  262. This function splits the long edges using dummy nodes and add Dummy node LayerNode, adds it to Nesting Tree also
  263. @pre none
  264. @param none
  265. @return none
  266. @throws LayoutException
  267. -# INCONSISTENT_DATASTRUCTURE if boost graph contains duplicate long edges
  268. */
  269. int splitLongEdgesAndUpdateNestingTree();
  270. /**
  271. This function return edge span. It is the difference between source and destinition vertex rank values.
  272. @pre
  273. -# eEdge != NULL
  274. @param eEdge
  275. edge
  276. @return int
  277. edge span value
  278. @throws none
  279. */
  280. int edgeSpan(EdgeDescriptor eEdge, SubGraph &gGraph);
  281. /**
  282. This function removes the cycles from the graph by removing back edges. Records the back edges into provided vector of edges.
  283. @pre
  284. -# gGraph != NULL
  285. @param gGraph
  286. reference to the graph
  287. @param vectBackEdges
  288. vector of edges to record the back edges which creates cycle
  289. @return none
  290. @throws Boost Exception
  291. @throws LayoutException
  292. */
  293. void removeCycle(SubGraph& gGraph , VectorEdgeDescriptor& vectBackEdges);
  294. /**
  295. This function initiates hashVertexToLayerNode
  296. @pre none
  297. @param none
  298. @return none
  299. @throws none
  300. */
  301. void initHashVertexToLayerNode(SubGraph &gGraph);
  302. /**
  303. This function is for creating root node of nesting tree, it generates nesting tree by internally calling its recursive version
  304. @pre none
  305. @param none
  306. @return none
  307. @throws BoostException
  308. */
  309. void generateNestingTree();
  310. /**
  311. This function creates nesting tree recursively
  312. @pre none
  313. @param none
  314. @return none
  315. @throws none
  316. */
  317. void generateNestingTreeByRecur(NestingTreeSubgraphNode &nestingTreeSubgraphNodes , SubGraph &gRootGraph);
  318. /**
  319. This function returns path between provided nesting tree nodes
  320. @pre
  321. -# &sourceSubgraphNode != NULL
  322. -# &targetSubgraphNode != NULL
  323. @param none
  324. @return path between source and target subgraph nodes in nesting tree in a queue of nesting subgraph node
  325. @throws none
  326. */
  327. void getNestingTreeSubgraphNodesPath(NestingTreeSubgraphNode& sourceSubgraphNode , NestingTreeSubgraphNode& targetSubgraphNode , QueueNestingTreeSubgraphNodesRef &qNestingTreeSubgraphNodesRef);
  328. /**
  329. This function generates LayeredGraph, creates Layers of LayerNodes which have same rank as the LayerId of the Layer, and creates Map of Layers thus provides access to the graph Horizontally (Layer wise).
  330. @pre
  331. -# gRankedRootGraph.is_root() == true
  332. @param none
  333. @return none
  334. @throws none
  335. */
  336. void generateLayeredGraph();
  337. /**
  338. This function reversed the layer node sequence and updates the new positions into the vertex horizontalPosition property
  339. @pre none
  340. @param none
  341. @return none
  342. @throws none
  343. */
  344. void reverseLayerNodesPositions(int iLayerId);
  345. /**
  346. This function reverses the layered graph layers horizontally
  347. @pre none
  348. @param none
  349. @return none
  350. @throws LayoutException
  351. -# INCONSISTENT_DATASTRUCTURE if layered graph becomes inconsistent while reversing layers horizontally
  352. @throws BoostException
  353. @throws MemoryException
  354. */
  355. void reverseLayeredGraphHorizontaly();
  356. /**
  357. This function reverses the layered graph layers vertically. But it does not update the rank values of vertices
  358. @pre none
  359. @param none
  360. @return none
  361. @throws MemoryException
  362. */
  363. void reverseLayeredGraphVertically();
  364. /**
  365. This function restores the BackEdges and Long edges. Adds bend points to the long edges
  366. @pre none
  367. @param none
  368. @return none
  369. @throws none
  370. */
  371. void restoreReversedAndLongEdgesWithBendPoints();
  372. /**
  373. This function stores edge properties and returns a pointer to the structure
  374. @pre none
  375. @param none
  376. @return a pointer to the new EdgeProperties storing structure
  377. @throws none
  378. */
  379. EdgeProperties* recordEdgeProperties(EdgeDescriptor& eGlobalEdge);
  380. /**
  381. This function sets edge's stored properties
  382. @pre none
  383. @param none
  384. @return none
  385. @throws none
  386. */
  387. void setEdgeProperties(EdgeDescriptor& eGlobalEdge , EdgeProperties* edgeProperties);
  388. //****************************CROSSING REDUCTION*******************************************************
  389. /**
  390. This function reduces edge crossings without considering the subgraph using BarryCenter Method
  391. @pre
  392. -# gMainGraph.is_root() == true
  393. @param gMainGraph
  394. reference to main graph
  395. @return none
  396. @throws none
  397. */
  398. void globalCrossingReducion(SubGraph& gMainGraph);
  399. /**
  400. This function reduces edge crossings without considering the subgraph using BarryCenter Method
  401. @pre
  402. -# m_mapLayeredGraph.contains(iLayerId) == true
  403. @param iLayerId
  404. layer id (rank) of Layer to be sorted by barrycenters
  405. @param enDirection
  406. direction of barry center weights calculation
  407. @return none
  408. @throws LayoutException
  409. -# INVALIS_OPERATION if first layer id in the provided direction is given for sorting by barycenters
  410. -# NOT_FOUND_IN_CONTAINER if given layer id is not fond in layered graph
  411. @throws BoostException
  412. */
  413. void sortLayerByBarryCenters(int iLayerId , ProcessDirection enDirection , NeighborNodes enNeighborNodes);
  414. /**
  415. This function reduces edge crossings by considering the subgraphs
  416. @pre
  417. -# gMainGraph.is_root() == true
  418. @param gMainGraph
  419. reference to main graph
  420. @param iCrossingReductionDegree
  421. parameter to control crossing reduction process iterations
  422. @return none
  423. @throws LayoutException
  424. @throws BoostException
  425. @throws MemoryException
  426. */
  427. void reduceEdgeCrossings(int iCrossingReductionDegree);
  428. /**
  429. This function reduces edge crossings using BarryCenter method and ReducedNestingTree method. It places nodes of each subgraph in unbroken sequence on each layer while reducing the crossings.
  430. @pre none
  431. @param bIsUpwardDirection
  432. boolean to decide the direction
  433. @return none
  434. @throws LayoutException
  435. @throws BoostException
  436. @throws MemoryException
  437. */
  438. void crossingReductionByReducedNestingTree(bool bIsUpwardDirection);
  439. /**
  440. This function reduces edge crossings using SubgraphOrderingGraph method. It places nodes of each subgraph in unbroken sequence on all layers.
  441. @pre none
  442. @param bIsUpwardDirection
  443. boolean to decide the direction
  444. @return none
  445. @throws LayoutException
  446. -# INCONSISTENT_DATASTRUCTURE if subgraph ordering graph is inconsistent
  447. @throws BoostException
  448. @throws MemoryException
  449. */
  450. void crossingReductionBySubgraphOrderingGraph(bool bIsUpwardDirection);
  451. /**
  452. This function sorts all nodes by only single subgraph ordering graph.
  453. @pre none
  454. @param none
  455. @return none
  456. @throws none
  457. */
  458. void crosingReductionFinalTopologicalSorting();
  459. /**
  460. This function sorts the layerNodes according to their vertex iTopological Order Property
  461. @pre none
  462. @param iLayerId
  463. layer id of the layer to be sorted
  464. @return none
  465. @throws LayoutException
  466. -# NOT_FOUND_IN_CONTAINER if layer id is not found in layered graph
  467. -# INCONSISTENT_DATASTRUCTURE if layer is not properly sorted by topological order or node positions are inconsistent with their horizontal positions in graph
  468. */
  469. void sortLayerByTopologicalOrder(int iLayerId);
  470. /**
  471. This function reduces edge crossings without considering the subgraph using BarryCenter Method
  472. @pre
  473. -# m_mapLayeredGraph.contains(iLayerId) == true
  474. -# nestingTreeRootNode != NULL
  475. @param iLayerId
  476. layer id (rank) of Layer
  477. @param nestingTreeRootNode
  478. root nesting tree node
  479. @param reducedNestingTreeNode
  480. outparameter reduced nesting tree node
  481. @return none
  482. @throws LayoutException
  483. -# INVALID_PARAMETER if invalid layer id is passed
  484. -# INCONSISTENT_DATASTRUCTURE if incorrect ReducedNestingTree or Layer is generated
  485. @throws BoostException
  486. */
  487. void doSortedTraversalByReducedNestingTree(int iLayerId );
  488. /**
  489. This function creates reduced nested tree for given iLayerId
  490. @pre
  491. -# m_mapLayeredGraph.contains(iLayerId) == true
  492. -# nestingTreeRootNode != NULL
  493. @param iLayerId
  494. layer id (rank) of Layer
  495. @param nestingTreeRootNode
  496. root nesting tree node
  497. @param reducedNestingTreeNode
  498. outparameter reduced nesting tree node
  499. @return none
  500. @throws none
  501. */
  502. void createReducedNestedTree(int iLayerId , NestingTreeSubgraphNode &nestingTreeRootNode , ReducedNestingTreeNode &reducedNestingTreeNode);
  503. /**
  504. This function creates Layer sorted according to the provided ReducedNestingTree
  505. @pre
  506. -# newLayer.isEmpty() == true
  507. @param newLayer
  508. out parameter layer
  509. @param reducedNestingTreeRootNode
  510. root node of reduced nesting tree
  511. @return none
  512. @throws none
  513. */
  514. void generateLayerByReducedNestingTree(MapPositionToLayerNode &newLayer , ReducedNestingTreeNode &reducedNestingTreeRootNode);
  515. /**
  516. This is recursive function to add LayerNodes sorted according to the provided ReducedNestingTree in provided Layer
  517. @pre
  518. -# iHorizontalPosition > 0
  519. @param iHorizontalPosition
  520. integer to provide horizontal position to LayerNodes in new Layer
  521. @param newLayer
  522. out parameter layer
  523. @param reducedNestingTreeRootNode
  524. root node of reduced nesting tree
  525. @return none
  526. @throws none
  527. */
  528. void generateLayerByReducedNestingTreeRecur(int &iHorizontalPosition , MapPositionToLayerNode &newLayer , ReducedNestingTreeNode &reducedNestingTreeRootNode);
  529. //Function to get upper/lower layer id from current layer id
  530. /**
  531. This function gives next layer in the provided direction of the provided layer type
  532. @pre
  533. -# m_mapLayeredGraph.contains(iLayerId) == true
  534. @param iLayerId
  535. layer id
  536. @param enDirection
  537. direction enum
  538. @param enLayerType
  539. layer type enum for specifying type of layer
  540. @return none
  541. @throws none
  542. */
  543. int getNextLayerId(int iLayerId , ProcessDirection enDirection , LayerType enLayerType = AnyTypeLayer);
  544. public:
  545. /**
  546. This function gives number of crossings in a layered graph
  547. @pre none
  548. @param none
  549. @return none
  550. @throws LayoutException
  551. -# INVALID_OPERATION if any two layer upper and lower layer edge sources queue and targets queue respectively, size mismatches
  552. @throws BoostException
  553. @throws MemoryException
  554. */
  555. int getTotalCrossings();
  556. private:
  557. //***************************CROSSING REDUCTION END************************************************************
  558. //***************************SUBGRAPH ORDERING GRAPH************************************************************
  559. typedef QMap<NestingTreeSubgraphNode* , SubgraphOrderingGraphType*> MapNestingTreeRefToSubgraphOrderingGraphRef;
  560. typedef QMapIterator<NestingTreeSubgraphNode* , SubgraphOrderingGraphType*> IteratorMapNestingTreeRefToSubgraphOrderingGraphRef;
  561. MapNestingTreeRefToSubgraphOrderingGraphRef m_mapNestingTreeNodeRefToSubgraphOrderingGraphRef;
  562. SubgraphOrderingGraphWrapper m_subgraphOrderingGraphWrapper;
  563. /**
  564. This function creates empty subgraphOrderingGraphs for each NestingTreeSubgraphNode and stores its entry in global map m_mapNestingTreeNodeRefToSubgraphOrderingGraphRef
  565. @pre none
  566. @param none
  567. @return none
  568. @throws LayoutException
  569. -# INCONSISTENT_DATASTRUCTURE if invalid Subgraph Ordering Graph is created
  570. @throws BoostException
  571. */
  572. void createEmptySubgraphOrderingGraphsForEachNestingTreeSubgraphNode();
  573. //Generate SubgraphOrdering Graph
  574. /**
  575. This function generates nodes and edges into empty subgraphs created for each Nesting Tree Subgraph Node
  576. @pre none
  577. @param none
  578. @return none
  579. @throws LayoutException
  580. @throws BoostException
  581. */
  582. void generateSubgraphOrderingGraph();
  583. /**
  584. This function adds layer nodes and edges accoring to the 'left of' relations into Subgraph Ordering Graphs
  585. @pre none
  586. @param none
  587. @return none
  588. @throws LayoutException
  589. -# NOT_FOUND_IN_CONTAINER if Left node nesting tree parent tree does not contain Root nesting tree node or if any vertex is not found in Subgraph Ordering Graph
  590. -# INVALID_OPERATION if finding common parent for any two neighbor nodes process fails
  591. -# INVALID_PARAMETER if left or right nesting tree node index in generated list of parent nesting tree nodes found to be a negative value
  592. */
  593. void populateNodesAndEdgesInSubgraphOrderingGraph();
  594. /**
  595. This function adds layer node to its own parent NestingTreeSubgraphNode's SubgraphOrderingGraph
  596. @pre
  597. -# layerNode->getSubgra
  598. @param layerNode
  599. layer node
  600. @return none
  601. @throws none
  602. */
  603. void addLayerNodeToOwnParentSubgraphOrderingGraph(LayerNode* layerNode);
  604. /**
  605. This function gives parent SubgraphOrderingGraph pointer from nesting tree node
  606. @pre none
  607. @param nestingTreeNode
  608. nesting tree node
  609. @return pointer to SubgraphOrderingGraph pointer for nesting tree node
  610. @throws none
  611. */
  612. SubgraphOrderingGraphType* getParentSubgraphOrderingGraph(NestingTreeSubgraphNode* nestingTreeNode);
  613. //Give topological order to vertices according to Subgraph Ordering Graph
  614. //Sort Layered Graph According to Subgraph Ordering Graph
  615. //Remove cycles in Subgraph Ordering Graphs
  616. /**
  617. This function removes cycles from SubgraphOrderingGraphs
  618. @pre none
  619. @param none
  620. @return none
  621. @throws LayoutException
  622. -# EMPTY_CONTAINER if map nesting tree nodes to their Subgraph ordering graph is empty
  623. @throws BoostException
  624. @throws MemoryException
  625. */
  626. void removeCycleFromSubgraphOrderingGraph();
  627. /**
  628. This function break cycle created by provided node nodes at node among the all participating nodes in cycle which has least most average barrycenter
  629. @pre
  630. -# gSubgraphOrderingGraph.find_edge(eBackEdge).second == true
  631. @param eBackEdge
  632. a back edge detected in SubgraphOrderingGraph
  633. @param gSubgraphOrderingGraph
  634. SubgraphOrderingGraph
  635. @return none
  636. @throws LayoutException
  637. -# NOT_FOUND_IN_CONTAINER if back edge is not found in Subgraph Ordering Graph
  638. -# INVALID_PARAMETER if the back edge is actually a self loop i.e. an edge from a vertex to itself
  639. @throws BoostException
  640. @throws MemoryException
  641. */
  642. void breakCycleAtSmallestAverageBarryCenterNode(SubgraphOrderingGraphEdgeDescriptor eBackEdge , SubgraphOrderingGraphType& gSubgraphOrderingGraph);
  643. /**
  644. This function assigns topological order according to SubgraphOrderingGraph to all vertices of original graph
  645. @pre
  646. -# iStartOrder > 0
  647. -# m_mapNestingTreeNodeRefToSubgraphOrderingGraphRef.contains(nestingTreeNode)
  648. @param iStartOrder
  649. the order value to give to first vertex in the SubgraphOrderingGraph pointed by provided NestingTreeSubgraphNode
  650. @param nestingTreeNode
  651. nesting tree node which points to the SubgraphOrderingGraph
  652. @return the next value of last order value assigned in SubgraphOrderingGraph
  653. @throws LayoutException
  654. -# INVALID_PARAMETER if Start Order for topological order of subgraph ordering graph is zero or negative
  655. -# NOT_FOUND_IN_CONTAINER if nesting tree node entry not found in map of nesting tree nodes to their subrgaph ordering graphs
  656. -# INVALID_OPERATION if operation of assigning topological order to nodes of leaf subgaph ordering graph fails
  657. */
  658. int assignTopologicalOrderAccordingToSubgraphOrderingGraph(int iStartOrder , NestingTreeSubgraphNode* nestingTreeNode);
  659. /**
  660. This function calculate and update AverageBarryCenter weights of NestingTreeNodes in SubgraphOrderingGraph
  661. @pre none
  662. @param none
  663. @return none
  664. @throws LayoutException
  665. -# EMPTY_CONTAINER if map of nesting tree nodes to their subgraph ordering graph object references is empty
  666. */
  667. void updateAverageBarryCenterForNestingTreeNodes();
  668. /**
  669. This function gives average BarryCenter weight of vertex in SubgraphOrderingGraph efficiently
  670. @pre
  671. -# gSubgraphOrderingGraph.find_vertex(vVertex).second == true
  672. @param vVertex
  673. vertex of SubgraphOrderingGraph
  674. @param gSubgraphOrderingGraph
  675. SubgraphOrderingGraph
  676. @return average barrycenter position of provided vertex
  677. @throws none
  678. */
  679. double getSubgraphOrderingGraphVertexAverageBarryCenter(SubgraphOrderingGraphVertexDescriptor vVertex , SubgraphOrderingGraphType &gSubgraphOrderingGraph);
  680. //***************************SUBGRAPH ORDERING GRAPH END******************************************************
  681. //***************************VERTICAL BORDER DRAWING**********************************************************
  682. /**
  683. This function add VerticalBorder nodes to define subgraph vertical boundaries
  684. @pre
  685. -# m_iRankDifferenceInLayers.isSet() == true
  686. @param none
  687. @return none
  688. @throws LayoutException
  689. -# REQUIRED_PARAMETER_NOT_SET if rank difference between layers is not set
  690. @throws BoostException
  691. @throws MemoryException
  692. */
  693. void addVerticalBorderNodesForSubgraphs();
  694. /**
  695. This function add VerticalBorder nodes for given NestingTreeSubgraphNode recursively starting from innermost NestingTreeSubgraphNode
  696. @pre none
  697. @param nestingTreeNode
  698. NestingTreeSubgraphNode to which vertical border nodes are to be added
  699. @return none
  700. @throws LayoutException
  701. -# INVALID_OPERATION if vertical border node is added at horizontal position which is already taken by another node at same layer
  702. @throws BoostException
  703. @throws MemoryException
  704. */
  705. void addVerticalBorderNodesNestingTreeRecur(NestingTreeSubgraphNode& nestingTreeNode);
  706. /**
  707. This function adds dummy nodes in empty layers of each subgraphs. This is neccessary in order to give vertical border vertex at every layer of every subgraph.
  708. @pre none
  709. @param none
  710. @return none
  711. @throws LayoutException
  712. @throws BoostException
  713. */
  714. void addDummyNodeToEmptyLayersRecur(NestingTreeSubgraphNode& rootNestingTreeNode);
  715. /**
  716. This function updates horizontal positions of LayerNodes on each layer, space them to accomodate Vertical Border Nodes
  717. @pre
  718. m_iRankDifferenceInLayers.isSet() == true
  719. @param none
  720. @return none
  721. @throws LayoutException
  722. -# REQUIRED_PARAMETER_NOT_SET if rank difference between layers is not set
  723. @throws BoostException
  724. @throws MemoryException
  725. */
  726. void setHorizontalPositionsForVerticalBorderNodes();
  727. //***************************VERTICAL BORDER DRAWING END******************************************************
  728. //***************************POSITIONING***********************************************************************
  729. /**
  730. This function generates center coordinates of all vertices according to their rank and horizontal position values
  731. @pre
  732. -# gMainGraph.is_root() == true
  733. @param none
  734. @return none
  735. @throws LayoutException
  736. -# INVALID_PARAMETER if provided graph is not a root graph
  737. -# REQUIRED_PARAMETER_NOT_SET if y coordinate or next layer's height is not set
  738. @throws BoostException
  739. @throws MemoryException
  740. */
  741. void assignYCoordinates(SubGraph& gMainGraph);
  742. /**
  743. This function calculates and writes compartment (cluster) border left top coordinates and height - width to Graph properties
  744. @pre none
  745. @param none
  746. @return none
  747. @throws BoostException
  748. */
  749. void setSubgraphCompartmentProperties();
  750. /**
  751. This function generates x coordinates of all vertices according to their horizontal position values
  752. @pre
  753. -# iHorizontalStep > 0
  754. @param iHorizontalStep
  755. space between two nodes 1 distance apart
  756. @return none
  757. @throws none
  758. */
  759. void applyXCoordinatesFromHorizontalPosition(int iHorizontalStep);
  760. /**
  761. This function gives coordinates that the space below leaf vertices can also be
  762. utilised and graph width compresses to some extent. It generates center
  763. coordinates of all vertices according to their rank, horizontal position
  764. and out degree values
  765. @pre none
  766. @param none
  767. @return none
  768. @throws LayoutException
  769. -# INCONSISTENT_DATASTRUCTURE if layered graph is inconsistent
  770. @throws MemoryException
  771. @throws BoostException
  772. */
  773. void setHorizontalPosition2();
  774. /**
  775. This function creates average median vertical alignment
  776. @pre
  777. -# vecUpLeftAlign.size() == num_vertices(*m_gMainGraph)
  778. -# vecUpRightAlign.size() == num_vertices(*m_gMainGraph)
  779. -# vecDownLeftAlign.size() == num_vertices(*m_gMainGraph)
  780. -# vecDownRightAlign.size() == num_vertices(*m_gMainGraph)
  781. @param vecUpLeftAlign
  782. out parameter vector of upward left alignment roots of vertices
  783. @param vecUpRightAlign
  784. vector of upward right alignment
  785. @return none
  786. @throws LayoutException
  787. -# INVALID_PARAMETER if any provided alignement vector has size not equal to total number of nodes
  788. @throws MemoryException
  789. @throws BoostException
  790. */
  791. void alignToSmallestAlignment(QVectorDouble &vecUpLeftAlign, QVectorDouble &vecUpRightAlign, QVectorDouble &vecDownLeftAlign, QVectorDouble &vecDownRightAlign);
  792. /**
  793. This function merges the four vertical alignments- UpLeft, UpRight , DownLeft and DownRight
  794. @pre
  795. -# vecUpLeftAlign.size() == num_vertices(*m_gMainGraph)
  796. -# vecUpRightAlign.size() == num_vertices(*m_gMainGraph)
  797. -# vecDownLeftAlign.size() == num_vertices(*m_gMainGraph)
  798. -# vecDownRightAlign.size() == num_vertices(*m_gMainGraph)
  799. @param vecUpLeftAlign
  800. out parameter vector of upward left alignment roots of vertices
  801. @param vecUpRightAlign
  802. vector of upward right alignment
  803. @param vecDownLeftAlign
  804. vector of downward left alignment
  805. @param vecDownRightAlign
  806. vector of downward right alignment
  807. @return a vector of final horizontal positioning by merging the four vertical alignments
  808. @throws LayoutException
  809. -# INVALID_PARAMETER if any provided alignement vector has size not equal to total number of nodes
  810. @throws MemoryException
  811. @throws BoostException
  812. */
  813. QVectorDouble mergeAlignments(QVectorDouble &vecUpLeftAlign, QVectorDouble &vecUpRightAlign, QVectorDouble &vecDownLeftAlign, QVectorDouble &vecDownRightAlign);
  814. /**
  815. This function gives minimum and maximaum positions in given vector of positions
  816. @pre
  817. -# vecPositions.size() == num_vertices(*m_gMainGraph)
  818. @param vecPositions
  819. out parameter vector of upward left alignment roots of vertices
  820. @return none
  821. @throws none
  822. */
  823. void getMinMaxPositions(double &iMinPosition , double &iMaxPosition , QVectorDouble &vecPositions);
  824. /**
  825. This function initialises LeftOf Relation vector of vertices which tells the immediete left neighbor vertex of the vertex on same layer
  826. @pre none
  827. @param none
  828. @return none
  829. @throws LayoutException
  830. -# INVALID_PARAMETER if vector vecLeftNeighborVertex does not have size equal to total number of vertices
  831. @throws BoostException
  832. @throws MemoryException
  833. */
  834. void initLeftNeighborVertexVector(QVectorInt &vecLeftNeighborVertex);
  835. /**
  836. This function marks edge crossings between LongEdgeSegment and GraphEdge and sets it into edge property
  837. @pre none
  838. @param vecIsMarkedEdge
  839. it is an empty vector of bool values for specifying edge is marked as conflicted true or false
  840. @return none
  841. @throws LayoutException
  842. @throws BoostException
  843. @throws MemoryException
  844. */
  845. void markConflictedEdges();
  846. /**
  847. This function creates upward left vertical alignment
  848. @pre
  849. -# vecUpLeftAlignRoot.size() == num_vertices(*m_gMainGraph)
  850. -# vecUpLeftAlign.size() == num_vertices(*m_gMainGraph)
  851. @param vecLeftAlignRoot
  852. out parameter vector of upward left alignment roots of vertices
  853. @param vecLeftAlign
  854. out parameter vector of upward left alignment
  855. @return none
  856. @throws LayoutException
  857. -# INCONSISTENT_DATASTRUCTURE if a vertical border node has out degree or in degree greater than 1
  858. -# INVALID_PARAMETER if vector LeftAlignRoot or UpLeftAlign does not have size equal to total number of vertices
  859. @throws BoostException
  860. @throws MemoryException
  861. */
  862. QVectorInt createUpwardLeftAlignment(QVectorInt &vecUpLeftAlignRoot , QVectorInt &vecUpLeftAlign);
  863. /**
  864. This function creates downward left vertical alignment
  865. @pre
  866. -# vecDownLeftAlignRoot.size() == num_vertices(*m_gMainGraph)
  867. -# vecDownLeftAlign.size() == num_vertices(*m_gMainGraph)
  868. @param vecDownLeftAlignRoot
  869. out parameter vector of downward left alignment roots of vertices
  870. @param vecDownLeftAlign
  871. out parameter vector of downward left alignment
  872. @return none
  873. @throws LayoutException
  874. -# INVALID_OPERATION if the layered graph is not reversed
  875. -# INCONSISTENT_DATASTRUCTURE if a vertical border node has out degree or in degree greater than 1
  876. -# INVALID_PARAMETER if vector DownLeftAlignRoot or DownLeftAlign does not have size equal to total number of vertices
  877. @throws BoostException
  878. @throws MemoryException
  879. */
  880. QVectorInt createDownwardLeftAlignment(QVectorInt &vecDownLeftAlignRoot , QVectorInt &vecDownLeftAlign);
  881. /**
  882. This function creates upward right vertical alignment
  883. @pre
  884. -# vecUpRightAlignRoot.size() == num_vertices(*m_gMainGraph)
  885. -# vecUpRightAlign.size() == num_vertices(*m_gMainGraph)
  886. @param vecUpRightAlignRoot
  887. out parameter vector of upward right alignment roots of vertices
  888. @param vecUpRightAlign
  889. out parameter vector of upward right alignment
  890. @return none
  891. @throws none
  892. */
  893. QVectorInt createUpwardRightAlignment(QVectorInt &vecUpRightAlignRoot , QVectorInt &vecUpRightAlign);
  894. /**
  895. This function creates downward right vertical alignment
  896. @pre
  897. -# vecDownRightAlignRoot.size() == num_vertices(*m_gMainGraph)
  898. -# vecDownRightAlign.size() == num_vertices(*m_gMainGraph)
  899. @param vecDownRightAlignRoot
  900. out parameter vector of upward right alignment roots of vertices
  901. @param vecDownRightAlign
  902. out parameter vector of upward right alignment
  903. @return none
  904. @throws none
  905. */
  906. QVectorInt createDownwardRightAlignment(QVectorInt &vecDownRightAlignRoot , QVectorInt &vecDownRightAlign);
  907. /**
  908. This function gives QMap of median upper neighbors of provided vertex
  909. @pre
  910. -# vVertex >= 0
  911. @param none
  912. @return none
  913. @throws none
  914. */
  915. MapPositionToVertexDescriptor getMedianUpperNeighborsExcludeConflictedEdges(VertexDescriptor &vGlobalVertex);
  916. /**
  917. This function gives QMap of median lower or down neighbors of provided vertex
  918. @pre
  919. -# vVertex >= 0
  920. @param none
  921. @return none
  922. @throws none
  923. */
  924. MapPositionToVertexDescriptor getMedianLowerNeighborsExcludeConflictedEdges(VertexDescriptor &vGlobalVertex);
  925. /**
  926. This function gives horizontal compaction of given vertical alignment considering vertex sizes
  927. @pre
  928. -# vecPositions.size() = num_vertices(mainGraph)
  929. -# vecAlignVertex.size() = num_vertices(mainGraph)
  930. -# vecRootVertex.size() = num_vertices(mainGraph)
  931. -# vecLeftNeighborVertex.size() = num_vertices(mainGraph)
  932. @param vecPositions
  933. vector as out parameter which stores the each vertex horizontal position
  934. @param vecAlignVertex
  935. vector of vertical alignment
  936. @param vecRootVertex
  937. vector of root vertices according to the vertical alignment
  938. @param vecLeftNeighborVertex
  939. vector of left neighbor nodes of vertices on ssame layer
  940. @return none
  941. @throws LayoutException
  942. -# INCONSISTENT_DATASTRUCTURE if horizontal compaction shuffles the node positions or creates inconsistent positions with respect to the alignments of nodes
  943. -# INVALID_PARAMETER if any of vector vecPositions , vecAlignVertex, vecRootVertex, vecLeftNeighborVertex has size not equal to total nodes in the graph
  944. @throws BoostException
  945. @throws MemoryException
  946. */
  947. void horizontalCompaction2(QVectorDouble &vecPositions , const QVectorInt &vecAlignVertex , const QVectorInt &vecRootVertex , const QVectorInt vecLeftNeighborVertex);
  948. /**
  949. This function places the block of vertices according to their vertical alignment using space considerations
  950. @pre
  951. -# vVertex >= 0
  952. -# vecPositions.size() = num_vertices(mainGraph)
  953. -# vecShift.size() = num_vertices(mainGraph)
  954. -# vecSink.size() = num_vertices(mainGraph)
  955. -# vecAlignVertex.size() = num_vertices(mainGraph)
  956. -# vecRootVertex.size() = num_vertices(mainGraph)
  957. -# vecLeftNeighborVertex.size() = num_vertices(mainGraph)
  958. @param none
  959. @return none
  960. @throws LayoutException
  961. -# INVALID_PARAMETER if any provided vector has size not equal to total number of nodes
  962. @throws MemoryException
  963. @throws BoostException
  964. */
  965. void placeBlock2(int iLevel
  966. , VertexDescriptor vVertex
  967. , QVectorDouble &vecPositions
  968. , QVectorDouble &vecShift
  969. , QVectorInt &vecSink
  970. , const QVectorInt &vecAlignVertex
  971. , const QVectorInt &vecRootVertex
  972. , const QVectorInt &vecLeftNeighborVertex
  973. , VecMapShiftClass &mapShiftClass);
  974. /**
  975. This function updates shift for class of vertices having same sink
  976. @pre
  977. -# iToShift >= 0
  978. -# iNeighbor >= 0
  979. @param iToShift
  980. vertex to shift
  981. @param iNeighbor
  982. vertex neighbor to iToShift vertex
  983. @param mapShiftClass
  984. map to store shifts of classes of vertices
  985. @return none
  986. @throws none
  987. */
  988. void updateShift(int iToShift , int iNeighbor , double dDelta, VecMapShiftClass &mapShiftClas);
  989. /**
  990. This function provides separation value in pixels
  991. @pre
  992. -# vVertex >= 0
  993. @param vVertex
  994. vertex index
  995. @return number of pixels separation required
  996. @throws none
  997. */
  998. int separation(VertexDescriptor vVertex);
  999. /**
  1000. This function adjusts x and y coordinates of vertices to shift to left top point according to height and width of them
  1001. @pre none
  1002. @param none
  1003. @return none
  1004. @throws BoostException
  1005. */
  1006. int shiftVertexCoordinateToLeftTop();
  1007. //*****************************Miscelleneous Function*********************************************************
  1008. /**
  1009. This function prints indent space according to level
  1010. @pre
  1011. -# iLevel >= 0
  1012. @param none
  1013. @return none
  1014. @throws none
  1015. */
  1016. QString printIndent(int iLevel);
  1017. //************************************************************************************************************
  1018. /*Testing Functions:
  1019. */
  1020. /**
  1021. This function tests if proper ranking is assigned and there are no upward edges exist
  1022. @pre
  1023. -# gGraph != NULL
  1024. @param gGraph
  1025. reference to the graph
  1026. @return none
  1027. @throws none
  1028. */
  1029. bool testUpwardEdgesAndRanks(SubGraph &gGraph);
  1030. /**
  1031. This function tests if proper layered graph is created: 1. checks if all vertices are present in layered graph
  1032. @pre none
  1033. @param gGraph
  1034. reference to the graph
  1035. @return none
  1036. @throws none
  1037. */
  1038. bool testLayeredGraph();
  1039. /**
  1040. This function tests consistancy of LayerNode position in Layer and the actual Vertex property iHorizontalPosition, they should be same
  1041. @pre none
  1042. @param mapPositionToLayerNode
  1043. map of LayerNodes representing the layer
  1044. @param gMainGraph
  1045. reference to main (root) graph
  1046. @return bool value true if all LayerNode position are consistent with corrensponding Vertex's property iHorizopntalPosition otherwise returns false
  1047. @throws none
  1048. */
  1049. int testGetLayerKeysAndVertexPositionNotConsistentCount(MapPositionToLayerNode& mapPositionToLayerNode , SubGraph& gMainGraph);
  1050. /**
  1051. This function tests the horizontal compaction aligned horizontalPositions of vertices changes the original order of nodes on layer or not
  1052. @pre
  1053. -# veAlignedPosition.size() == num_vertices(*m_gMainGraph)
  1054. @param veAlignedPosition
  1055. vector of vertices horizontal position
  1056. @return bool value true horizontal compaction aligned horizontalPositions of vertices changes the original order of nodes on layer otherwise false
  1057. @throws none
  1058. */
  1059. bool testHorizontalCompaction(QVectorInt &vecAlignedPosition);
  1060. /**
  1061. This function tests the horizontal compaction aligned horizontalPositions of vertices changes the original order of nodes on layer or not
  1062. @pre
  1063. -# veAlignedPosition.size() == num_vertices(*m_gMainGraph)
  1064. @param veAlignedPosition
  1065. vector of vertices horizontal position
  1066. @return bool value true horizontal compaction aligned horizontalPositions of vertices changes the original order of nodes on layer otherwise false
  1067. @throws none
  1068. */
  1069. bool testHorizontalCompaction(QVectorDouble &vecAlignedPosition);
  1070. /**
  1071. This function tests the aligned horizontalPositions of vertices with their alignment
  1072. @pre
  1073. -# veAlignedPosition.size() == num_vertices(*m_gMainGraph)
  1074. -# vecAlign.size() == num_vertices(*m_gMainGraph)
  1075. @param veAlignedPosition
  1076. vector of vertices horizontal position
  1077. @return bool value true horizontal compaction aligned horizontalPositions of vertices changes the original order of nodes on layer otherwise false
  1078. @throws none
  1079. */
  1080. bool testPositionWithAlignment(const QVectorInt &vecAlignedPosition , const QVectorInt &vecAlign);
  1081. /**
  1082. This function tests the aligned horizontalPositions of vertices with their alignment
  1083. @pre
  1084. -# veAlignedPosition.size() == num_vertices(*m_gMainGraph)
  1085. -# vecAlign.size() == num_vertices(*m_gMainGraph)
  1086. @param veAlignedPosition
  1087. vector of vertices horizontal position
  1088. @return bool value true horizontal compaction aligned horizontalPositions of vertices changes the original order of nodes on layer otherwise false
  1089. @throws none
  1090. */
  1091. bool testPositionWithAlignment(const QVectorDouble &vecAlignedPosition , const QVectorInt &vecAlign);
  1092. /**
  1093. This function writes current hierarchical layout execution time details and number off nodes, edes, ling edges to CSV file: FILENAME_EXECUTION_TIME_DETAILS from HIERARCHICALLAYOUTTESTINGCONSTANTS_H
  1094. @pre none
  1095. @param sExecutionDetails
  1096. string containing details in comma separated form
  1097. @return none
  1098. @throws none
  1099. */
  1100. void writeLog(QString sExecutionDetails);
  1101. /**
  1102. This function tests the number of nodes and subgraph count in the generated nesting tree
  1103. @pre none
  1104. @param none
  1105. @return bool value true if the nesting tree is correct otherwise false
  1106. @throws none
  1107. */
  1108. bool testNestingTree();
  1109. /**
  1110. This function tests the number of nodes and subgraph count in the generated Reduced Nesting tree
  1111. @pre
  1112. -# reducedNestingTreeRoot.isLayerNode() == false
  1113. @param reducedNestingTreeRoot
  1114. root reduced nesting tree node
  1115. @return bool value true if the Reduced Nesting tree is correct otherwise false
  1116. @throws none
  1117. */
  1118. bool testReducedNestingTree(ReducedNestingTreeNode &reducedNestingTreeRoot);
  1119. /**
  1120. This function tests SubgraphOrderingGraphs are consistent with NestingTreeSubgraphNode structure
  1121. @pre none
  1122. @param none
  1123. @return bool value true if SubgraphOrderingGraphs are consistent with NestingTreeSubgraphNode structure otherwise false
  1124. @throws none
  1125. */
  1126. bool testSubgraphOrderingGraph();
  1127. /**
  1128. This function tests if layerNodes are sorted according their iTopologicalOrder value
  1129. @pre
  1130. -# m_mapLayeredGraph.contains(iLayerId)==true
  1131. @param none
  1132. @return bool value true if layerNodes are sorted according their iTopologicalOrder value otherwise false
  1133. @throws none
  1134. */
  1135. bool testIsLayerTopologicallySorted(int iLayerId);
  1136. //************************************************************************************************************
  1137. };
  1138. #endif // HIERARCHICALLAYOUTER_H