SpringEmbedder.h 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220
  1. #ifndef SKELETONGRAPH_H
  2. #define SKELETONGRAPH_H
  3. #include<Common/GraphType.h>
  4. #include<Common/BoostGraphWrapper.h>
  5. #include "MembershipInitializer.h"
  6. #include <HierarchicalLayoutGenerator/HierarchicalLayouter.h>
  7. #include <Common/LayoutEnum.h>
  8. #include<Common/GraphType.h>
  9. /**
  10. * @brief SpringEmbedder
  11. *
  12. * Applies Eades Spring embedder algorithm to graphs , does not retain
  13. * cluster information.
  14. */
  15. class GRAPHLAYOUTLIBRARYSHARED_EXPORT SpringEmbedder
  16. {
  17. public:
  18. QVector<VertexDescriptor> vVertex; /*!< Vector of vertices */
  19. QVector<double> vXpos; /*!< vector of X Cordinate */
  20. QVector<double> vYpos; /*!< vector of Y Cordinate */
  21. QVector<double> xDisp; /*!< Vector of X Displacement */
  22. QVector<double> yDisp; /*!< Vector of Y Displacement */
  23. QVector<double> xDelta; /*!< Vector of X Delta */
  24. QVector<double> yDelta; /*!< Vector of X Cordinate */
  25. double *dataXPos = NULL; /*!< Pointer to X Cordinate */
  26. double *dataYPos = NULL; /*!< Pointer to Y Cordinate */
  27. double *dataXDisp =NULL; /*!< Pointer to X Displacement */
  28. double *dataYDisp = NULL; /*!< Pointer to Y Displacement */
  29. double *dataXDelta = NULL; /*!< Difference to X values */
  30. double *dataYDelta = NULL; /*!< Differenceto Y values */
  31. double m_dDesiredEdgeLength = 75; /*!< Desired Edge Length */
  32. double m_dIterations = 25; /*!< Desired number of Iterations */
  33. /** @name Creators
  34. * The methods under this section are responsible for constructing or
  35. * destructing an instance of type SpringEmbedder.
  36. */
  37. //@{
  38. /**
  39. Constructs new object of type SpringEmbedder.
  40. @pre none
  41. @param none
  42. @return none
  43. @throw none
  44. */
  45. SpringEmbedder();
  46. //@}
  47. /** @name Modifiers
  48. * The methods under this section are responsible for modifying
  49. * an instance of SpringEmbedder.
  50. */
  51. //@{
  52. /** Sets the desired edge lengths (to be implemented )
  53. @pre
  54. -# gMainGraph != NULL
  55. @param edgeLength
  56. Length of the edge
  57. @return none
  58. @throw none
  59. */
  60. void setDesiredEdgeLength(double edgeLength);
  61. /** Sets the desired of iterations (to be implemented )
  62. @pre
  63. -# gMainGraph != NULL
  64. @param num_iterations
  65. number of iterations
  66. @return none
  67. @throw none
  68. */
  69. void setNoOfIterations(double dNumIterations);
  70. /** Alternative method for Reingold Fruchtermann
  71. @pre
  72. -# gMainGraph != NULL
  73. @param gMainGraph
  74. reference to graph
  75. @return none
  76. @throw none
  77. */
  78. void testSpringVectors(SubGraph& gMainGraph);
  79. /** Alternative method for Spring Embedder
  80. @pre
  81. -#gMainGraph != NULL
  82. @param gMainGraph
  83. reference to graph
  84. @return none
  85. @throw none
  86. */
  87. void testSpring(SubGraph& gMainGraph);
  88. /** Main method for Eades Spring embedder , call Repulse and relax
  89. @pre
  90. -# gMainGraph != NULL
  91. @param gMainGraph
  92. reference to graph
  93. @return none
  94. @throw none
  95. */
  96. void SpringEmbedderStep(SubGraph& gMainGraph);
  97. /** Relax edges one step at a time
  98. @pre
  99. -# gMainGraph != NULL
  100. @param gMainGraph
  101. reference to graph
  102. @return none
  103. @throw none
  104. */
  105. void SpringRelaxEdges(SubGraph& gMainGraph);
  106. /** Repel nodes one step at a time
  107. @pre
  108. -# gMainGraph != NULL
  109. @param gMainGraph
  110. reference to graph
  111. @return none
  112. @throw boost graph exception
  113. */
  114. void SpringRepelVertices(SubGraph& gMainGraph);
  115. /** Addes displacement to nodes
  116. @pre
  117. -# gMainGraph != NULL
  118. @param gMainGraph
  119. reference to graph
  120. @return none
  121. @throw none
  122. */
  123. void SpringMoveNodes(SubGraph& gMainGraph);
  124. //@}
  125. /** @name Queries
  126. * The methods under this section are responsible for accessing
  127. * an instance of type SpringEmbedder.
  128. */
  129. //@{
  130. /** Returns the dimensions of all the enclosing subgraphs as a vector
  131. @pre
  132. -# gMainGraph != NULL
  133. @param gMainGraph
  134. reference to graph
  135. @param vRestBound
  136. Restricted bounds for main graph
  137. @param vClusters
  138. Pointer to sub graphs
  139. @return none
  140. @throw none
  141. */
  142. void getRestrictedBounds(SubGraph& gMainGraph,QVector<int>&
  143. vRestBound, QVector<SubGraph* > vClusters);
  144. /** Returns attractive force between two points
  145. @pre
  146. -# gGraph != NULL
  147. @param idist
  148. distance between two nodes
  149. @param m_iK
  150. Value of constant K
  151. @return attractive force
  152. @throw none
  153. */
  154. double getAttractiveForce(double idist,double m_iK);
  155. /** Returns repulsive force between two points
  156. @pre
  157. -# gMainGraph != NULL
  158. @param idist
  159. distance between two nodes
  160. @param m_iK
  161. Value of constant K
  162. @return repulsive force
  163. @throw none
  164. */
  165. double getRepulsiveForce(double idist,double m_iK);
  166. //@}
  167. };
  168. #endif // SKELETONGRAPH_H