edge.h 3.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177
  1. /*!
  2. Temelia - graph_t edge interface.
  3. Copyright (C) 2008 Ceata (http://cod.ceata.org/proiecte/temelia).
  4. This program is free software; you can redistribute it and
  5. modify it under the terms of the GNU General Public License
  6. as published by the Free Software Foundation; either version 3
  7. of the License, or (at your option) any later version.
  8. This program is distributed in the hope that it will be useful,
  9. but WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  11. GNU General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with this program; if not, write to the Free Software
  14. Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  15. */
  16. #ifndef EDGE_H_
  17. #define EDGE_H_
  18. #include "platform.h"
  19. #include "graph_constants.h"
  20. #include "vertex.h"
  21. struct _edge_t;
  22. typedef struct _edge_t *edge_t;
  23. /*!
  24. * @brief Returns a new edge between vertices V1 and V2 with given cost and label.
  25. * Complexity O(1)
  26. *
  27. * @param First vertex
  28. * @param Second vertex
  29. * @param Edge cost
  30. * @param Edge label
  31. * @param Key attached to edge
  32. */
  33. DECLSPEC edge_t edge_new(vertex_t vertex1, vertex_t vertex2, double cost, char *label,
  34. void *ket);
  35. /*
  36. * @brief Frees memory occupied by an edge.
  37. * Complexity O(1)
  38. *
  39. * @param Edge
  40. */
  41. DECLSPEC void edge_delete(edge_t edge);
  42. /*!
  43. * @brief Returns first vertex of edge.
  44. * Complexity O(1)
  45. *
  46. * @param Edge
  47. */
  48. DECLSPEC vertex_t edge_get_vertex1(edge_t edge);
  49. /*!
  50. * @brief Returns second vertex of edge.
  51. * Complexity O(1)
  52. *
  53. * @param Edge
  54. */
  55. DECLSPEC vertex_t edge_get_vertex2(edge_t edge);
  56. /*!
  57. * @brief Returns complementary vertex of edge.
  58. * Complexity O(1)
  59. *
  60. * @param Edge
  61. * @param Pointer to vertex.
  62. */
  63. DECLSPEC vertex_t edge_complementary_vertex(edge_t edge, vertex_t vertex);
  64. /*!
  65. * @brief Returns edge cost.
  66. * Complexity O(1)
  67. *
  68. * @param Edge
  69. */
  70. DECLSPEC double edge_get_cost(edge_t edge);
  71. /*!
  72. * @brief Returns edge type.
  73. * Complexity O(1)
  74. *
  75. * @param Edge
  76. */
  77. DECLSPEC char edge_get_type(edge_t edge);
  78. /*!
  79. * @brief Returns edge's key.
  80. * Complexity O(1)
  81. *
  82. * @param Edge
  83. */
  84. DECLSPEC void *edge_get_key(edge_t edge);
  85. /*!
  86. * @brief Returns edge label.
  87. * Complexity O(1)
  88. *
  89. * @param Edge
  90. */
  91. DECLSPEC char *edge_get_label(edge_t edge);
  92. /*!
  93. * @brief Sets first vertex of edge.
  94. * Complexity O(1)
  95. *
  96. * @param Edge
  97. * @param Vertex
  98. */
  99. DECLSPEC void edge_set_vertex1(edge_t edge, vertex_t vertex);
  100. /*!
  101. * @brief Sets second vertex of edge.
  102. * Complexity O(1)
  103. *
  104. * @param Edge
  105. * @param Pointer to vertex
  106. */
  107. DECLSPEC void edge_set_vertex2(edge_t edge, vertex_t vertex);
  108. /*!
  109. * @brief Sets cost of edge.
  110. * Complexity O(1)
  111. *
  112. * @param Edge
  113. * @param New cost
  114. */
  115. DECLSPEC void edge_set_cost(edge_t edge, double cost);
  116. /*!
  117. * @brief Sets edge type.
  118. * Complexity O(1)
  119. *
  120. * @param Edge
  121. * @param New edge type
  122. */
  123. DECLSPEC void edge_set_type(edge_t edge, char type);
  124. /*!
  125. * @brief Sets key stored in edge.
  126. * Complexity O(1)
  127. *
  128. * @param Edge
  129. * @param New key
  130. */
  131. DECLSPEC void edge_set_key(edge_t edge, void *key);
  132. /*!
  133. * @brief Sets label of edge.
  134. * Complexity O(1)
  135. *
  136. * @param Edge
  137. * @param New label
  138. */
  139. DECLSPEC void edge_set_label(edge_t edge, char *label);
  140. /*!
  141. * @brief Debugs edge's content into a stream.
  142. *
  143. * @param Edge
  144. * @param Stream, should be FILE *
  145. */
  146. DECLSPEC void edge_debug(edge_t edge, void *stream);
  147. /*!
  148. * @brief Switches the orientation of edge: vertex1->vertex2
  149. * becomes vertex2->vertex1. It's common utility is in graph transposing.
  150. */
  151. DECLSPEC void edge_switch_vertices(edge_t edge);
  152. #endif /* EDGE_H_ */