adjacency_list.html 38 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148
  1. <HTML>
  2. <!--
  3. Copyright (c) Jeremy Siek 2000
  4. Distributed under the Boost Software License, Version 1.0.
  5. (See accompanying file LICENSE_1_0.txt or copy at
  6. http://www.boost.org/LICENSE_1_0.txt)
  7. -->
  8. <Head>
  9. <Title>Boost Graph Library: Adjacency List</Title>
  10. <BODY BGCOLOR="#ffffff" LINK="#0000ee" TEXT="#000000" VLINK="#551a8b"
  11. ALINK="#ff0000">
  12. <IMG SRC="../../../boost.png"
  13. ALT="C++ Boost" width="277" height="86">
  14. <BR Clear>
  15. <H1><A NAME="sec:adjacency-list-class"></A>
  16. <pre>
  17. adjacency_list&lt;OutEdgeList, VertexList, Directed,
  18. VertexProperties, EdgeProperties,
  19. GraphProperties, EdgeList&gt;
  20. </pre>
  21. </H1>
  22. <P>
  23. The <TT>adjacency_list</TT> class implements a generalized adjacency
  24. list graph structure. The template parameters provide many
  25. configuration options so that you can pick a version of the class that
  26. best meets your needs. An <a
  27. href="graph_theory_review.html#sec:adjacency-list-representation">adjacency-list</a>
  28. is basically a two-dimensional structure, where each element of the
  29. first dimension represents a vertex, and each of the vertices contains
  30. a one-dimensional structure that is its edge list. <a
  31. href="#fig:adj-list-graph">Figure 1</a> shows an adjacency list
  32. representation of a directed graph.
  33. <P></P>
  34. <DIV ALIGN="center"><A NAME="fig:adj-list-graph"></A>
  35. <TABLE>
  36. <CAPTION ALIGN="BOTTOM"><STRONG>Figure 1:</STRONG> Adjacency List Representation of a Directed Graph.</CAPTION>
  37. <TR><TD><IMG SRC="./figs/adj-matrix-graph2.gif" width="386" height="284"></TD>
  38. <TD><IMG SRC="./figs/adj-list2.gif" width="62" height="122"></TD></TR>
  39. </TABLE>
  40. </DIV><P></P>
  41. The
  42. <TT>VertexList</TT> template parameter of the <TT>adjacency_list</TT>
  43. class controls what kind of container is used to represent the outer
  44. two-dimensional container. The <TT>OutEdgeList</TT> template parameter
  45. controls what kind of container is used to represent the edge
  46. lists. The choices for <TT>OutEdgeList</TT> and <TT>VertexList</TT> will
  47. determine the space complexity of the graph structure, and will
  48. determine the time complexity of the various graph operations. The
  49. possible choices and tradeoffs are discussed in Section <A
  50. HREF="./using_adjacency_list.html#sec:choosing-graph-type">Choosing
  51. the <TT>Edgelist</TT> and <TT>VertexList</TT></A>.
  52. <P>
  53. The <TT>Directed</TT> template parameter controls whether the graph is
  54. directed, undirected, or directed with access to both the in-edges and
  55. out-edges (which we call bidirectional). The bidirectional graph takes
  56. up twice the space (per edge) of a directed graph since each edge will
  57. appear in both an out-edge and in-edge list. <a
  58. href="#fig:undir-adj-list-graph">Figure 2</a> shows an adjacency list
  59. representation of an undirected graph.
  60. <P></P>
  61. <DIV ALIGN="center"><A NAME="fig:undir-adj-list-graph"></A>
  62. <TABLE>
  63. <CAPTION ALIGN="BOTTOM"><STRONG>Figure 2:</STRONG> Adjacency List Representation of an Undirected Graph.</CAPTION>
  64. <TR><TD><IMG SRC="./figs/undir-adj-matrix-graph2.gif" width="260" height="240"></TD>
  65. <TD><IMG SRC="./figs/undir-adj-list.gif" width="62" height="122"></TD></TR>
  66. </TABLE>
  67. </DIV><P></P>
  68. <P>
  69. A tutorial on how to use the <TT>adjacency_list</TT> class is in
  70. Section <A HREF="./using_adjacency_list.html">Using
  71. <TT>adjacency_list</TT></A>.
  72. <P>
  73. <H3>Example</H3>
  74. <P>
  75. The example in <a
  76. href="../example/family-tree-eg.cpp"><tt>examples/family-tree-eg.cpp</tt></a>
  77. shows how to represent a family tree with a graph.
  78. <H3>Template Parameters</H3>
  79. <P>
  80. <TABLE border>
  81. <TR>
  82. <th>Parameter</th><th>Description</th><th>Default</th>
  83. </tr>
  84. <TR><TD><TT>OutEdgeList</TT></TD>
  85. <TD>The selector for the container used to represent the
  86. edge-list for each of the vertices.</TD>
  87. <TD><TT>vecS</TT></TD>
  88. </TR>
  89. <TR>
  90. <TD><TT>VertexList</TT></TD>
  91. <TD>The selector for the container used to represent the
  92. vertex-list of the graph.</TD>
  93. <TD><TT>vecS</TT></TD>
  94. </TR>
  95. <TR>
  96. <TD><TT>Directed</TT></TD>
  97. <TD>A selector to choose whether the graph is directed, undirected, or directed with bidirectional edge access (access to both out-edges and in-edges). The options are <TT>directedS</TT>, <TT>undirectedS</TT>, and <TT>bidirectionalS</TT>.</TD>
  98. <TD><TT>directedS</TT></TD>
  99. </TR>
  100. <TR>
  101. <TD><TT>VertexProperties</TT></TD>
  102. <TD>for specifying internal property storage.</TD>
  103. <TD><TT>no_property</TT></TD>
  104. </TR>
  105. <TR>
  106. <TD><TT>EdgeProperties</TT></TD>
  107. <TD>for specifying internal property storage.</TD>
  108. <TD><TT>no_property</TT></TD>
  109. </TR>
  110. <TR>
  111. <TD><TT>GraphProperties</TT></TD>
  112. <TD>for specifying property storage for the graph object.</TD>
  113. <TD><TT>no_property</TT></TD>
  114. </TR>
  115. <TR><TD><TT>EdgeList</TT></TD>
  116. <TD>The selector for the container used to represent the
  117. edge-list for the graph.</TD>
  118. <TD><TT>listS</TT></TD>
  119. </TR>
  120. </TABLE>
  121. <P>
  122. <H3>Model of</H3>
  123. <P>
  124. <a href="./VertexAndEdgeListGraph.html">VertexAndEdgeListGraph</a>,
  125. <a href="./MutablePropertyGraph.html">MutablePropertyGraph</a>,
  126. <a href="../../utility/CopyConstructible.html">CopyConstructible</a>,
  127. <a href="../../utility/Assignable.html">Assignable</a>,
  128. and <a href="../../serialization/doc/index.html">Serializable</a>.
  129. <P>
  130. <H3>Where Defined</H3>
  131. <P>
  132. <a href="../../../boost/graph/adjacency_list.hpp"><TT>boost/graph/adjacency_list.hpp</TT></a><br><br>
  133. Also, the serialization functionality is in
  134. <a href="../../../boost/graph/adj_list_serialize.hpp"><tt>boost/graph/adj_list_serialize.hpp</tt></a>.
  135. <P>
  136. <H2>Vertex and Edge Properties</H2>
  137. <P>
  138. Properties such as color, distance, weight, and user-defined
  139. properties can be attached to the vertices and edges of the graph
  140. using properties. The property values can be read from and written to
  141. via the property maps provided by the graph. The property maps are
  142. obtained via the <TT>get(property, g)</TT> function. How to use
  143. properties is described in Section <A
  144. HREF="./using_adjacency_list.html#sec:adjacency-list-properties">Internal
  145. Properties </A>. The property maps are objects that implement the
  146. interface defined in Section <A
  147. HREF="../../property_map/doc/property_map.html">Property Map
  148. Concepts</A> or may be <a href="bundles.html">bundled properties</a>,
  149. which have a more succinct syntax. The types of all property values
  150. must be Copy Constructible, Assignable, and Default Constructible.
  151. The property maps obtained from the
  152. <TT>adjacency_list</TT> class are models of the <a
  153. href="../../property_map/doc/LvaluePropertyMap.html">Lvalue Property
  154. Map</a> concept. If the <TT>adjacency_list</TT> is const,
  155. then the property map is constant, otherwise the property
  156. map is mutable.
  157. <P>
  158. If the <TT>VertexList</TT> of the graph is <TT>vecS</TT>, then the
  159. graph has a builtin vertex indices accessed via the property map for
  160. the <TT>vertex_index_t</TT> property. The indices fall in the range
  161. <TT>[0, num_vertices(g))</TT> and are contiguous. When a vertex is
  162. removed the indices are adjusted so that they retain these
  163. properties. Some care must be taken when using these indices to access
  164. exterior property storage. The property map for vertex index is a
  165. model of <a href="../../property_map/doc/ReadablePropertyMap.html">Readable
  166. Property Map</a>.
  167. <P>
  168. <h2>Iterator and Descriptor Stability/Invalidation</h2>
  169. Some care must be taken when changing the structure of a graph (via
  170. adding or removing edges). Depending on the type of
  171. <tt>adjacency_list</tt> and on the operation, some of the iterator or
  172. descriptor objects that point into the graph may become invalid. For
  173. example, the following code will result in undefined (bad) behavior:
  174. <pre>
  175. typedef adjacency_list&lt;listS, vecS&gt; Graph; <b>// VertexList=vecS</b>
  176. Graph G(N);
  177. <b>// Fill in the graph...</b>
  178. <b>// Attempt to remove all the vertices. Wrong!</b>
  179. graph_traits&lt;Graph&gt;::vertex_iterator vi, vi_end;
  180. for (boost::tie(vi, vi_end) = vertices(G); vi != vi_end; ++vi)
  181. remove_vertex(*vi, G);
  182. <b>// Remove all the vertices. This is still wrong!</b>
  183. graph_traits&lt;Graph&gt;::vertex_iterator vi, vi_end, next;
  184. boost::tie(vi, vi_end) = vertices(G);
  185. for (next = vi; vi != vi_end; vi = next) {
  186. ++next;
  187. remove_vertex(*vi, G);
  188. }
  189. </pre>
  190. The reason this is a problem is that we are invoking
  191. <tt>remove_vertex()</tt>, which when used with an
  192. <tt>adjacency_list</tt> where <tt>VertexList=vecS</tt>, invalidates
  193. all iterators and descriptors for the graph (such as <tt>vi</tt> and
  194. <tt>vi_end</tt>), thereby causing trouble in subsequent iterations of
  195. the loop.
  196. <p>
  197. If we use a different kind of <tt>adjacency_list</tt>, where
  198. <tt>VertexList=listS</tt>, then the iterators are not invalidated by
  199. calling <tt>remove_vertex</tt> unless the iterator is pointing to the
  200. actual vertex that was removed. The following code demonstrates this.
  201. <pre>
  202. typedef adjacency_list&lt;listS, listS&gt; Graph; <b>// VertexList=listS</b>
  203. Graph G(N);
  204. <b>// Fill in the graph...</b>
  205. <b>// Attempt to remove all the vertices. Wrong!</b>
  206. graph_traits&lt;Graph&gt;::vertex_iterator vi, vi_end;
  207. for (boost::tie(vi, vi_end) = vertices(G); vi != vi_end; ++vi)
  208. remove_vertex(*vi, G);
  209. <b>// Remove all the vertices. This is OK.</b>
  210. graph_traits&lt;Graph&gt;::vertex_iterator vi, vi_end, next;
  211. boost::tie(vi, vi_end) = vertices(G);
  212. for (next = vi; vi != vi_end; vi = next) {
  213. ++next;
  214. remove_vertex(*vi, G);
  215. }
  216. </pre>
  217. <p>
  218. The stability issue also affects vertex and edge descriptors. For
  219. example, suppose you use vector of vertex descriptors to keep track of
  220. the parents (or predecessors) of vertices in a shortest paths tree
  221. (see <a
  222. href="../example/dijkstra-example.cpp"><tt>examples/dijkstra-example.cpp</tt></a>).
  223. You create the parent vector with a call to
  224. <tt>dijkstra_shortest_paths()</tt>, and then remove a vertex from the
  225. graph. Subsequently you try to use the parent vector, but since all
  226. vertex descriptors have become invalid, the result is incorrect.
  227. <pre>
  228. std::vector&lt;Vertex&gt; parent(num_vertices(G));
  229. std::vector&lt;Vertex&gt; distance(num_vertices(G));
  230. dijkstra_shortest_paths(G, s, distance_map(&amp;distance[0]).
  231. predecessor_map(&amp;parent[0]));
  232. remove_vertex(s, G); <b>// Bad idea! Invalidates vertex descriptors in parent vector.</b>
  233. <b>// The following will produce incorrect results</b>
  234. for(boost::tie(vi, vend) = vertices(G); vi != vend; ++vi)
  235. std::cout << p[*vi] << " is the parent of " << *vi << std::endl;
  236. </pre>
  237. <p>
  238. Note that in this discussion iterator and descriptor invalidation is
  239. concerned with the invalidation of iterators and descriptors that are
  240. <b>not directly affected</b> by the operation. For example, performing
  241. <tt>remove_edge(u, v, g)</tt> will always invalidate any edge
  242. descriptor for <i>(u,v)</i> or edge iterator pointing to <i>(u,v)</i>,
  243. regardless of the kind <tt>adjacency_list</tt>. In this discussion
  244. of iterator and descriptor invalidation, we are only concerned with the
  245. affect of <tt>remove_edge(u, v, g)</tt> on edge descriptors and
  246. iterators that point to other edges (not <i>(u,v)</i>).
  247. <p>
  248. In general, if you want your vertex and edge descriptors to be stable
  249. (never invalidated) then use <tt>listS</tt> or <tt>setS</tt> for the
  250. <tt>VertexList</tt> and <tt>OutEdgeList</tt> template parameters of
  251. <tt>adjacency_list</tt>. If you are not as concerned about descriptor
  252. and iterator stability, and are more concerned about memory
  253. consumption and graph traversal speed, use <tt>vecS</tt> for the
  254. <tt>VertexList</tt> and/or <tt>OutEdgeList</tt> template parameters.
  255. <p>
  256. The following table summarizes which operations cause descriptors and
  257. iterators to become invalid. In the table, <tt>EL</tt> is an
  258. abbreviation for <tt>OutEdgeList</tt> and <tt>VL</tt> means
  259. <tt>VertexList</tt>. The <b>Adj Iter</b> category includes the
  260. <tt>out_edge_iterator</tt>, <tt>in_edge_iterator</tt>, and
  261. <tt>adjacency_iterator</tt> types. A more detailed description of
  262. descriptor and iterator invalidation is given in the documentation for
  263. each operation.
  264. <p>
  265. <table border>
  266. <CAPTION ALIGN="BOTTOM"><STRONG>Table:</STRONG>
  267. Summary of Descriptor and Iterator Invalidation.
  268. </CAPTION>
  269. <tr>
  270. <th>Function</th>
  271. <th>Vertex Desc</th>
  272. <th>Edge Desc</th>
  273. <th>Vertex Iter</th>
  274. <th>Edge Iter</th>
  275. <th>Adj Iter</th>
  276. </tr>
  277. <tr>
  278. <td>
  279. <tt>add_edge()</tt></td>
  280. <td align=center><tt>OK</tt></td>
  281. <td align=center><tt>OK</tt></td>
  282. <td align=center><tt>OK</tt></td>
  283. <td align=center><tt>EL=vecS &amp;&amp; <br>Directed=directedS</tt></td>
  284. <td align=center><tt>EL=vecS</tt></td>
  285. </tr>
  286. <tr>
  287. <td><tt>remove_edge()<br>remove_edge_if()<br>remove_out_edge_if()<br>
  288. remove_in_edge_if()<br>clear_vertex()</tt>
  289. </td>
  290. <td align=center><tt>OK</tt></td>
  291. <td align=center><tt>OK</tt></td>
  292. <td align=center><tt>OK</tt></td>
  293. <td align=center><tt>EL=vecS &amp;&amp; <br>Directed=directedS</tt></td>
  294. <td align=center><tt>EL=vecS</tt></td>
  295. </tr>
  296. <tr>
  297. <td><tt>add_vertex()</tt></td>
  298. <td align=center><tt>OK</tt></td>
  299. <td align=center><tt>OK</tt></td>
  300. <td align=center><tt>OK</tt></td>
  301. <td align=center><tt>VL=vecS &amp;&amp; <br/> Directed=directedS</tt></td>
  302. <td align=center><tt>VL=vecS &amp;&amp; <br/> Directed=directedS</tt></td>
  303. </tr>
  304. <tr>
  305. <td><tt>remove_vertex()</tt></td>
  306. <td align=center><tt>VL=vecS</tt></td>
  307. <td align=center><tt>VL=vecS</tt></td>
  308. <td align=center><tt>VL=vecS</tt></td>
  309. <td align=center><tt>VL=vecS</tt></td>
  310. <td align=center><tt>VL=vecS</tt></td>
  311. </tr>
  312. </table>
  313. <H2>Associated Types</H2>
  314. <hr>
  315. <tt>graph_traits&lt;adjacency_list&gt;::vertex_descriptor</tt>
  316. <br>
  317. and
  318. <br>
  319. <tt>adjacency_list_traits&lt;OutEdgeList, VertexList, Directed, EdgeList&gt;::vertex_descriptor</tt>
  320. <br><br>
  321. The type for the vertex descriptors associated with the
  322. <TT>adjacency_list</TT>.
  323. <hr>
  324. <tt>graph_traits&lt;adjacency_list&gt;::edge_descriptor</tt><br>
  325. and<br>
  326. <tt>adjacency_list_traits&lt;OutEdgeList, VertexList, Directed, EdgeList&gt;::edge_descriptor</tt>
  327. <br><br>
  328. The type for the edge descriptors associated with the
  329. <TT>adjacency_list</TT>.
  330. <hr>
  331. <tt>graph_traits&lt;adjacency_list&gt;::vertex_iterator</tt>
  332. <br><br>
  333. The type for the iterators returned by <TT>vertices()</TT>.
  334. When <tt>VertexList=vecS</tt> then the <tt>vertex_iterator</tt> models
  335. <a
  336. href="http://www.boost.org/sgi/stl/RandomAccessIterator.html">RandomAccessIterator</a>. Otherwise
  337. the <tt>vertex_iterator</tt> models <a
  338. href="http://www.boost.org/sgi/stl/BidirectionalIterator.html">BidirectionalIterator</a>.
  339. <hr>
  340. <tt>graph_traits&lt;adjacency_list&gt;::edge_iterator</tt>
  341. <br><br>
  342. The type for the iterators returned by <TT>edges()</TT>.
  343. The <tt>edge_iterator</tt> models <a
  344. href="http://www.boost.org/sgi/stl/BidirectionalIterator.html">BidirectionalIterator</a>.
  345. <hr>
  346. <tt>graph_traits&lt;adjacency_list&gt;::out_edge_iterator</tt>
  347. <br><br>
  348. The type for the iterators returned by <TT>out_edges()</TT>.
  349. When <tt>OutEdgeList=vecS</tt> then the <tt>out_edge_iterator</tt> models
  350. <a href="http://www.boost.org/sgi/stl/RandomAccessIterator.html">
  351. RandomAccessIterator</a>. When <tt>OutEdgeList=slistS</tt> then the
  352. <tt>out_edge_iterator</tt> models <a
  353. href="http://www.boost.org/sgi/stl/ForwardIterator.html">
  354. ForwardIterator</a>. Otherwise the <tt>out_edge_iterator</tt> models
  355. <a
  356. href="http://www.boost.org/sgi/stl/BidirectionalIterator.html">
  357. BidirectionalIterator</a>.
  358. <hr>
  359. <tt>graph_traits&lt;adjacency_list&gt;::adjacency_iterator</tt>
  360. <br><br>
  361. The type for the iterators returned by <TT>adjacent_vertices()</TT>.
  362. The <tt>adjacency_iterator</tt> models the same iterator concept
  363. as <tt>out_edge_iterator</tt>.
  364. <hr>
  365. <tt>adjacency_list::inv_adjacency_iterator</tt>
  366. <br><br>
  367. The type for the iterators returned by <TT>inv_adjacent_vertices()</TT>.
  368. The <tt>inv_adjacency_iterator</tt> models the same iterator concept
  369. as <tt>out_edge_iterator</tt>.
  370. <hr>
  371. <tt>graph_traits&lt;adjacency_list&gt;::directed_category</tt><br>
  372. and<br>
  373. <tt>adjacency_list_traits&lt;OutEdgeList, VertexList, Directed, EdgeList&gt;::directed_category</tt>
  374. <br><br>
  375. Provides information about whether the graph is
  376. directed (<TT>directed_tag</TT>) or undirected
  377. (<TT>undirected_tag</TT>).
  378. <hr>
  379. <tt>graph_traits&lt;adjacency_list&gt;::edge_parallel_category</tt><br>
  380. and<br>
  381. <tt>adjacency_list_traits&lt;OutEdgeList, VertexList, Directed, EdgeList&gt;::edge_parallel_category</tt>
  382. <br><br>
  383. This describes whether the graph class allows the insertion of
  384. parallel edges (edges with the same source and target). The two tags
  385. are <TT>allow_parallel_edge_tag</TT> and
  386. <TT>disallow_parallel_edge_tag</TT>. The
  387. <TT>setS</TT> and <TT>hash_setS</TT> variants disallow
  388. parallel edges while the others allow parallel edges.
  389. <hr>
  390. <tt>graph_traits&lt;adjacency_list&gt;::vertices_size_type</tt><br>
  391. and<br>
  392. <tt>adjacency_list_traits&lt;OutEdgeList, VertexList, Directed_list, EdgeList&gt;::vertices_size_type</tt><br>
  393. <br><br>
  394. The type used for dealing with the number of vertices in the graph.
  395. <hr>
  396. <tt>graph_traits&lt;adjacency_list&gt;::edges_size_type</tt><br>
  397. and<br>
  398. <tt>adjacency_list_traits&lt;OutEdgeList, VertexList, Directed_list, EdgeList&gt;::edges_size_type</tt><br>
  399. <br><br>
  400. The type used for dealing with the number of edges in the graph.
  401. <hr>
  402. <tt>graph_traits&lt;adjacency_list&gt;::degree_size_type</tt>
  403. <br><br>
  404. The type used for dealing with the number of edges incident to a vertex
  405. in the graph.
  406. <hr>
  407. <tt>property_map&lt;adjacency_list, Property&gt;::type</tt><br>
  408. and<br>
  409. <tt>property_map&lt;adjacency_list, Property&gt;::const_type</tt>
  410. <br><br>
  411. The property map type for vertex or edge properties in the graph. The
  412. specific property is specified by the <TT>Property</TT> template argument,
  413. and must match one of the properties specified in the
  414. <TT>VertexProperties</TT> or <TT>EdgeProperties</TT> for the graph.
  415. <hr>
  416. <tt>graph_property&lt;adjacency_list, Property&gt;::type</tt>
  417. <br><br>
  418. The property value type for the graph property specified by the
  419. <tt>Property</tt> tag.
  420. <hr>
  421. <tt>adjacency_list::out_edge_list_selector</tt>
  422. <br><br>
  423. The type <tt>OutEdgeListS</tt>.
  424. <hr>
  425. <tt>adjacency_list::vertex_list_selector</tt>
  426. <br><br>
  427. The type <tt>VertexListS</tt>.
  428. <hr>
  429. <tt>adjacency_list::directed_selector</tt>
  430. <br><br>
  431. The type <tt>DirectedS</tt>.
  432. <hr>
  433. <tt>adjacency_list::edge_list_selector</tt>
  434. <br><br>
  435. The type <tt>EdgeListS</tt>.
  436. <hr>
  437. <H2>Member Functions</H2>
  438. <hr>
  439. <pre>
  440. adjacency_list(const&nbsp;GraphProperty&amp;&nbsp;p = GraphProperty())
  441. </pre>
  442. Default constructor. Creates an empty graph object with zero vertices
  443. and zero edges.
  444. <hr>
  445. <pre>
  446. adjacency_list(const&nbsp;adjacency_list&amp;&nbsp;x)
  447. </pre>
  448. Copy constructor. Creates a new graph that is a copy of graph
  449. <tt>x</tt>, including the edges, vertices, and properties.
  450. <hr>
  451. <pre>
  452. adjacency_list&amp; operator=(const&nbsp;adjacency_list&amp;&nbsp;x)
  453. </pre>
  454. Assignment operator. Makes this graph a copy of graph
  455. <tt>x</tt>, including the edges, vertices, and properties.
  456. <hr>
  457. <pre>
  458. adjacency_list(vertices_size_type&nbsp;n,
  459. const&nbsp;GraphProperty&amp;&nbsp;p = GraphProperty())
  460. </pre>
  461. Creates a graph object with <TT>n</TT> vertices and zero edges.
  462. <hr>
  463. <a name="sec:iterator-constructor">
  464. <pre>
  465. template &lt;class&nbsp;EdgeIterator&gt;
  466. adjacency_list(EdgeIterator&nbsp;first, EdgeIterator&nbsp;last,
  467. vertices_size_type&nbsp;n,
  468. edges_size_type&nbsp;m = 0,
  469. const&nbsp;GraphProperty&amp;&nbsp;p&nbsp;=&nbsp;GraphProperty())
  470. </pre>
  471. Creates a graph object with <TT>n</TT> vertices and with the edges
  472. specified in the edge list given by the range <TT>[first, last)</TT>.
  473. The <tt>EdgeIterator</tt> must be a model of <a
  474. href="http://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>.
  475. The value type of the <TT>EdgeIterator</TT> must be a
  476. <TT>std::pair</TT>, where the type in the pair is an integer type. The
  477. integers will correspond to vertices, and they must all fall in the
  478. range of <TT>[0, n)</TT>.
  479. </a>
  480. <hr>
  481. <pre>
  482. template &lt;class&nbsp;EdgeIterator, class&nbsp;EdgePropertyIterator&gt;
  483. adjacency_list(EdgeIterator&nbsp;first, EdgeIterator&nbsp;last,
  484. EdgePropertyIterator&nbsp;ep_iter,
  485. vertices_size_type&nbsp;n,
  486. edges_size_type&nbsp;m = 0,
  487. const&nbsp;GraphProperty&amp;&nbsp;p&nbsp;=&nbsp;GraphProperty())
  488. </pre>
  489. Creates a graph object with <TT>n</TT> vertices and with the edges
  490. specified in the edge list given by the range <TT>[first, last)</TT>.
  491. The <tt>EdgeIterator</tt> and <tt>EdgePropertyIterator</tt> must be a
  492. model of <a
  493. href="http://www.boost.org/sgi/stl/InputIterator.html">InputIterator</a>.
  494. The value type of the <TT>EdgeIterator</TT> must be a
  495. <TT>std::pair</TT>, where the type in the pair is an integer type. The
  496. integers will correspond to vertices, and they must all fall in the
  497. range of <TT>[0, n)</TT>. The <TT>value_type</TT> of the
  498. <TT>ep_iter</TT> should be <TT>EdgeProperties</TT>.
  499. <hr>
  500. <pre>
  501. void clear()
  502. </pre>
  503. Remove all of the edges and vertices from the graph.
  504. <hr>
  505. <pre>
  506. void swap(adjacency_list&amp; x)
  507. </pre>
  508. Swap the vertices, edges, and properties of this graph with the
  509. vertices, edges, and properties of graph <tt>x</tt>.
  510. <hr>
  511. <P>
  512. <H2>Non-Member Functions</H2>
  513. <h4>Structure Access</h4>
  514. <hr>
  515. <pre>
  516. std::pair&lt;vertex_iterator,&nbsp;vertex_iterator&gt;
  517. vertices(const adjacency_list&amp; g)
  518. </pre>
  519. Returns an iterator-range providing access to the vertex set of graph
  520. <tt>g</tt>.
  521. <hr>
  522. <pre>
  523. std::pair&lt;edge_iterator,&nbsp;edge_iterator&gt;
  524. edges(const adjacency_list&amp; g)
  525. </pre>
  526. Returns an iterator-range providing access to the edge set of graph
  527. <tt>g</tt>.
  528. <hr>
  529. <pre>
  530. std::pair&lt;adjacency_iterator,&nbsp;adjacency_iterator&gt;
  531. adjacent_vertices(vertex_descriptor&nbsp;u, const&nbsp;adjacency_list&amp;&nbsp;g)
  532. </pre>
  533. Returns an iterator-range providing access to the vertices adjacent to
  534. vertex <tt>u</tt> in graph <tt>g</tt>. For example, if <tt>u -> v</tt>
  535. is an edge in the graph, then <tt>v</tt> will be in this iterator-range.
  536. <hr>
  537. <pre>
  538. std::pair&lt;inv_adjacency_iterator,&nbsp;inv_adjacency_iterator&gt;
  539. inv_adjacent_vertices(vertex_descriptor&nbsp;u, const&nbsp;adjacency_list&amp;&nbsp;g)
  540. </pre>
  541. Returns an iterator-range providing access to the vertices in graph
  542. <tt>g</tt> to which <tt>u</tt> is adjacent. (<tt>inv</tt> is for
  543. inverse.) For example, if <tt>v -> u</tt> is an edge in the graph,
  544. then <tt>v</tt> will be in this iterator range. This function is only
  545. available for bidirectional and undirected <tt>adjacency_list</tt>'s.
  546. <hr>
  547. <pre>
  548. std::pair&lt;out_edge_iterator,&nbsp;out_edge_iterator&gt;
  549. out_edges(vertex_descriptor&nbsp;u, const&nbsp;adjacency_list&amp;&nbsp;g)
  550. </pre>
  551. Returns an iterator-range providing access to the out-edges of vertex
  552. <tt>u</tt> in graph <tt>g</tt>. If the graph is undirected, this
  553. iterator-range provides access to all edges incident on vertex
  554. <tt>u</tt>. For both directed and undirected graphs, for an out-edge
  555. <tt>e</tt>, <tt>source(e, g) == u</tt> and <tt>target(e, g) == v</tt>
  556. where <tt>v</tt> is a vertex adjacent to <tt>u</tt>.
  557. <hr>
  558. <pre>
  559. std::pair&lt;in_edge_iterator,&nbsp;in_edge_iterator&gt;
  560. in_edges(vertex_descriptor&nbsp;v, const&nbsp;adjacency_list&amp;&nbsp;g)
  561. </pre>
  562. Returns an iterator-range providing access to the in-edges of vertex
  563. <tt>v</tt> in graph <tt>g</tt>. This operation is only available if
  564. <TT>bidirectionalS</TT> was specified for the <TT>Directed</TT>
  565. template parameter. For an in-edge <tt>e</tt>, <tt>target(e, g) == v</tt>
  566. and <tt>source(e, g) == u</tt> for some vertex <tt>u</tt> that is
  567. adjacent to <tt>v</tt>, whether the graph is directed or undirected.
  568. <hr>
  569. <pre>
  570. vertex_descriptor
  571. source(edge_descriptor&nbsp;e, const&nbsp;adjacency_list&amp;&nbsp;g)
  572. </pre>
  573. Returns the source vertex of edge <tt>e</tt>.
  574. <hr>
  575. <pre>
  576. vertex_descriptor
  577. target(edge_descriptor&nbsp;e, const&nbsp;adjacency_list&amp;&nbsp;g)
  578. </pre>
  579. Returns the target vertex of edge <tt>e</tt>.
  580. <hr>
  581. <pre>
  582. degree_size_type
  583. out_degree(vertex_descriptor&nbsp;u, const&nbsp;adjacency_list&amp;&nbsp;g)
  584. </pre>
  585. Returns the number of edges leaving vertex <tt>u</tt>.
  586. <hr>
  587. <pre>
  588. degree_size_type
  589. in_degree(vertex_descriptor&nbsp;u, const&nbsp;adjacency_list&amp;&nbsp;g)
  590. </pre>
  591. Returns the number of edges entering vertex <tt>u</tt>. This operation
  592. is only available if <TT>bidirectionalS</TT> was specified for
  593. the <TT>Directed</TT> template parameter.
  594. <hr>
  595. <pre>
  596. vertices_size_type
  597. num_vertices(const adjacency_list&amp; g)
  598. </pre>
  599. Returns the number of vertices in the graph <tt>g</tt>.
  600. <hr>
  601. <pre>
  602. edges_size_type
  603. num_edges(const adjacency_list&amp; g)
  604. </pre>
  605. Returns the number of edges in the graph <tt>g</tt>.
  606. <hr>
  607. <pre>
  608. vertex_descriptor
  609. vertex(vertices_size_type&nbsp;n, const&nbsp;adjacency_list&amp;&nbsp;g)
  610. </pre>
  611. Returns the nth vertex in the graph's vertex list.
  612. <hr>
  613. <pre>
  614. std::pair&lt;edge_descriptor, bool&gt;
  615. edge(vertex_descriptor&nbsp;u, vertex_descriptor&nbsp;v,
  616. const&nbsp;adjacency_list&amp;&nbsp;g)
  617. </pre>
  618. If an edge from vertex <tt>u</tt> to vertex <tt>v</tt> exists, return a pair
  619. containing one such edge and <tt>true</tt>. If there are no edges between
  620. <tt>u</tt> and <tt>v</tt>, return a pair with an arbitrary edge descriptor and
  621. <tt>false</tt>.
  622. <hr>
  623. <pre>
  624. std::pair&lt;out_edge_iterator, out_edge_iterator&gt;
  625. edge_range(vertex_descriptor&nbsp;u, vertex_descriptor&nbsp;v,
  626. const&nbsp;adjacency_list&amp;&nbsp;g)
  627. </pre>
  628. Returns a pair of out-edge iterators that give the range for
  629. all the parallel edges from <tt>u</tt> to <tt>v</tt>. This
  630. function only works when the <tt>OutEdgeList</tt> for the
  631. <tt>adjacency_list</tt> is a container that sorts the
  632. out edges according to target vertex, and allows for
  633. parallel edges. The <tt>multisetS</tt> selector chooses
  634. such a container.
  635. <hr>
  636. <h4>Structure Modification</h4>
  637. <hr>
  638. <pre>
  639. std::pair&lt;edge_descriptor, bool&gt;
  640. add_edge(vertex_descriptor&nbsp;u, vertex_descriptor&nbsp;v,
  641. adjacency_list&amp; g)
  642. </pre>
  643. Adds edge <i>(u,v)</i> to the graph and returns the edge descriptor
  644. for the new edge. For graphs that do not allow parallel edges, if the
  645. edge is already in the graph then a duplicate will not be added and
  646. the <TT>bool</TT> flag will be <TT>false</TT>. When the flag is
  647. <TT>false</TT>, the
  648. returned edge descriptor points to the already existing edge.
  649. <p>
  650. The placement of the new edge in the out-edge list is in general
  651. unspecified, though ordering of the out-edge list can be accomplished
  652. through the choice of <tt>OutEdgeList</tt>.
  653. If the <tt>VertexList</tt> selector is
  654. <tt>vecS</tt>, and if either vertex descriptor <tt>u</tt> or
  655. <tt>v</tt> (which are integers) has a value greater than the current
  656. number of vertices in the graph, the graph is enlarged so that the
  657. number of vertices is <tt>std::max(u,v) + 1</tt>.
  658. <p>
  659. If the <TT>OutEdgeList</TT> selector is <TT>vecS</TT> then this operation
  660. will invalidate any <tt>out_edge_iterator</tt> for vertex
  661. <i>u</i>. This also applies if the <TT>OutEdgeList</TT> is a user-defined
  662. container that invalidates its iterators when <TT>push(container,
  663. x)</TT> is invoked (see Section <A
  664. HREF="./using_adjacency_list.html#sec:custom-storage">Customizing the
  665. Adjacency List Storage</A>). If the graph is also bidirectional then
  666. any <tt>in_edge_iterator</tt> for <i>v</i> is also invalidated. If
  667. instead the graph is undirected then any <tt>out_edge_iterator</tt>
  668. for <i>v</i> is also invalidated. If instead the graph is directed,
  669. then <tt>add_edge()</tt> also invalidates any <tt>edge_iterator</tt>.
  670. <hr>
  671. <pre>
  672. std::pair&lt;edge_descriptor,&nbsp;bool&gt;
  673. add_edge(vertex_descriptor&nbsp;u, vertex_descriptor&nbsp;v,
  674. const&nbsp;EdgeProperties&amp;&nbsp;p,
  675. adjacency_list&amp;&nbsp;g)
  676. </pre>
  677. Adds edge <i>(u,v)</i> to the graph and attaches <TT>p</TT> as the
  678. value of the edge's internal property storage. Also see the previous
  679. <TT>add_edge()</TT> non-member function for more details.
  680. <hr>
  681. <pre>
  682. void remove_edge(vertex_descriptor u, vertex_descriptor v,
  683. adjacency_list&amp; g)
  684. </pre>
  685. Removes the edge <i>(u,v)</i> from the graph.
  686. <p>
  687. This operation causes any outstanding edge descriptors or iterators
  688. that point to edge <i>(u,v)</i> to become invalid. In addition, if
  689. the <TT>OutEdgeList</TT> selector is <TT>vecS</TT> then this operation
  690. will invalidate any iterators that point into the edge-list for vertex
  691. <i>u</i> and also for vertex <i>v</i> in the undirected and
  692. bidirectional case. Also, for directed graphs this invalidates any
  693. <tt>edge_iterator</tt>.
  694. <hr>
  695. <pre>
  696. void remove_edge(edge_descriptor e, adjacency_list&amp; g)
  697. </pre>
  698. Removes the edge <tt>e</tt> from the graph. This differs from the
  699. <tt>remove_edge(u, v, g)</tt> function in the case of a
  700. multigraph. This <tt>remove_edge(e, g)</tt> function removes a single
  701. edge, whereas the <tt>remove_edge(u, v, g)</tt> function removes all
  702. edges <i>(u,v)</i>.
  703. <p>
  704. This operation invalidates any outstanding edge descriptors and
  705. iterators for the same edge pointed to by descriptor <tt>e</tt>. In
  706. addition, this operation will invalidate any iterators that point into
  707. the edge-list for the <tt>target(e, g)</tt>. Also, for directed
  708. graphs this invalidates any <tt>edge_iterator</tt> for the graph.
  709. <hr>
  710. <pre>
  711. void remove_edge(out_edge_iterator iter, adjacency_list&amp; g)
  712. </pre>
  713. This has the same effect as <tt>remove_edge(*iter, g)</tt>. The
  714. difference is that this function has constant time complexity
  715. in the case of directed graphs, whereas <tt>remove_edge(e, g)</tt>
  716. has time complexity <i>O(E/V)</i>.
  717. <hr>
  718. <pre>
  719. template &lt;class <a href="http://www.boost.org/sgi/stl/Predicate.html">Predicate</a>&gt;
  720. void remove_out_edge_if(vertex_descriptor u, Predicate predicate,
  721. adjacency_list&amp; g)
  722. </pre>
  723. Removes all out-edges of vertex <i>u</i> from the graph that satisfy
  724. the <tt>predicate</tt>. That is, if the predicate returns true when
  725. applied to an edge descriptor, then the edge is removed.
  726. <p>
  727. The affect on descriptor and iterator stability is the same as that of
  728. invoking <tt>remove_edge()</tt> on each of the removed edges.
  729. <hr>
  730. <pre>
  731. template &lt;class <a
  732. href="http://www.boost.org/sgi/stl/Predicate.html">Predicate</a>&gt;
  733. void remove_in_edge_if(vertex_descriptor v, Predicate predicate,
  734. adjacency_list&amp; g)
  735. </pre>
  736. Removes all in-edges of vertex <i>v</i> from the graph that satisfy
  737. the <tt>predicate</tt>. That is, if the predicate returns true when
  738. applied to an edge descriptor, then the edge is removed.
  739. <p>
  740. The affect on descriptor and iterator stability is the
  741. same as that of invoking <tt>remove_edge()</tt> on each of the
  742. removed edges.
  743. <p>
  744. This operation is available for undirected and bidirectional
  745. <tt>adjacency_list</tt> graphs, but not for directed.
  746. <hr>
  747. <pre>
  748. template &lt;class <a href="http://www.boost.org/sgi/stl/Predicate.html">Predicate</a>&gt;
  749. void remove_edge_if(Predicate predicate, adjacency_list&amp; g)
  750. </pre>
  751. Removes all edges from the graph that satisfy
  752. the <tt>predicate</tt>. That is, if the predicate returns true when
  753. applied to an edge descriptor, then the edge is removed.
  754. <p>
  755. The affect on descriptor and iterator stability is the same as that of
  756. invoking <tt>remove_edge()</tt> on each of the removed edges.
  757. <hr>
  758. <a name="sec:add-vertex">
  759. <pre>
  760. vertex_descriptor
  761. add_vertex(adjacency_list&amp; g)
  762. </pre>
  763. Adds a vertex to the graph and returns the vertex descriptor for the
  764. new vertex.
  765. </a>
  766. <hr>
  767. <pre>
  768. vertex_descriptor
  769. add_vertex(const&nbsp;VertexProperties&amp;&nbsp;p,
  770. adjacency_list&amp; g)
  771. </pre>
  772. Adds a vertex to the graph with the specified properties. Returns the
  773. vertex descriptor for the new vertex.
  774. </a>
  775. <hr>
  776. <pre>
  777. void clear_vertex(vertex_descriptor u, adjacency_list&amp; g)
  778. </pre>
  779. Removes all edges to and from vertex <i>u</i>. The vertex still appears
  780. in the vertex set of the graph.
  781. <p>
  782. The affect on descriptor and iterator stability is the
  783. same as that of invoking <tt>remove_edge()</tt> for all of
  784. the edges that have <tt>u</tt> as the source or target.
  785. <hr>
  786. <pre>
  787. void clear_out_edges(vertex_descriptor u, adjacency_list&amp; g)
  788. </pre>
  789. Removes all out-edges from vertex <i>u</i>. The vertex still appears
  790. in the vertex set of the graph.
  791. <p>
  792. The affect on descriptor and iterator stability is the
  793. same as that of invoking <tt>remove_edge()</tt> for all of
  794. the edges that have <tt>u</tt> as the source.
  795. <p>
  796. This operation is not applicable to undirected graphs
  797. (use <tt>clear_vertex()</tt> instead).
  798. <hr>
  799. <pre>
  800. void clear_in_edges(vertex_descriptor u, adjacency_list&amp; g)
  801. </pre>
  802. Removes all in-edges from vertex <i>u</i>. The vertex still appears
  803. in the vertex set of the graph.
  804. <p>
  805. The affect on descriptor and iterator stability is the
  806. same as that of invoking <tt>remove_edge()</tt> for all of
  807. the edges that have <tt>u</tt> as the target.
  808. <p>
  809. This operation is only applicable to bidirectional graphs.
  810. <hr>
  811. <pre>
  812. void remove_vertex(vertex_descriptor u, adjacency_list&amp; g)
  813. </pre>
  814. Remove vertex <i>u</i> from the vertex set of the graph. It is assumed
  815. that there are no edges to or from vertex <i>u</i> when it is removed.
  816. One way to make sure of this is to invoke <TT>clear_vertex()</TT>
  817. beforehand.
  818. <p>
  819. If the <TT>VertexList</TT> template parameter of the
  820. <TT>adjacency_list</TT> was <TT>vecS</TT>, then all vertex
  821. descriptors, edge descriptors, and iterators for the graph are
  822. invalidated by this operation. The builtin
  823. <tt>vertex_index_t</tt> property for each vertex is renumbered so that
  824. after the operation the vertex indices still form a contiguous range
  825. <TT>[0, num_vertices(g))</TT>. If you are using external property
  826. storage based on the builtin vertex index, then the external storage
  827. will need to be adjusted. Another option is to not use the builtin
  828. vertex index, and instead use a property to add your own vertex index
  829. property. If you need to make frequent use of the
  830. <TT>remove_vertex()</TT> function the <TT>listS</TT> selector is a
  831. much better choice for the <TT>VertexList</TT> template parameter.
  832. <hr>
  833. <h4><a name="property-map-accessors">Property Map Accessors</a></h4>
  834. <hr>
  835. <pre>
  836. template &lt;class <a href="./PropertyTag.html">PropertyTag</a>&gt;
  837. property_map&lt;adjacency_list, PropertyTag&gt;::type
  838. get(PropertyTag, adjacency_list&amp; g)
  839. template &lt;class <a href="./PropertyTag.html">PropertyTag</a>&gt;
  840. property_map&lt;adjacency_list, Tag&gt;::const_type
  841. get(PropertyTag, const adjacency_list&amp; g)
  842. </pre>
  843. Returns the property map object for the vertex property specified by
  844. <TT>PropertyTag</TT>. The <TT>PropertyTag</TT> must match one of the
  845. properties specified in the graph's <TT>VertexProperty</TT> template
  846. argument.
  847. <hr>
  848. <pre>
  849. template &lt;class <a href="./PropertyTag.html">PropertyTag</a>, class X&gt;
  850. typename property_traits&lt;property_map&lt;adjacency_list, PropertyTag&gt;::const_type&gt::value_type
  851. get(PropertyTag, const adjacency_list&amp; g, X x)
  852. </pre>
  853. This returns the property value for <tt>x</tt>, where <tt>x</tt> is either
  854. a vertex or edge descriptor.
  855. <hr>
  856. <pre>
  857. template &lt;class <a href="./PropertyTag.html">PropertyTag</a>, class X, class Value&gt;
  858. void
  859. put(PropertyTag, const adjacency_list&amp; g, X x, const Value& value)
  860. </pre>
  861. This sets the property value for <tt>x</tt> to
  862. <tt>value</tt>. <tt>x</tt> is either a vertex or edge descriptor.
  863. <tt>Value</tt> must be convertible to
  864. <tt>typename property_traits&lt;property_map&lt;adjacency_list, PropertyTag&gt;::type&gt::value_type</tt>
  865. <hr>
  866. <pre>
  867. template &lt;class GraphProperties, class <a href="./PropertyTag.html#GraphPropertyTag">GraphPropertyTag</a>&gt;
  868. typename graph_property&lt;adjacency_list, GraphPropertyTag&gt;::type&amp;
  869. get_property(adjacency_list&amp; g, GraphPropertyTag);
  870. </pre>
  871. Return the property specified by <tt>GraphPropertyTag</tt> that is
  872. attached to the graph object <tt>g</tt>. The <tt>graph_property</tt>
  873. traits class is defined in <a
  874. href="../../../boost/graph/adjacency_list.hpp"><tt>boost/graph/adjacency_list.hpp</tt></a>.
  875. <hr>
  876. <pre>
  877. template &lt;class GraphProperties, class <a href="./PropertyTag.html#GraphPropertyTag">GraphPropertyTag</a>&gt;
  878. const typename graph_property&lt;adjacency_list, GraphPropertyTag&gt;::type&amp;
  879. get_property(const adjacency_list&amp; g, GraphPropertyTag);
  880. </pre>
  881. Return the property specified by <tt>GraphPropertyTag</tt> that is
  882. attached to the graph object <tt>g</tt>. The <tt>graph_property</tt>
  883. traits class is defined in <a
  884. href="../../../boost/graph/adjacency_list.hpp"><tt>boost/graph/adjacency_list.hpp</tt></a>.
  885. <!-- add the shortcut property functions -->
  886. <hr>
  887. <h4><a name="serialization">Serialization</a></h4>
  888. <hr>
  889. <pre>
  890. template&lt;class <a href="../../serialization/doc/archives.html#saving_interface">SavingArchive</a>&gt;
  891. SavingArchive&amp; operator<<(SavingArchive&amp; ar, const adjacency_list&amp graph);
  892. </pre>
  893. Serializes the graph into the archive. Requires the vertex and edge properties of the
  894. graph to be <a href="../../serialization/doc/index.html">Serializable</a>.
  895. <br>
  896. Include <a href="../../../boost/graph/adj_list_serialize.hpp"><tt>boost/graph/adj_list_serialize.hpp</tt></a>.
  897. <hr>
  898. <pre>
  899. template&lt;class <a href="../../serialization/doc/archives.html#loading_interface">LoadingArchive</a>&gt;
  900. LoadingArchive&amp; operator>>(LoadingArchive&amp; ar, const adjacency_list&amp graph);
  901. </pre>
  902. Reads the graph from the archive. Requires the vertex and edge properties of the
  903. graph to be <a href="../../serialization/doc/index.html">Serializable</a>.
  904. <br>
  905. Include <a href="../../../boost/graph/adj_list_serialize.hpp"><tt>boost/graph/adj_list_serialize.hpp</tt></a>.
  906. <hr>
  907. <h3>See Also</h3>
  908. <a href="./adjacency_list_traits.html"><tt>adjacency_list_traits</tt></a>,
  909. <a href="./property_map.html"><tt>property_map</tt></a>,
  910. <a href="./graph_traits.html"><tt>graph_traits</tt></a>
  911. <br>
  912. <HR>
  913. <TABLE>
  914. <TR valign=top>
  915. <TD nowrap>Copyright &copy; 2000-2001</TD><TD>
  916. <A HREF="http://www.boost.org/people/jeremy_siek.htm">Jeremy Siek</A>,
  917. Indiana University (<A
  918. HREF="mailto:jsiek@osl.iu.edu">jsiek@osl.iu.edu</A>)<br>
  919. <A HREF="http://www.boost.org/people/liequan_lee.htm">Lie-Quan Lee</A>, Indiana University (<A HREF="mailto:llee@cs.indiana.edu">llee@cs.indiana.edu</A>)<br>
  920. <A HREF="https://homes.cs.washington.edu/~al75">Andrew Lumsdaine</A>,
  921. Indiana University (<A
  922. HREF="mailto:lums@osl.iu.edu">lums@osl.iu.edu</A>)
  923. </TD></TR></TABLE>
  924. </BODY>
  925. </HTML>
  926. <!-- LocalWords: gif ALT OutEdgeList EdgeList VertexList html VertexProperties EdgeProperties
  927. -->
  928. <!-- LocalWords: GraphPropertyTag cpp enum ai cout endl VertexAndEdgeListGraph
  929. -->
  930. <!-- LocalWords: MutablePropertyGraph hpp const ReadablePropertyMap listS num
  931. -->
  932. <!-- LocalWords: ReadWritePropertyMap vecS dijkstra ucs pre Adj Iter Desc ep
  933. -->
  934. <!-- LocalWords: EdgeIterator EdgePropertyIterator iter bool edge's IDs siek
  935. -->
  936. <!-- LocalWords: multigraph typename htm Univ Quan Lumsdaine
  937. -->