distributed_adjacency_list.html 49 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804
  1. <?xml version="1.0" encoding="utf-8" ?>
  2. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  3. <html xmlns="http://www.w3.org/1999/xhtml" xml:lang="en" lang="en">
  4. <head>
  5. <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
  6. <meta name="generator" content="Docutils 0.6: http://docutils.sourceforge.net/" />
  7. <title>Parallel BGL Distributed Adjacency List</title>
  8. <link rel="stylesheet" href="../../../../rst.css" type="text/css" />
  9. </head>
  10. <body>
  11. <div class="document" id="logo-distributed-adjacency-list">
  12. <h1 class="title"><a class="reference external" href="http://www.osl.iu.edu/research/pbgl"><img align="middle" alt="Parallel BGL" class="align-middle" src="pbgl-logo.png" /></a> Distributed Adjacency List</h1>
  13. <!-- Copyright (C) 2004-2008 The Trustees of Indiana University.
  14. Use, modification and distribution is subject to the Boost Software
  15. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  16. http://www.boost.org/LICENSE_1_0.txt) -->
  17. <div class="contents topic" id="contents">
  18. <p class="topic-title first">Contents</p>
  19. <ul class="simple">
  20. <li><a class="reference internal" href="#introduction" id="id1">Introduction</a><ul>
  21. <li><a class="reference internal" href="#defining-a-distributed-adjacency-list" id="id2">Defining a Distributed Adjacency List</a></li>
  22. <li><a class="reference internal" href="#distributed-vertex-and-edge-properties" id="id3">Distributed Vertex and Edge Properties</a></li>
  23. <li><a class="reference internal" href="#named-vertices" id="id4">Named Vertices</a></li>
  24. <li><a class="reference internal" href="#building-a-distributed-graph" id="id5">Building a Distributed Graph</a></li>
  25. <li><a class="reference internal" href="#graph-concepts" id="id6">Graph Concepts</a></li>
  26. </ul>
  27. </li>
  28. <li><a class="reference internal" href="#reference" id="id7">Reference</a><ul>
  29. <li><a class="reference internal" href="#where-defined" id="id8">Where Defined</a></li>
  30. <li><a class="reference internal" href="#associated-types" id="id9">Associated Types</a></li>
  31. <li><a class="reference internal" href="#member-functions" id="id10">Member Functions</a></li>
  32. <li><a class="reference internal" href="#non-member-functions" id="id11">Non-Member Functions</a></li>
  33. <li><a class="reference internal" href="#structure-modification" id="id12">Structure Modification</a></li>
  34. <li><a class="reference internal" href="#property-map-accessors" id="id13">Property Map Accessors</a></li>
  35. </ul>
  36. </li>
  37. </ul>
  38. </div>
  39. <div class="section" id="introduction">
  40. <h1><a class="toc-backref" href="#id1">Introduction</a></h1>
  41. <p>The distributed adjacency list implements a graph data structure using
  42. an adjacency list representation. Its interface and behavior are
  43. roughly equivalent to the Boost Graph Library's <a class="reference external" href="http://www.boost.org/libs/graph/doc/adjacency_list.html">adjacency_list</a>
  44. class template. However, the distributed adjacency list partitions the
  45. vertices of the graph across several processes (which need not share
  46. an address space). Edges outgoing from any vertex stored by a process
  47. are also stored on that process, except in the case of undirected
  48. graphs, where either the source or the target may store the edge.</p>
  49. <pre class="literal-block">
  50. template&lt;typename OutEdgeListS, typename ProcessGroup, typename VertexListS,
  51. typename DirectedS, typename VertexProperty, typename EdgeProperty,
  52. typename GraphProperty, typename EdgeListS&gt;
  53. class adjacency_list&lt;OutEdgeListS,
  54. distributedS&lt;ProcessGroup, VertexListS&gt;,
  55. DirectedS, VertexProperty,
  56. EdgeProperty, GraphProperty, EdgeListS&gt;;
  57. </pre>
  58. <div class="section" id="defining-a-distributed-adjacency-list">
  59. <h2><a class="toc-backref" href="#id2">Defining a Distributed Adjacency List</a></h2>
  60. <p>To create a distributed adjacency list, first determine the
  61. representation of the graph in a single address space using these
  62. <a class="reference external" href="http://www.boost.org/libs/graph/doc/using_adjacency_list.html">guidelines</a>. Next, replace the vertex list selector (<tt class="docutils literal"><span class="pre">VertexListS</span></tt>)
  63. with an instantiation of <a class="reference external" href="distributedS.html">distributedS</a>, which includes:</p>
  64. <ul class="simple">
  65. <li>Selecting a <a class="reference external" href="process_group.html">process group</a> type that represents the various
  66. coordinating processes that will store the distributed graph. For
  67. example, the <a class="reference external" href="process_group.html">MPI process group</a>.</li>
  68. <li>A selector indicating how the vertex lists in each process will be
  69. stored. Only the <tt class="docutils literal"><span class="pre">vecS</span></tt> and <tt class="docutils literal"><span class="pre">listS</span></tt> selectors are well-supported
  70. at this time.</li>
  71. </ul>
  72. <p>The following <tt class="docutils literal"><span class="pre">typedef</span></tt> defines a distributed adjacency list
  73. containing directed edges. The vertices in the graph will be
  74. distributed over several processes, using the MPI process group
  75. for communication. In each process, the vertices and outgoing edges
  76. will be stored in STL vectors. There are no properties attached to the
  77. vertices or edges of the graph.</p>
  78. <pre class="literal-block">
  79. using namespace boost;
  80. typedef adjacency_list&lt;vecS,
  81. distributedS&lt;parallel::mpi::bsp_process_group, vecS&gt;,
  82. directedS&gt;
  83. Graph;
  84. </pre>
  85. </div>
  86. <div class="section" id="distributed-vertex-and-edge-properties">
  87. <h2><a class="toc-backref" href="#id3">Distributed Vertex and Edge Properties</a></h2>
  88. <p>Vertex and edge properties for distributed graphs mirror their
  89. counterparts for non-distributed graphs. With a distributed graph,
  90. however, vertex and edge properties are stored only in the process
  91. that owns the vertex or edge.</p>
  92. <p>The most direct way to attach properties to a distributed graph is to
  93. create a structure that will be attached to each of the vertices and
  94. edges of the graph. For example, if we wish to model a simplistic map
  95. of the United States interstate highway system, we might state that
  96. the vertices of the graph are cities and the edges are highways, then
  97. define the information that we maintain for each city and highway:</p>
  98. <pre class="literal-block">
  99. struct City {
  100. City() { }
  101. City(const std::string&amp; name, const std::string&amp; mayor = &quot;Unknown&quot;, int population = 0)
  102. : name(name), mayor(mayor), population(population) { }
  103. std::string name;
  104. std::string mayor;
  105. int population;
  106. // Serialization support is required!
  107. template&lt;typename Archiver&gt;
  108. void serialize(Archiver&amp; ar, const unsigned int /*version*/) {
  109. ar &amp; name &amp; mayor &amp; population;
  110. }
  111. };
  112. struct Highway {
  113. Highway() { }
  114. Highway(const std::string&amp; name, int lanes, int miles_per_hour, int length)
  115. : name(name), lanes(lanes), miles_per_hour(miles_per_hour), length(length) { }
  116. std::string name;
  117. int lanes;
  118. int miles_per_hour;
  119. int length;
  120. // Serialization support is required!
  121. template&lt;typename Archiver&gt;
  122. void serialize(Archiver&amp; ar, const unsigned int /*version*/) {
  123. ar &amp; name &amp; lanes &amp; miles_per_hour &amp; length;
  124. }
  125. };
  126. </pre>
  127. <p>To create a distributed graph for a road map, we supply <tt class="docutils literal"><span class="pre">City</span></tt> and
  128. <tt class="docutils literal"><span class="pre">Highway</span></tt> as the fourth and fifth parameters to <tt class="docutils literal"><span class="pre">adjacency_list</span></tt>,
  129. respectively:</p>
  130. <pre class="literal-block">
  131. typedef adjacency_list&lt;vecS,
  132. distributedS&lt;parallel::mpi::bsp_process_group, vecS&gt;,
  133. directedS,
  134. City, Highway&gt;
  135. RoadMap;
  136. </pre>
  137. <p>Property maps for internal properties retain their behavior with
  138. distributed graphs via <a class="reference external" href="distributed_property_map.html">distributed property maps</a>, which automate
  139. communication among processes so that <tt class="docutils literal"><span class="pre">put</span></tt> and <tt class="docutils literal"><span class="pre">get</span></tt> operations
  140. may be applied to non-local vertices and edges. However, for
  141. distributed adjacency lists that store vertices in a vector
  142. (<tt class="docutils literal"><span class="pre">VertexListS</span></tt> is <tt class="docutils literal"><span class="pre">vecS</span></tt>), the automatic <tt class="docutils literal"><span class="pre">vertex_index</span></tt>
  143. property map restricts the domain of <tt class="docutils literal"><span class="pre">put</span></tt> and <tt class="docutils literal"><span class="pre">get</span></tt> operations
  144. to vertices local to the process executing the operation. For example,
  145. we can create a property map that accesses the length of each highway
  146. as follows:</p>
  147. <pre class="literal-block">
  148. RoadMap map; // distributed graph instance
  149. typedef property_map&lt;RoadMap, int Highway::*&gt;::type
  150. road_length = get(&amp;Highway::length, map);
  151. </pre>
  152. <p>Now, one can access the length of any given road based on its edge
  153. descriptor <tt class="docutils literal"><span class="pre">e</span></tt> with the expression <tt class="docutils literal"><span class="pre">get(road_length,</span> <span class="pre">e)</span></tt>,
  154. regardless of which process stores the edge <tt class="docutils literal"><span class="pre">e</span></tt>.</p>
  155. </div>
  156. <div class="section" id="named-vertices">
  157. <h2><a class="toc-backref" href="#id4">Named Vertices</a></h2>
  158. <p>The vertices of a graph typically correspond to named entities within
  159. the application domain. In the road map example from the previous
  160. section, the vertices in the graph represent cities. The distributed
  161. adjacency list supports named vertices, which provides an implicit
  162. mapping from the names of the vertices in the application domain
  163. (e.g., the name of a city, such as &quot;Bloomington&quot;) to the actual vertex
  164. descriptor stored within the distributed graph (e.g., the third vertex
  165. on processor 1). By enabling support for named vertices, one can refer
  166. to vertices by name when manipulating the graph. For example, one can
  167. add a highway from Indianapolis to Chicago:</p>
  168. <pre class="literal-block">
  169. add_edge(&quot;Indianapolis&quot;, &quot;Chicago&quot;, Highway(&quot;I-65&quot;, 4, 65, 151), map);
  170. </pre>
  171. <p>The distributed adjacency list will find vertices associated with the
  172. names &quot;Indianapolis&quot; and &quot;Chicago&quot;, then add an edge between these
  173. vertices that represents I-65. The vertices may be stored on any
  174. processor, local or remote.</p>
  175. <p>To enable named vertices, specialize the <tt class="docutils literal"><span class="pre">internal_vertex_name</span></tt>
  176. property for the structure attached to the vertices in your
  177. graph. <tt class="docutils literal"><span class="pre">internal_vertex_name</span></tt> contains a single member, <tt class="docutils literal"><span class="pre">type</span></tt>,
  178. which is the type of a function object that accepts a vertex property
  179. and returns the name stored within that vertex property. In the case
  180. of our road map, the <tt class="docutils literal"><span class="pre">name</span></tt> field contains the name of each city, so
  181. we use the <tt class="docutils literal"><span class="pre">member</span></tt> function object from the <a class="reference external" href="http://www.boost.org/libs/multi_index/doc/index.html">Boost.MultiIndex</a>
  182. library to extract the name, e.g.,</p>
  183. <pre class="literal-block">
  184. namespace boost { namespace graph {
  185. template&lt;&gt;
  186. struct internal_vertex_name&lt;City&gt;
  187. {
  188. typedef multi_index::member&lt;City, std::string, &amp;City::name&gt; type;
  189. };
  190. } }
  191. </pre>
  192. <p>That's it! One can now refer to vertices by name when interacting with
  193. the distributed adjacency list.</p>
  194. <p>What happens when one uses the name of a vertex that does not exist?
  195. For example, in our <tt class="docutils literal"><span class="pre">add_edge</span></tt> call above, what happens if the
  196. vertex named &quot;Indianapolis&quot; has not yet been added to the graph? By
  197. default, the distributed adjacency list will throw an exception if a
  198. named vertex does not yet exist. However, one can customize this
  199. behavior by specifying a function object that constructs an instance
  200. of the vertex property (e.g., <tt class="docutils literal"><span class="pre">City</span></tt>) from just the name of the
  201. vertex. This customization occurs via the
  202. <tt class="docutils literal"><span class="pre">internal_vertex_constructor</span></tt> trait. For example, using the
  203. <tt class="docutils literal"><span class="pre">vertex_from_name</span></tt> template (provided with the Parallel BGL), we can
  204. state that a <tt class="docutils literal"><span class="pre">City</span></tt> can be constructed directly from the name of the
  205. city using its second constructor:</p>
  206. <pre class="literal-block">
  207. namespace boost { namespace graph {
  208. template&lt;&gt;
  209. struct internal_vertex_constructor&lt;City&gt;
  210. {
  211. typedef vertex_from_name&lt;City&gt; type;
  212. };
  213. } }
  214. </pre>
  215. <p>Now, one can add edges by vertex name freely, without worrying about
  216. the explicit addition of vertices. The <tt class="docutils literal"><span class="pre">mayor</span></tt> and <tt class="docutils literal"><span class="pre">population</span></tt>
  217. fields will have default values, but the graph structure will be
  218. correct.</p>
  219. </div>
  220. <div class="section" id="building-a-distributed-graph">
  221. <h2><a class="toc-backref" href="#id5">Building a Distributed Graph</a></h2>
  222. <p>Once you have determined the layout of your graph type, including the
  223. specific data structures and properties, it is time to construct an
  224. instance of the graph by adding the appropriate vertices and
  225. edges. Construction of distributed graphs can be slightly more
  226. complicated than construction of normal, non-distributed graph data
  227. structures, because one must account for both the distribution of the
  228. vertices and edges and the multiple processes executing
  229. concurrently. There are three main ways to construct distributed
  230. graphs:</p>
  231. <p>1. <em>Sequence constructors</em>: if your data can easily be generated by a
  232. pair of iterators that produce (source, target) pairs, you can use the
  233. sequence constructors to build the distributed graph in parallel. This
  234. method is often preferred when creating benchmarks, because random
  235. graph generators like the <a class="reference external" href="http://www.boost.org/libs/graph/doc/sorted_erdos_renyi_gen.html">sorted_erdos_renyi_iterator</a> create the
  236. appropriate input sequence. Note that one must provide the same input
  237. iterator sequence on all processes. This method has the advantage that
  238. the sequential graph-building code is identical to the parallel
  239. graph-building code. An example constructing a random graph this way:</p>
  240. <blockquote>
  241. <pre class="literal-block">
  242. typedef boost::sorted_erdos_renyi_iterator&lt;boost::minstd_rand, Graph&gt; ERIter;
  243. boost::minstd_rand gen;
  244. unsigned long n = 1000000; // 1M vertices
  245. Graph g(ERIter(gen, n, 0.00005), ERIter(), n);
  246. </pre>
  247. </blockquote>
  248. <p>2. <em>Adding edges by vertex number</em>: if you are able to map your
  249. vertices into values in the random [0, <em>n</em>), where <em>n</em> is the number
  250. of vertices in the distributed graph. Use this method rather than the
  251. sequence constructors when your algorithm cannot easily be moved into
  252. input iterators, or if you can't replicate the input sequence. For
  253. example, you might be reading the graph from an input file:</p>
  254. <blockquote>
  255. <pre class="literal-block">
  256. Graph g(n); // initialize with the total number of vertices, n
  257. if (process_id(g.process_group()) == 0) {
  258. // Only process 0 loads the graph, which is distributed automatically
  259. int source, target;
  260. for (std::cin &gt;&gt; source &gt;&gt; target)
  261. add_edge(vertex(source, g), vertex(target, g), g);
  262. }
  263. // All processes synchronize at this point, then the graph is complete
  264. synchronize(g.process_group());
  265. </pre>
  266. </blockquote>
  267. <p>3. <em>Adding edges by name</em>: if you are using named vertices, you can
  268. construct your graph just by calling <tt class="docutils literal"><span class="pre">add_edge</span></tt> with the names of
  269. the source and target vertices. Be careful to make sure that each edge
  270. is added by only one process (it doesn't matter which process it is),
  271. otherwise you will end up with multiple edges. For example, in the
  272. following program we read edges from the standard input of process 0,
  273. adding those edges by name. Vertices and edges will be created and
  274. distributed automatically.</p>
  275. <blockquote>
  276. <pre class="literal-block">
  277. Graph g;
  278. if (process_id(g.process_group()) == 0) {
  279. // Only process 0 loads the graph, which is distributed automatically
  280. std:string source, target;
  281. for(std::cin &gt;&gt; source &gt;&gt; target)
  282. add_edge(source, target, g);
  283. }
  284. // All processes synchronize at this point, then the graph is complete
  285. synchronize(g.process_group());
  286. </pre>
  287. </blockquote>
  288. </div>
  289. <div class="section" id="graph-concepts">
  290. <h2><a class="toc-backref" href="#id6">Graph Concepts</a></h2>
  291. <p>The distributed adjacency list models the <a class="reference external" href="http://www.boost.org/libs/graph/doc/Graph.html">Graph</a> concept, and in
  292. particular the <a class="reference external" href="DistributedGraph.html">Distributed Graph</a> concept. It also models the
  293. <a class="reference external" href="http://www.boost.org/libs/graph/doc/IncidenceGraph.html">Incidence Graph</a> and <a class="reference external" href="http://www.boost.org/libs/graph/doc/AdjacencyGraph.html">Adjacency Graph</a> concept, but restricts the
  294. input domain of the operations to correspond to local vertices
  295. only. For instance, a process may only access the outgoing edges of a
  296. vertex if that vertex is stored in that process. Undirected and
  297. bidirectional distributed adjacency lists model the <a class="reference external" href="http://www.boost.org/libs/graph/doc/BidirectionalGraph.html">Bidirectional
  298. Graph</a> concept, with the same domain restrictions. Distributed
  299. adjacency lists also model the <a class="reference external" href="http://www.boost.org/libs/graph/doc/MutableGraph.html">Mutable Graph</a> concept (with domain
  300. restrictions; see the <a class="reference internal" href="#reference">Reference</a> section), <a class="reference external" href="http://www.boost.org/libs/graph/doc/PropertyGraph.html">Property Graph</a> concept,
  301. and <a class="reference external" href="http://www.boost.org/libs/graph/doc/MutablePropertyGraph.html">Mutable Property Graph</a> concept.</p>
  302. <p>Unlike its non-distributed counterpart, the distributed adjacency
  303. list does <strong>not</strong> model the <a class="reference external" href="http://www.boost.org/libs/graph/doc/VertexListGraph.html">Vertex List Graph</a> or <a class="reference external" href="http://www.boost.org/libs/graph/doc/EdgeListGraph.html">Edge List
  304. Graph</a> concepts, because one cannot enumerate all vertices or edges
  305. within a distributed graph. Instead, it models the weaker
  306. <a class="reference external" href="DistributedVertexListGraph.html">Distributed Vertex List Graph</a> and <a class="reference external" href="DistributedEdgeListGraph.html">Distributed Edge List Graph</a>
  307. concepts, which permit access to the local edges and vertices on each
  308. processor. Note that if all processes within the process group over
  309. which the graph is distributed iterator over their respective vertex
  310. or edge lists, all vertices and edges will be covered once.</p>
  311. </div>
  312. </div>
  313. <div class="section" id="reference">
  314. <h1><a class="toc-backref" href="#id7">Reference</a></h1>
  315. <p>Since the distributed adjacency list closely follows the
  316. non-distributed <a class="reference external" href="http://www.boost.org/libs/graph/doc/adjacency_list.html">adjacency_list</a>, this reference documentation
  317. only describes where the two implementations differ.</p>
  318. <div class="section" id="where-defined">
  319. <h2><a class="toc-backref" href="#id8">Where Defined</a></h2>
  320. <p>&lt;boost/graph/distributed/adjacency_list.hpp&gt;</p>
  321. </div>
  322. <div class="section" id="associated-types">
  323. <h2><a class="toc-backref" href="#id9">Associated Types</a></h2>
  324. <pre class="literal-block">
  325. adjacency_list::process_group_type
  326. </pre>
  327. <p>The type of the process group over which the graph will be
  328. distributed.</p>
  329. <hr class="docutils" />
  330. <blockquote>
  331. adjacency_list::distribution_type</blockquote>
  332. <p>The type of distribution used to partition vertices in the graph.</p>
  333. <hr class="docutils" />
  334. <blockquote>
  335. adjacency_list::vertex_name_type</blockquote>
  336. <p>If the graph supports named vertices, this is the type used to name
  337. vertices. Otherwise, this type is not present within the distributed
  338. adjacency list.</p>
  339. </div>
  340. <div class="section" id="member-functions">
  341. <h2><a class="toc-backref" href="#id10">Member Functions</a></h2>
  342. <pre class="literal-block">
  343. adjacency_list(const ProcessGroup&amp; pg = ProcessGroup());
  344. adjacency_list(const GraphProperty&amp; g,
  345. const ProcessGroup&amp; pg = ProcessGroup());
  346. </pre>
  347. <p>Construct an empty distributed adjacency list with the given process
  348. group (or default) and graph property (or default).</p>
  349. <hr class="docutils" />
  350. <pre class="literal-block">
  351. adjacency_list(vertices_size_type n, const GraphProperty&amp; p,
  352. const ProcessGroup&amp; pg, const Distribution&amp; distribution);
  353. adjacency_list(vertices_size_type n, const ProcessGroup&amp; pg,
  354. const Distribution&amp; distribution);
  355. adjacency_list(vertices_size_type n, const GraphProperty&amp; p,
  356. const ProcessGroup&amp; pg = ProcessGroup());
  357. adjacency_list(vertices_size_type n,
  358. const ProcessGroup&amp; pg = ProcessGroup());
  359. </pre>
  360. <p>Construct a distributed adjacency list with <tt class="docutils literal"><span class="pre">n</span></tt> vertices,
  361. optionally providing the graph property, process group, or
  362. distribution. The <tt class="docutils literal"><span class="pre">n</span></tt> vertices will be distributed via the given
  363. (or default-constructed) distribution. This operation is collective,
  364. requiring all processes with the process group to execute it
  365. concurrently.</p>
  366. <hr class="docutils" />
  367. <pre class="literal-block">
  368. template &lt;class EdgeIterator&gt;
  369. adjacency_list(EdgeIterator first, EdgeIterator last,
  370. vertices_size_type n,
  371. const ProcessGroup&amp; pg = ProcessGroup(),
  372. const GraphProperty&amp; p = GraphProperty());
  373. template &lt;class EdgeIterator, class EdgePropertyIterator&gt;
  374. adjacency_list(EdgeIterator first, EdgeIterator last,
  375. EdgePropertyIterator ep_iter,
  376. vertices_size_type n,
  377. const ProcessGroup&amp; pg = ProcessGroup(),
  378. const GraphProperty&amp; p = GraphProperty());
  379. template &lt;class EdgeIterator&gt;
  380. adjacency_list(EdgeIterator first, EdgeIterator last,
  381. vertices_size_type n,
  382. const ProcessGroup&amp; process_group,
  383. const Distribution&amp; distribution,
  384. const GraphProperty&amp; p = GraphProperty());
  385. template &lt;class EdgeIterator, class EdgePropertyIterator&gt;
  386. adjacency_list(EdgeIterator first, EdgeIterator last,
  387. EdgePropertyIterator ep_iter,
  388. vertices_size_type n,
  389. const ProcessGroup&amp; process_group,
  390. const Distribution&amp; distribution,
  391. const GraphProperty&amp; p = GraphProperty());
  392. </pre>
  393. <p>Construct a distributed adjacency list with <tt class="docutils literal"><span class="pre">n</span></tt> vertices and with
  394. edges specified in the edge list given by the range <tt class="docutils literal"><span class="pre">[first,</span> <span class="pre">last)</span></tt>. The
  395. <tt class="docutils literal"><span class="pre">EdgeIterator</span></tt> must be a model of <a class="reference external" href="http://www.boost.org/doc/html/InputIterator.html">InputIterator</a>. The value type of the
  396. <tt class="docutils literal"><span class="pre">EdgeIterator</span></tt> must be a <tt class="docutils literal"><span class="pre">std::pair</span></tt>, where the type in the pair is an
  397. integer type. The integers will correspond to vertices, and they must
  398. all fall in the range of <tt class="docutils literal"><span class="pre">[0,</span> <span class="pre">n)</span></tt>. When provided, <tt class="docutils literal"><span class="pre">ep_iter</span></tt>
  399. refers to an edge property list <tt class="docutils literal"><span class="pre">[ep_iter,</span> <span class="pre">ep_iter</span> <span class="pre">+</span> <span class="pre">m)</span></tt> contains
  400. properties for each of the edges.</p>
  401. <p>This constructor is a collective operation and must be executed
  402. concurrently by each process with the same argument list. Most
  403. importantly, the edge lists provided to the constructor in each process
  404. should be equivalent. The vertices will be partitioned among the
  405. processes according to the <tt class="docutils literal"><span class="pre">distribution</span></tt>, with edges placed on the
  406. process owning the source of the edge. Note that this behavior
  407. permits sequential graph construction code to be parallelized
  408. automatically, regardless of the underlying distribution.</p>
  409. <hr class="docutils" />
  410. <pre class="literal-block">
  411. void clear()
  412. </pre>
  413. <p>Removes all of the edges and vertices from the local graph. To
  414. eliminate all vertices and edges from the graph, this routine must be
  415. executed in all processes.</p>
  416. <hr class="docutils" />
  417. <pre class="literal-block">
  418. process_group_type&amp; process_group();
  419. const process_group_type&amp; process_group() const;
  420. </pre>
  421. <p>Returns the process group over which this graph is distributed.</p>
  422. <hr class="docutils" />
  423. <pre class="literal-block">
  424. distribution_type&amp; distribution();
  425. const distribution_type&amp; distribution() const;
  426. </pre>
  427. <p>Returns the distribution used for initial placement of vertices.</p>
  428. <hr class="docutils" />
  429. <pre class="literal-block">
  430. template&lt;typename VertexProcessorMap&gt;
  431. void redistribute(VertexProcessorMap vertex_to_processor);
  432. </pre>
  433. <p>Redistributes the vertices (and, therefore, the edges) of the
  434. graph. The property map <tt class="docutils literal"><span class="pre">vertex_to_processor</span></tt> provides, for each
  435. vertex, the process identifier indicating where the vertex should be
  436. moved. Once this collective routine has completed, the distributed
  437. graph will reflect the new distribution. All vertex and edge
  438. descsriptors and internal and external property maps are invalidated
  439. by this operation.</p>
  440. <hr class="docutils" />
  441. <pre class="literal-block">
  442. template&lt;typename OStreamConstructibleArchive&gt;
  443. void save(std::string const&amp; filename) const;
  444. template&lt;typename IStreamConstructibleArchive&gt;
  445. void load(std::string const&amp; filename);
  446. </pre>
  447. <p>Serializes the graph to a Boost.Serialization archive.
  448. <tt class="docutils literal"><span class="pre">OStreamConstructibleArchive</span></tt> and <tt class="docutils literal"><span class="pre">IStreamConstructibleArchive</span></tt>
  449. are models of Boost.Serialization <em>Archive</em> with the extra
  450. requirement that they can be constructed from a <tt class="docutils literal"><span class="pre">std::ostream</span></tt>
  451. and <tt class="docutils literal"><span class="pre">std::istream</span></tt>.
  452. <tt class="docutils literal"><span class="pre">filename</span></tt> names a directory that will hold files for
  453. the different processes.</p>
  454. </div>
  455. <div class="section" id="non-member-functions">
  456. <h2><a class="toc-backref" href="#id11">Non-Member Functions</a></h2>
  457. <pre class="literal-block">
  458. std::pair&lt;vertex_iterator, vertex_iterator&gt;
  459. vertices(const adjacency_list&amp; g);
  460. </pre>
  461. <p>Returns an iterator-range providing access to the vertex set of graph
  462. <tt class="docutils literal"><span class="pre">g</span></tt> stored in this process. Each of the processes that contain <tt class="docutils literal"><span class="pre">g</span></tt>
  463. will get disjoint sets of vertices.</p>
  464. <hr class="docutils" />
  465. <pre class="literal-block">
  466. std::pair&lt;edge_iterator, edge_iterator&gt;
  467. edges(const adjacency_list&amp; g);
  468. </pre>
  469. <p>Returns an iterator-range providing access to the edge set of graph
  470. <tt class="docutils literal"><span class="pre">g</span></tt> stored in this process.</p>
  471. <hr class="docutils" />
  472. <pre class="literal-block">
  473. std::pair&lt;adjacency_iterator, adjacency_iterator&gt;
  474. adjacent_vertices(vertex_descriptor u, const adjacency_list&amp; g);
  475. </pre>
  476. <p>Returns an iterator-range providing access to the vertices adjacent to
  477. vertex <tt class="docutils literal"><span class="pre">u</span></tt> in graph <tt class="docutils literal"><span class="pre">g</span></tt>. The vertex <tt class="docutils literal"><span class="pre">u</span></tt> must be local to this process.</p>
  478. <hr class="docutils" />
  479. <pre class="literal-block">
  480. std::pair&lt;out_edge_iterator, out_edge_iterator&gt;
  481. out_edges(vertex_descriptor u, const adjacency_list&amp; g);
  482. </pre>
  483. <p>Returns an iterator-range providing access to the out-edges of vertex
  484. <tt class="docutils literal"><span class="pre">u</span></tt> in graph <tt class="docutils literal"><span class="pre">g</span></tt>. If the graph is undirected, this iterator-range
  485. provides access to all edges incident on vertex <tt class="docutils literal"><span class="pre">u</span></tt>. For both
  486. directed and undirected graphs, for an out-edge <tt class="docutils literal"><span class="pre">e</span></tt>, <tt class="docutils literal"><span class="pre">source(e,</span> <span class="pre">g)</span>
  487. <span class="pre">==</span> <span class="pre">u</span></tt> and <tt class="docutils literal"><span class="pre">target(e,</span> <span class="pre">g)</span> <span class="pre">==</span> <span class="pre">v</span></tt> where <tt class="docutils literal"><span class="pre">v</span></tt> is a vertex adjacent to
  488. <tt class="docutils literal"><span class="pre">u</span></tt>. The vertex <tt class="docutils literal"><span class="pre">u</span></tt> must be local to this process.</p>
  489. <hr class="docutils" />
  490. <pre class="literal-block">
  491. std::pair&lt;in_edge_iterator, in_edge_iterator&gt;
  492. in_edges(vertex_descriptor v, const adjacency_list&amp; g);
  493. </pre>
  494. <p>Returns an iterator-range providing access to the in-edges of vertex
  495. <tt class="docutils literal"><span class="pre">v</span></tt> in graph <tt class="docutils literal"><span class="pre">g</span></tt>. This operation is only available if
  496. <tt class="docutils literal"><span class="pre">bidirectionalS</span></tt> was specified for the <tt class="docutils literal"><span class="pre">Directed</span></tt> template
  497. parameter. For an in-edge <tt class="docutils literal"><span class="pre">e</span></tt>, <tt class="docutils literal"><span class="pre">target(e,</span> <span class="pre">g)</span> <span class="pre">==</span> <span class="pre">v</span></tt> and <tt class="docutils literal"><span class="pre">source(e,</span>
  498. <span class="pre">g)</span> <span class="pre">==</span> <span class="pre">u</span></tt> for some vertex <tt class="docutils literal"><span class="pre">u</span></tt> that is adjacent to <tt class="docutils literal"><span class="pre">v</span></tt>, whether the
  499. graph is directed or undirected. The vertex <tt class="docutils literal"><span class="pre">v</span></tt> must be local to
  500. this process.</p>
  501. <hr class="docutils" />
  502. <pre class="literal-block">
  503. degree_size_type
  504. out_degree(vertex_descriptor u, const adjacency_list&amp; g);
  505. </pre>
  506. <p>Returns the number of edges leaving vertex <tt class="docutils literal"><span class="pre">u</span></tt>. Vertex <tt class="docutils literal"><span class="pre">u</span></tt> must
  507. be local to the executing process.</p>
  508. <hr class="docutils" />
  509. <pre class="literal-block">
  510. degree_size_type
  511. in_degree(vertex_descriptor u, const adjacency_list&amp; g);
  512. </pre>
  513. <p>Returns the number of edges entering vertex <tt class="docutils literal"><span class="pre">u</span></tt>. This operation is
  514. only available if <tt class="docutils literal"><span class="pre">bidirectionalS</span></tt> was specified for the
  515. <tt class="docutils literal"><span class="pre">Directed</span></tt> template parameter. Vertex <tt class="docutils literal"><span class="pre">u</span></tt> must be local to the
  516. executing process.</p>
  517. <hr class="docutils" />
  518. <pre class="literal-block">
  519. vertices_size_type
  520. num_vertices(const adjacency_list&amp; g);
  521. </pre>
  522. <p>Returns the number of vertices in the graph <tt class="docutils literal"><span class="pre">g</span></tt> that are stored in
  523. the executing process.</p>
  524. <hr class="docutils" />
  525. <pre class="literal-block">
  526. edges_size_type
  527. num_edges(const adjacency_list&amp; g);
  528. </pre>
  529. <p>Returns the number of edges in the graph <tt class="docutils literal"><span class="pre">g</span></tt> that are stored in the
  530. executing process.</p>
  531. <hr class="docutils" />
  532. <pre class="literal-block">
  533. vertex_descriptor
  534. vertex(vertices_size_type n, const adjacency_list&amp; g);
  535. </pre>
  536. <p>Returns the <tt class="docutils literal"><span class="pre">n``th</span> <span class="pre">vertex</span> <span class="pre">in</span> <span class="pre">the</span> <span class="pre">graph's</span> <span class="pre">vertex</span> <span class="pre">list,</span> <span class="pre">according</span> <span class="pre">to</span> <span class="pre">the</span>
  537. <span class="pre">distribution</span> <span class="pre">used</span> <span class="pre">to</span> <span class="pre">partition</span> <span class="pre">the</span> <span class="pre">graph.</span> <span class="pre">``n</span></tt> must be a value
  538. between zero and the sum of <tt class="docutils literal"><span class="pre">num_vertices(g)</span></tt> in each process (minus
  539. one). Note that it is not necessarily the case that <tt class="docutils literal"><span class="pre">vertex(0,</span> <span class="pre">g)</span> <span class="pre">==</span>
  540. <span class="pre">*num_vertices(g).first</span></tt>. This function is only guaranteed to be
  541. accurate when no vertices have been added to or removed from the
  542. graph after its initial construction.</p>
  543. <hr class="docutils" />
  544. <pre class="literal-block">
  545. std::pair&lt;edge_descriptor, bool&gt;
  546. edge(vertex_descriptor u, vertex_descriptor v,
  547. const adjacency_list&amp; g);
  548. </pre>
  549. <p>Returns an edge connecting vertex <tt class="docutils literal"><span class="pre">u</span></tt> to vertex <tt class="docutils literal"><span class="pre">v</span></tt> in graph
  550. <tt class="docutils literal"><span class="pre">g</span></tt>. For bidirectional and undirected graphs, either vertex <tt class="docutils literal"><span class="pre">u</span></tt> or
  551. vertex <tt class="docutils literal"><span class="pre">v</span></tt> must be local; for directed graphs, vertex <tt class="docutils literal"><span class="pre">u</span></tt> must be
  552. local.</p>
  553. <hr class="docutils" />
  554. <pre class="literal-block">
  555. std::pair&lt;out_edge_iterator, out_edge_iterator&gt;
  556. edge_range(vertex_descriptor u, vertex_descriptor v,
  557. const adjacency_list&amp; g);
  558. </pre>
  559. <p>TODO: Not implemented. Returns a pair of out-edge iterators that give
  560. the range for all the parallel edges from <tt class="docutils literal"><span class="pre">u</span></tt> to <tt class="docutils literal"><span class="pre">v</span></tt>. This function only
  561. works when the <tt class="docutils literal"><span class="pre">OutEdgeList</span></tt> for the <tt class="docutils literal"><span class="pre">adjacency_list</span></tt> is a container that
  562. sorts the out edges according to target vertex, and allows for
  563. parallel edges. The <tt class="docutils literal"><span class="pre">multisetS</span></tt> selector chooses such a
  564. container. Vertex <tt class="docutils literal"><span class="pre">u</span></tt> must be stored in the executing process.</p>
  565. </div>
  566. <div class="section" id="structure-modification">
  567. <h2><a class="toc-backref" href="#id12">Structure Modification</a></h2>
  568. <pre class="literal-block">
  569. unspecified add_edge(vertex_descriptor u, vertex_descriptor v, adjacency_list&amp; g);
  570. unspecified add_edge(vertex_name_type u, vertex_descriptor v, adjacency_list&amp; g);
  571. unspecified add_edge(vertex_descriptor u, vertex_name_type v, adjacency_list&amp; g);
  572. unspecified add_edge(vertex_name_type u, vertex_name_type v, adjacency_list&amp; g);
  573. </pre>
  574. <p>Adds edge <tt class="docutils literal"><span class="pre">(u,v)</span></tt> to the graph. The return type itself is
  575. unspecified, but the type can be copy-constructed and implicitly
  576. converted into a <tt class="docutils literal"><span class="pre">std::pair&lt;edge_descriptor,bool&gt;</span></tt>. The edge
  577. descriptor describes the added (or found) edge. For graphs that do not
  578. allow parallel edges, if the edge
  579. is already in the graph then a duplicate will not be added and the
  580. <tt class="docutils literal"><span class="pre">bool</span></tt> flag will be <tt class="docutils literal"><span class="pre">false</span></tt>. Also, if u and v are descriptors for
  581. the same vertex (creating a self loop) and the graph is undirected,
  582. then the edge will not be added and the flag will be <tt class="docutils literal"><span class="pre">false</span></tt>. When
  583. the flag is <tt class="docutils literal"><span class="pre">false</span></tt>, the returned edge descriptor points to the
  584. already existing edge.</p>
  585. <p>The parameters <tt class="docutils literal"><span class="pre">u</span></tt> and <tt class="docutils literal"><span class="pre">v</span></tt> can be either vertex descriptors or, if
  586. the graph uses named vertices, the names of vertices. If no vertex
  587. with the given name exists, the internal vertex constructor will be
  588. invoked to create a new vertex property and a vertex with that
  589. property will be added to the graph implicitly. The default internal
  590. vertex constructor throws an exception.</p>
  591. <hr class="docutils" />
  592. <pre class="literal-block">
  593. unspecified add_edge(vertex_descriptor u, vertex_descriptor v, const EdgeProperties&amp; p, adjacency_list&amp; g);
  594. unspecified add_edge(vertex_name_type u, vertex_descriptor v, const EdgeProperties&amp; p, adjacency_list&amp; g);
  595. unspecified add_edge(vertex_descriptor u, vertex_name_type v, const EdgeProperties&amp; p, adjacency_list&amp; g);
  596. unspecified add_edge(vertex_name_type u, vertex_name_type v, const EdgeProperties&amp; p, adjacency_list&amp; g);
  597. </pre>
  598. <p>Adds edge <tt class="docutils literal"><span class="pre">(u,v)</span></tt> to the graph and attaches <tt class="docutils literal"><span class="pre">p</span></tt> as the value of the edge's
  599. internal property storage. See the previous <tt class="docutils literal"><span class="pre">add_edge()</span></tt> member
  600. function for more details.</p>
  601. <hr class="docutils" />
  602. <pre class="literal-block">
  603. void
  604. remove_edge(vertex_descriptor u, vertex_descriptor v,
  605. adjacency_list&amp; g);
  606. </pre>
  607. <p>Removes the edge <tt class="docutils literal"><span class="pre">(u,v)</span></tt> from the graph. If the directed selector is
  608. <tt class="docutils literal"><span class="pre">bidirectionalS</span></tt> or <tt class="docutils literal"><span class="pre">undirectedS</span></tt>, either the source or target
  609. vertex of the graph must be local. If the directed selector is
  610. <tt class="docutils literal"><span class="pre">directedS</span></tt>, then the source vertex must be local.</p>
  611. <hr class="docutils" />
  612. <pre class="literal-block">
  613. void
  614. remove_edge(edge_descriptor e, adjacency_list&amp; g);
  615. </pre>
  616. <p>Removes the edge <tt class="docutils literal"><span class="pre">e</span></tt> from the graph. If the directed selector is
  617. <tt class="docutils literal"><span class="pre">bidirectionalS</span></tt> or <tt class="docutils literal"><span class="pre">undirectedS</span></tt>, either the source or target
  618. vertex of the graph must be local. If the directed selector is
  619. <tt class="docutils literal"><span class="pre">directedS</span></tt>, then the source vertex must be local.</p>
  620. <hr class="docutils" />
  621. <pre class="literal-block">
  622. void remove_edge(out_edge_iterator iter, adjacency_list&amp; g);
  623. </pre>
  624. <p>This has the same effect as <tt class="docutils literal"><span class="pre">remove_edge(*iter,</span> <span class="pre">g)</span></tt>. For directed
  625. (but not bidirectional) graphs, this will be more efficient than
  626. <tt class="docutils literal"><span class="pre">remove_edge(*iter,</span> <span class="pre">g)</span></tt>.</p>
  627. <hr class="docutils" />
  628. <pre class="literal-block">
  629. template &lt;class Predicate &gt;
  630. void remove_out_edge_if(vertex_descriptor u, Predicate predicate,
  631. adjacency_list&amp; g);
  632. </pre>
  633. <p>Removes all out-edges of vertex <tt class="docutils literal"><span class="pre">u</span></tt> from the graph that satisfy the
  634. predicate. That is, if the predicate returns <tt class="docutils literal"><span class="pre">true</span></tt> when applied to an
  635. edge descriptor, then the edge is removed. The vertex <tt class="docutils literal"><span class="pre">u</span></tt> must be local.</p>
  636. <p>The affect on descriptor and iterator stability is the same as that of
  637. invoking remove_edge() on each of the removed edges.</p>
  638. <hr class="docutils" />
  639. <pre class="literal-block">
  640. template &lt;class Predicate &gt;
  641. void remove_in_edge_if(vertex_descriptor v, Predicate predicate,
  642. adjacency_list&amp; g);
  643. </pre>
  644. <p>Removes all in-edges of vertex <tt class="docutils literal"><span class="pre">v</span></tt> from the graph that satisfy the
  645. predicate. That is, if the predicate returns true when applied to an
  646. edge descriptor, then the edge is removed. The vertex <tt class="docutils literal"><span class="pre">v</span></tt> must be local.</p>
  647. <p>The affect on descriptor and iterator stability is the same as that of
  648. invoking <tt class="docutils literal"><span class="pre">remove_edge()</span></tt> on each of the removed edges.</p>
  649. <p>This operation is available for undirected and bidirectional
  650. adjacency_list graphs, but not for directed.</p>
  651. <hr class="docutils" />
  652. <pre class="literal-block">
  653. template &lt;class Predicate&gt;
  654. void remove_edge_if(Predicate predicate, adjacency_list&amp; g);
  655. </pre>
  656. <p>Removes all edges from the graph that satisfy the predicate. That is,
  657. if the predicate returns true when applied to an edge descriptor, then
  658. the edge is removed.</p>
  659. <p>The affect on descriptor and iterator stability is the same as that
  660. of invoking <tt class="docutils literal"><span class="pre">remove_edge()</span></tt> on each of the removed edges.</p>
  661. <hr class="docutils" />
  662. <pre class="literal-block">
  663. vertex_descriptor add_vertex(adjacency_list&amp; g);
  664. </pre>
  665. <p>Adds a vertex to the graph and returns the vertex descriptor for the
  666. new vertex. The vertex will be stored in the local process. This
  667. function is not available when using named vertices.</p>
  668. <hr class="docutils" />
  669. <pre class="literal-block">
  670. unspecified add_vertex(const VertexProperties&amp; p, adjacency_list&amp; g);
  671. unspecified add_vertex(const vertex_name_type&amp; p, adjacency_list&amp; g);
  672. </pre>
  673. <p>Adds a vertex to the graph with the specified properties. If the graph
  674. is using vertex names, the vertex will be added on whichever process
  675. &quot;owns&quot; that name. Otherwise, the vertex will be stored in the local
  676. process. Note that the second constructor will invoke the
  677. user-customizable internal vertex constructor, which (by default)
  678. throws an exception when it sees an unknown vertex.</p>
  679. <p>The return type is of unspecified type, but can be copy-constructed
  680. and can be implicitly converted into a vertex descriptor.</p>
  681. <hr class="docutils" />
  682. <pre class="literal-block">
  683. void clear_vertex(vertex_descriptor u, adjacency_list&amp; g);
  684. </pre>
  685. <p>Removes all edges to and from vertex <tt class="docutils literal"><span class="pre">u</span></tt>. The vertex still appears
  686. in the vertex set of the graph.</p>
  687. <p>The affect on descriptor and iterator stability is the same as that of
  688. invoking <tt class="docutils literal"><span class="pre">remove_edge()</span></tt> for all of the edges that have <tt class="docutils literal"><span class="pre">u</span></tt> as the source
  689. or target.</p>
  690. <p>This operation is not applicable to directed graphs, because the
  691. incoming edges to vertex <tt class="docutils literal"><span class="pre">u</span></tt> are not known.</p>
  692. <hr class="docutils" />
  693. <pre class="literal-block">
  694. void clear_out_edges(vertex_descriptor u, adjacency_list&amp; g);
  695. </pre>
  696. <p>Removes all out-edges from vertex <tt class="docutils literal"><span class="pre">u</span></tt>. The vertex still appears in
  697. the vertex set of the graph.</p>
  698. <p>The affect on descriptor and iterator stability is the same as that of
  699. invoking <tt class="docutils literal"><span class="pre">remove_edge()</span></tt> for all of the edges that have <tt class="docutils literal"><span class="pre">u</span></tt> as the
  700. source.</p>
  701. <p>This operation is not applicable to undirected graphs (use
  702. <tt class="docutils literal"><span class="pre">clear_vertex()</span></tt> instead).</p>
  703. <hr class="docutils" />
  704. <pre class="literal-block">
  705. void clear_in_edges(vertex_descriptor u, adjacency_list&amp; g);
  706. </pre>
  707. <p>Removes all in-edges from vertex <tt class="docutils literal"><span class="pre">u</span></tt>. The vertex still appears in
  708. the vertex set of the graph.</p>
  709. <p>The affect on descriptor and iterator stability is the same as that of
  710. invoking <tt class="docutils literal"><span class="pre">remove_edge()</span></tt> for all of the edges that have <tt class="docutils literal"><span class="pre">u</span></tt> as the
  711. target.</p>
  712. <p>This operation is only applicable to bidirectional graphs.</p>
  713. <hr class="docutils" />
  714. <pre class="literal-block">
  715. void remove_vertex(vertex_descriptor u, adjacency_list&amp; g);
  716. </pre>
  717. <p>Remove vertex <tt class="docutils literal"><span class="pre">u</span></tt> from the vertex set of the graph. It is assumed
  718. that there are no edges to or from vertex <tt class="docutils literal"><span class="pre">u</span></tt> when it is
  719. removed. One way to make sure of this is to invoke <tt class="docutils literal"><span class="pre">clear_vertex()</span></tt>
  720. beforehand. The vertex <tt class="docutils literal"><span class="pre">u</span></tt> must be stored locally.</p>
  721. </div>
  722. <div class="section" id="property-map-accessors">
  723. <h2><a class="toc-backref" href="#id13">Property Map Accessors</a></h2>
  724. <pre class="literal-block">
  725. template &lt;class PropertyTag&gt;
  726. property_map&lt;adjacency_list, PropertyTag&gt;::type
  727. get(PropertyTag, adjacency_list&amp; g);
  728. template &lt;class PropertyTag&gt;
  729. property_map&lt;adjacency_list, Tag&gt;::const_type
  730. get(PropertyTag, const adjacency_list&amp; g);
  731. </pre>
  732. <p>Returns the property map object for the vertex property specified by
  733. <tt class="docutils literal"><span class="pre">PropertyTag</span></tt>. The <tt class="docutils literal"><span class="pre">PropertyTag</span></tt> must match one of the properties
  734. specified in the graph's <tt class="docutils literal"><span class="pre">VertexProperty</span></tt> template argument. The
  735. returned property map will be a <a class="reference external" href="distributed_property_map.html">distributed property map</a>.</p>
  736. <hr class="docutils" />
  737. <pre class="literal-block">
  738. template &lt;class PropertyTag , class X&gt;
  739. typename property_traits&lt;property_map&lt;adjacency_list, PropertyTag&gt;::const_type&gt;::value_type
  740. get(PropertyTag, const adjacency_list&amp; g, X x);
  741. </pre>
  742. <p>This returns the property value for <tt class="docutils literal"><span class="pre">x</span></tt>, where <tt class="docutils literal"><span class="pre">x</span></tt> is either a vertex or
  743. edge descriptor. The entity referred to by descriptor <tt class="docutils literal"><span class="pre">x</span></tt> must be
  744. stored in the local process.</p>
  745. <hr class="docutils" />
  746. <pre class="literal-block">
  747. template &lt;class PropertyTag , class X, class Value&gt;
  748. void put(PropertyTag, const adjacency_list&amp; g, X x, const Value&amp; value);
  749. </pre>
  750. <p>This sets the property value for <tt class="docutils literal"><span class="pre">x</span></tt> to value. <tt class="docutils literal"><span class="pre">x</span></tt> is either a
  751. vertex or edge descriptor. <tt class="docutils literal"><span class="pre">Value</span></tt> must be convertible to <tt class="docutils literal"><span class="pre">typename</span>
  752. <span class="pre">property_traits&lt;property_map&lt;adjacency_list,</span>
  753. <span class="pre">PropertyTag&gt;::type&gt;::value_type</span></tt>.</p>
  754. <hr class="docutils" />
  755. <pre class="literal-block">
  756. template &lt;class GraphProperties, class GraphPropertyTag&gt;
  757. typename graph_property&lt;adjacency_list, GraphPropertyTag&gt;::type&amp;
  758. get_property(adjacency_list&amp; g, GraphPropertyTag);
  759. template &lt;class GraphProperties, class GraphPropertyTag &gt;
  760. const typename graph_property&lt;adjacency_list, GraphPropertyTag&gt;::type&amp;
  761. get_property(const adjacency_list&amp; g, GraphPropertyTag);
  762. </pre>
  763. <p>TODO: not implemented.</p>
  764. <p>Return the property specified by <tt class="docutils literal"><span class="pre">GraphPropertyTag</span></tt> that is attached
  765. to the graph object <tt class="docutils literal"><span class="pre">g</span></tt>. The <tt class="docutils literal"><span class="pre">graph_property</span></tt> traits class is
  766. defined in <tt class="docutils literal"><span class="pre">boost/graph/adjacency_list.hpp</span></tt>.</p>
  767. <hr class="docutils" />
  768. <p>Copyright (C) 2004 The Trustees of Indiana University.</p>
  769. <p>Copyright (C) 2007 Douglas Gregor</p>
  770. <p>Authors: Douglas Gregor and Andrew Lumsdaine</p>
  771. </div>
  772. </div>
  773. </div>
  774. <div class="footer">
  775. <hr class="footer" />
  776. Generated on: 2009-05-31 00:21 UTC.
  777. Generated by <a class="reference external" href="http://docutils.sourceforge.net/">Docutils</a> from <a class="reference external" href="http://docutils.sourceforge.net/rst.html">reStructuredText</a> source.
  778. </div>
  779. </body>
  780. </html>