testgraphmlwriter.h 2.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. #ifndef TESTGRAPHMLWRITER_H
  2. #define TESTGRAPHMLWRITER_H
  3. #include <QFile>
  4. #include <iostream>
  5. #include <QTime>
  6. #include <boost/graph/graphml.hpp>
  7. #include <boost/graph/subgraph.hpp>
  8. #include <boost/graph/adjacency_list.hpp>
  9. #include <boost/graph/graph_utility.hpp>
  10. #include <QTextStream>
  11. using namespace std;
  12. using namespace boost;
  13. /**
  14. * @brief VertexProperties
  15. *
  16. * Structure for vertex properties.
  17. */
  18. struct VertexProperties
  19. {
  20. string sId;
  21. string sHeight;
  22. string sWidth;
  23. string sCoord_X;
  24. string sCoord_Y;
  25. };
  26. /**
  27. * @brief EdgeProperties
  28. *
  29. * Structure for edge properties.
  30. */
  31. struct EdgeProperties
  32. {
  33. string sId;
  34. bool bBidirectional;
  35. };
  36. /**
  37. * @brief Graph
  38. *
  39. * Type definition for boost bidirectional graph type.
  40. */
  41. typedef boost::subgraph<
  42. boost::adjacency_list<
  43. boost::vecS,
  44. boost::vecS,
  45. boost::bidirectionalS,
  46. boost::property<
  47. boost::vertex_index_t,
  48. int,
  49. VertexProperties
  50. >,
  51. boost::property<
  52. boost::edge_index_t,
  53. int,
  54. EdgeProperties
  55. >
  56. >
  57. > Graph;
  58. /**
  59. * @brief edgeDescriptor
  60. *
  61. * Type definition for boost bidirectional graph edge type.
  62. */
  63. typedef graph_traits<Graph>::edge_descriptor edgeDescriptor;
  64. /**
  65. * @brief vertexDescriptor
  66. *
  67. * Type definition for boost bidirectional graph vertex type.
  68. */
  69. typedef graph_traits<Graph>::vertex_descriptor vertexDescriptor;
  70. /**
  71. * @brief The TestGraphmlWriter class writes dummy boost graph into temporary file in graphml file format
  72. */
  73. class TestGraphmlWriter
  74. {
  75. public:
  76. QString m_sFileName; /*!< QString to store name of temporary graphML file. */
  77. Graph m_gMainGraph; /*!< Graph used to test writter. */
  78. int m_iTotalNodes; /*!< Integer to store vertex count */
  79. int m_iTotalEdges; /*!< Integer to store edge count */
  80. /** @name Creators
  81. * The methods under this section are responsible for constructing
  82. * an instance of type TestGraphmlWriter.
  83. */
  84. //@{
  85. TestGraphmlWriter();
  86. //@}
  87. /**
  88. This function creates a map of the node, edge, graph and their properties.
  89. This map is later used to generate key declarations for these node, edge or graph.
  90. @pre
  91. @param
  92. @return none
  93. @throw none
  94. */
  95. void test(int iExtraVertices);
  96. /**
  97. This function creates a map of the node, edge, graph and their properties.
  98. This map is later used to generate key declarations for these node, edge or graph.
  99. @pre
  100. @param
  101. @return none
  102. @throw none
  103. */
  104. void generateMainGraph1();
  105. /**
  106. This function creates a map of the node, edge, graph and their properties.
  107. This map is later used to generate key declarations for these node, edge or graph.
  108. @pre
  109. @param
  110. @return none
  111. @throw none
  112. */
  113. void generateMainGraph2(int iGenerateExtraVertice);
  114. };
  115. #endif // TESTGRAPHMLWRITER_H