adj_list_cc.cpp 11 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242
  1. //=======================================================================
  2. // Copyright 1997, 1998, 1999, 2000 University of Notre Dame.
  3. // Authors: Andrew Lumsdaine, Lie-Quan Lee, Jeremy G. Siek
  4. //
  5. // Distributed under the Boost Software License, Version 1.0. (See
  6. // accompanying file LICENSE_1_0.txt or copy at
  7. // http://www.boost.org/LICENSE_1_0.txt)
  8. //=======================================================================
  9. #include <boost/graph/graph_concepts.hpp>
  10. #include <boost/graph/graph_archetypes.hpp>
  11. #include <boost/graph/adjacency_list.hpp>
  12. #include <boost/concept/assert.hpp>
  13. int main(int,char*[])
  14. {
  15. using namespace boost;
  16. // Check adjacency_list with properties
  17. {
  18. typedef adjacency_list<vecS, vecS, directedS,
  19. property<vertex_color_t, int>,
  20. property<edge_weight_t, int>
  21. > Graph;
  22. typedef graph_traits<Graph>::vertex_descriptor Vertex;
  23. typedef graph_traits<Graph>::edge_descriptor Edge;
  24. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  25. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  26. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  27. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  28. BOOST_CONCEPT_ASSERT(( MutableIncidenceGraphConcept<Graph> ));
  29. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  30. BOOST_CONCEPT_ASSERT(( VertexMutablePropertyGraphConcept<Graph> ));
  31. BOOST_CONCEPT_ASSERT(( EdgeMutablePropertyGraphConcept<Graph> ));
  32. BOOST_CONCEPT_ASSERT((
  33. ReadablePropertyGraphConcept<Graph, Vertex, vertex_index_t> ));
  34. BOOST_CONCEPT_ASSERT((
  35. LvaluePropertyGraphConcept<Graph, Vertex, vertex_color_t> ));
  36. BOOST_CONCEPT_ASSERT((
  37. LvaluePropertyGraphConcept<Graph, Edge, edge_weight_t> ));
  38. }
  39. {
  40. typedef adjacency_list<vecS, vecS, bidirectionalS,
  41. property<vertex_color_t, int>,
  42. property<edge_weight_t, int>
  43. > Graph;
  44. typedef graph_traits<Graph>::vertex_descriptor Vertex;
  45. typedef graph_traits<Graph>::edge_descriptor Edge;
  46. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  47. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  48. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  49. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  50. BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept<Graph> ));
  51. BOOST_CONCEPT_ASSERT(( MutableBidirectionalGraphConcept<Graph> ));
  52. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  53. BOOST_CONCEPT_ASSERT(( VertexMutablePropertyGraphConcept<Graph> ));
  54. BOOST_CONCEPT_ASSERT(( EdgeMutablePropertyGraphConcept<Graph> ));
  55. BOOST_CONCEPT_ASSERT((
  56. ReadablePropertyGraphConcept<Graph, Vertex, vertex_index_t> ));
  57. BOOST_CONCEPT_ASSERT((
  58. LvaluePropertyGraphConcept<Graph, Vertex, vertex_color_t> ));
  59. BOOST_CONCEPT_ASSERT((
  60. LvaluePropertyGraphConcept<Graph, Edge, edge_weight_t> ));
  61. }
  62. {
  63. typedef adjacency_list< listS, listS, directedS,
  64. property<vertex_color_t, int>,
  65. property<edge_weight_t, int>
  66. > Graph;
  67. typedef graph_traits<Graph>::vertex_descriptor Vertex;
  68. typedef graph_traits<Graph>::edge_descriptor Edge;
  69. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  70. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  71. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  72. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  73. BOOST_CONCEPT_ASSERT(( MutableIncidenceGraphConcept<Graph> ));
  74. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  75. BOOST_CONCEPT_ASSERT(( VertexMutablePropertyGraphConcept<Graph> ));
  76. BOOST_CONCEPT_ASSERT(( EdgeMutablePropertyGraphConcept<Graph> ));
  77. BOOST_CONCEPT_ASSERT((
  78. LvaluePropertyGraphConcept<Graph, Vertex, vertex_color_t> ));
  79. BOOST_CONCEPT_ASSERT((
  80. LvaluePropertyGraphConcept<Graph, Edge, edge_weight_t> ));
  81. }
  82. {
  83. typedef adjacency_list< listS, listS, undirectedS,
  84. property<vertex_color_t, int>,
  85. property<edge_weight_t, int>
  86. > Graph;
  87. typedef graph_traits<Graph>::vertex_descriptor Vertex;
  88. typedef graph_traits<Graph>::edge_descriptor Edge;
  89. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  90. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  91. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  92. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  93. BOOST_CONCEPT_ASSERT(( MutableBidirectionalGraphConcept<Graph> ));
  94. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  95. BOOST_CONCEPT_ASSERT(( VertexMutablePropertyGraphConcept<Graph> ));
  96. BOOST_CONCEPT_ASSERT(( EdgeMutablePropertyGraphConcept<Graph> ));
  97. BOOST_CONCEPT_ASSERT((
  98. LvaluePropertyGraphConcept<Graph, Vertex, vertex_color_t> ));
  99. BOOST_CONCEPT_ASSERT((
  100. LvaluePropertyGraphConcept<Graph, Edge, edge_weight_t> ));
  101. }
  102. // Checking adjacency_list with EdgeList=setS
  103. {
  104. typedef adjacency_list<setS, vecS, bidirectionalS,
  105. property<vertex_color_t, int>,
  106. property<edge_weight_t, int>
  107. > Graph;
  108. typedef graph_traits<Graph>::vertex_descriptor Vertex;
  109. typedef graph_traits<Graph>::edge_descriptor Edge;
  110. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  111. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  112. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  113. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  114. BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept<Graph> ));
  115. BOOST_CONCEPT_ASSERT(( MutableBidirectionalGraphConcept<Graph> ));
  116. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  117. BOOST_CONCEPT_ASSERT(( VertexMutablePropertyGraphConcept<Graph> ));
  118. BOOST_CONCEPT_ASSERT(( EdgeMutablePropertyGraphConcept<Graph> ));
  119. BOOST_CONCEPT_ASSERT((
  120. ReadablePropertyGraphConcept<Graph, Vertex, vertex_index_t> ));
  121. BOOST_CONCEPT_ASSERT((
  122. LvaluePropertyGraphConcept<Graph, Vertex, vertex_color_t> ));
  123. BOOST_CONCEPT_ASSERT((
  124. LvaluePropertyGraphConcept<Graph, Edge, edge_weight_t> ));
  125. }
  126. {
  127. typedef adjacency_list< setS, listS, directedS,
  128. property<vertex_color_t, int>,
  129. property<edge_weight_t, int>
  130. > Graph;
  131. typedef graph_traits<Graph>::vertex_descriptor Vertex;
  132. typedef graph_traits<Graph>::edge_descriptor Edge;
  133. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  134. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  135. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  136. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  137. BOOST_CONCEPT_ASSERT(( MutableIncidenceGraphConcept<Graph> ));
  138. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  139. BOOST_CONCEPT_ASSERT(( VertexMutablePropertyGraphConcept<Graph> ));
  140. BOOST_CONCEPT_ASSERT(( EdgeMutablePropertyGraphConcept<Graph> ));
  141. BOOST_CONCEPT_ASSERT((
  142. LvaluePropertyGraphConcept<Graph, Vertex, vertex_color_t> ));
  143. BOOST_CONCEPT_ASSERT((
  144. LvaluePropertyGraphConcept<Graph, Edge, edge_weight_t> ));
  145. }
  146. {
  147. typedef adjacency_list< setS, listS, undirectedS,
  148. property<vertex_color_t, int>,
  149. property<edge_weight_t, int>
  150. > Graph;
  151. typedef graph_traits<Graph>::vertex_descriptor Vertex;
  152. typedef graph_traits<Graph>::edge_descriptor Edge;
  153. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  154. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  155. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  156. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  157. BOOST_CONCEPT_ASSERT(( MutableBidirectionalGraphConcept<Graph> ));
  158. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  159. BOOST_CONCEPT_ASSERT(( VertexMutablePropertyGraphConcept<Graph> ));
  160. BOOST_CONCEPT_ASSERT(( EdgeMutablePropertyGraphConcept<Graph> ));
  161. BOOST_CONCEPT_ASSERT((
  162. LvaluePropertyGraphConcept<Graph, Vertex, vertex_color_t> ));
  163. BOOST_CONCEPT_ASSERT((
  164. LvaluePropertyGraphConcept<Graph, Edge, edge_weight_t> ));
  165. }
  166. // Check adjacency_list without any properties
  167. {
  168. typedef adjacency_list<vecS, vecS, directedS > Graph;
  169. typedef graph_traits<Graph>::vertex_descriptor Vertex;
  170. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  171. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  172. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  173. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  174. BOOST_CONCEPT_ASSERT(( MutableIncidenceGraphConcept<Graph> ));
  175. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  176. BOOST_CONCEPT_ASSERT(( VertexMutablePropertyGraphConcept<Graph> ));
  177. BOOST_CONCEPT_ASSERT(( EdgeMutablePropertyGraphConcept<Graph> ));
  178. BOOST_CONCEPT_ASSERT((
  179. ReadablePropertyGraphConcept<Graph, Vertex, vertex_index_t> ));
  180. }
  181. {
  182. typedef adjacency_list<vecS, vecS, bidirectionalS> Graph;
  183. typedef graph_traits<Graph>::vertex_descriptor Vertex;
  184. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  185. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  186. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  187. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  188. BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept<Graph> ));
  189. BOOST_CONCEPT_ASSERT(( MutableBidirectionalGraphConcept<Graph> ));
  190. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  191. BOOST_CONCEPT_ASSERT((
  192. ReadablePropertyGraphConcept<Graph, Vertex, vertex_index_t> ));
  193. }
  194. {
  195. typedef adjacency_list< listS, listS, directedS> Graph;
  196. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  197. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  198. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  199. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  200. BOOST_CONCEPT_ASSERT(( MutableIncidenceGraphConcept<Graph> ));
  201. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  202. }
  203. {
  204. typedef adjacency_list< listS, listS, undirectedS> Graph;
  205. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  206. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  207. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  208. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  209. BOOST_CONCEPT_ASSERT(( MutableBidirectionalGraphConcept<Graph> ));
  210. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  211. }
  212. // Checking EdgeList=setS with no properties
  213. {
  214. typedef adjacency_list<setS, vecS, bidirectionalS> Graph;
  215. typedef graph_traits<Graph>::vertex_descriptor Vertex;
  216. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  217. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  218. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  219. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  220. BOOST_CONCEPT_ASSERT(( BidirectionalGraphConcept<Graph> ));
  221. BOOST_CONCEPT_ASSERT(( MutableBidirectionalGraphConcept<Graph> ));
  222. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  223. BOOST_CONCEPT_ASSERT(( ReadablePropertyGraphConcept<Graph,
  224. Vertex, vertex_index_t> ));
  225. }
  226. {
  227. typedef adjacency_list< setS, listS, directedS> Graph;
  228. BOOST_CONCEPT_ASSERT(( MutableIncidenceGraphConcept<Graph> ));
  229. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  230. }
  231. {
  232. typedef adjacency_list< setS, listS, undirectedS> Graph;
  233. BOOST_CONCEPT_ASSERT(( VertexListGraphConcept<Graph> ));
  234. BOOST_CONCEPT_ASSERT(( EdgeListGraphConcept<Graph> ));
  235. BOOST_CONCEPT_ASSERT(( IncidenceGraphConcept<Graph> ));
  236. BOOST_CONCEPT_ASSERT(( AdjacencyGraphConcept<Graph> ));
  237. BOOST_CONCEPT_ASSERT(( MutableBidirectionalGraphConcept<Graph> ));
  238. BOOST_CONCEPT_ASSERT(( MutableEdgeListGraphConcept<Graph> ));
  239. }
  240. return 0;
  241. }