vertex.h 4.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212
  1. /*!
  2. Temelia - graph_t vertex interface.
  3. Copyright (C) 2008, 2009 Ceata (http://cod.ceata.org/proiecte/temelia).
  4. @author Dascalu Laurentiu
  5. This program is free software; you can redistribute it and
  6. modify it under the terms of the GNU General Public License
  7. as published by the Free Software Foundation; either version 3
  8. of the License, or (at your option) any later version.
  9. This program is distributed in the hope that it will be useful,
  10. but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. GNU General Public License for more details.
  13. You should have received a copy of the GNU General Public License
  14. along with this program; if not, write to the Free Software
  15. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  16. */
  17. #ifndef VERTEX_H_
  18. #define VERTEX_H_
  19. #include "platform.h"
  20. #include "graph_constants.h"
  21. struct _vertex_t;
  22. typedef struct _vertex_t *vertex_t;
  23. /*!
  24. * @brief Returns a new vertex having label, identifier and key.
  25. * Complexity O(1)
  26. *
  27. * @param Label
  28. * @param Identifier
  29. * @param Key attached to vertex
  30. */
  31. DECLSPEC vertex_t vertex_new(char *label, unsigned int identifier, void *key);
  32. /*!
  33. * @brief Frees the memory occupied by vertex.
  34. * Complexity O(1)
  35. *
  36. * @param Vertex
  37. */
  38. DECLSPEC void vertex_delete(vertex_t vertex);
  39. /*!
  40. * @brief Returns vertex label.
  41. * Complexity O(1)
  42. *
  43. * @param Vertex
  44. */
  45. DECLSPEC char *vertex_get_label(vertex_t vertex);
  46. /*!
  47. * @brief Returns vertex cost.
  48. * Complexity O(1)
  49. *
  50. * @param Vertex
  51. */
  52. DECLSPEC double vertex_get_cost(vertex_t vertex);
  53. /*!
  54. * @brief Returns vertex identifier.
  55. * Complexity O(1)
  56. *
  57. * @param Vertex
  58. */
  59. DECLSPEC unsigned int vertex_get_identifier(vertex_t vertex);
  60. /*!
  61. * @brief Returns vertex key.
  62. * Complexity O(1)
  63. *
  64. * @param Vertex
  65. */
  66. DECLSPEC void *vertex_get_key(vertex_t vertex);
  67. /*!
  68. * @brief Returns vertex color.
  69. * Complexity O(1)
  70. *
  71. * @param Vertex
  72. */
  73. DECLSPEC char vertex_get_color(vertex_t vertex);
  74. /*!
  75. * @brief Returns 1 if vertex was visited and 0 if not.
  76. * Complexity O(1)
  77. *
  78. * @param Vertex
  79. */
  80. DECLSPEC char vertex_get_visited(vertex_t vertex);
  81. /*!
  82. * @brief Returns the parent identifier of this vertex.
  83. * Complexity O(1)
  84. *
  85. * @param Vertex
  86. */
  87. DECLSPEC unsigned int vertex_get_parent_identifier(vertex_t vertex);
  88. /*!
  89. * @brief Returns the time when the vertex was discovered.
  90. * Complexity O(1)
  91. *
  92. * @param Vertex
  93. */
  94. DECLSPEC unsigned int vertex_get_time_start(vertex_t vertex);
  95. /*!
  96. * @brief Returns the time when the vertex visitation ended.
  97. * Complexity O(1)
  98. *
  99. * @param Vertex
  100. */
  101. DECLSPEC unsigned int vertex_get_time_stop(vertex_t vertex);
  102. /*!
  103. * @brief Sets vertex label.
  104. * Complexity O(1)
  105. *
  106. * @param Vertex
  107. * @param Label reference
  108. */
  109. DECLSPEC void vertex_set_label(vertex_t vertex, char *label);
  110. /*!
  111. * @brief Sets vertex cost.
  112. * Complexity O(1)
  113. *
  114. * @param Vertex
  115. * @param Cost
  116. */
  117. DECLSPEC void vertex_set_cost(vertex_t vertex, double cost);
  118. /*!
  119. * @brief Sets vertex identifier.
  120. * Complexity O(1)
  121. *
  122. * @param Vertex
  123. * @param Identifier
  124. */
  125. DECLSPEC void vertex_set_identifier(vertex_t vertex, unsigned int identifier);
  126. /*!
  127. * @brief Sets vertex key.
  128. * Complexity O(1)
  129. *
  130. * @param Vertex
  131. * @param Key reference
  132. */
  133. DECLSPEC void vertex_set_key(vertex_t vertex, void *key);
  134. /*!
  135. * @brief Sets vertex color. You may use predefined color as WHITE, GRAY and BLACK.
  136. * Complexity O(1)
  137. *
  138. * @param Vertex
  139. * @param Color
  140. */
  141. DECLSPEC void vertex_set_color(vertex_t vertex, char color);
  142. /*!
  143. * @brief Sets vertex visited status. It's used by DFS/BFS travels and you may use it to implement
  144. * your own algorithms.
  145. * Complexity O(1)
  146. *
  147. * @param Vertex
  148. * @param Visited ( 1 ) or unvisited ( 0 ); actually node state depends on the program logic
  149. */
  150. DECLSPEC void vertex_set_visited(vertex_t vertex, char visited);
  151. /*!
  152. * @brief Sets the parent identifier of this vertex.
  153. * @param Vertex
  154. * @param Parent identifier
  155. */
  156. DECLSPEC void vertex_set_parent_identifier(vertex_t vertex, unsigned int parent_identifier);
  157. /*!
  158. * @brief Sets the time when the vertex was discovered.
  159. * Complexity O(1)
  160. *
  161. * @param Vertex
  162. * @param Time start value
  163. */
  164. DECLSPEC void vertex_set_time_start(vertex_t vertex, unsigned int time_start);
  165. /*!
  166. * @brief Sets the time when the vertex visitation ended.
  167. * Complexity O(1)
  168. *
  169. * @param Vertex
  170. * @param Time stop value
  171. */
  172. DECLSPEC void vertex_set_time_stop(vertex_t vertex, unsigned int time_stop);
  173. /*!
  174. * @brief Debugs vertex's content into stream.
  175. * Complexity O(1)
  176. *
  177. * @param Vertex
  178. * @param Stream, should be FILE *
  179. */
  180. DECLSPEC void vertex_debug(vertex_t vertex, void *stream);
  181. #endif /*VERTEX_H_*/