betweenness_centrality.html 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248
  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 Betweenness Centrality</title>
  8. <link rel="stylesheet" href="../../../../rst.css" type="text/css" />
  9. </head>
  10. <body>
  11. <div class="document" id="logo-betweenness-centrality">
  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> Betweenness Centrality</h1>
  13. <!-- Copyright (C) 2004-2009 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. <pre class="literal-block">
  18. // named parameter versions
  19. template&lt;typename Graph, typename Param, typename Tag, typename Rest&gt;
  20. void
  21. brandes_betweenness_centrality(const Graph&amp; g,
  22. const bgl_named_params&lt;Param,Tag,Rest&gt;&amp; params);
  23. template&lt;typename Graph, typename CentralityMap&gt;
  24. void
  25. brandes_betweenness_centrality(const Graph&amp; g, CentralityMap centrality);
  26. template&lt;typename Graph, typename CentralityMap, typename EdgeCentralityMap&gt;
  27. void
  28. brandes_betweenness_centrality(const Graph&amp; g, CentralityMap centrality,
  29. EdgeCentralityMap edge_centrality_map);
  30. // non-named parameter versions
  31. template&lt;typename Graph, typename CentralityMap, typename EdgeCentralityMap,
  32. typename IncomingMap, typename DistanceMap, typename DependencyMap,
  33. typename PathCountMap, typename VertexIndexMap, typename Buffer&gt;
  34. void
  35. brandes_betweenness_centrality(const Graph&amp; g,
  36. CentralityMap centrality,
  37. EdgeCentralityMap edge_centrality_map,
  38. IncomingMap incoming,
  39. DistanceMap distance,
  40. DependencyMap dependency,
  41. PathCountMap path_count,
  42. VertexIndexMap vertex_index,
  43. Buffer sources,
  44. typename property_traits&lt;DistanceMap&gt;::value_type delta);
  45. template&lt;typename Graph, typename CentralityMap, typename EdgeCentralityMap,
  46. typename IncomingMap, typename DistanceMap, typename DependencyMap,
  47. typename PathCountMap, typename VertexIndexMap, typename WeightMap,
  48. typename Buffer&gt;
  49. void
  50. brandes_betweenness_centrality(const Graph&amp; g,
  51. CentralityMap centrality,
  52. EdgeCentralityMap edge_centrality_map,
  53. IncomingMap incoming,
  54. DistanceMap distance,
  55. DependencyMap dependency,
  56. PathCountMap path_count,
  57. VertexIndexMap vertex_index,
  58. Buffer sources,
  59. typename property_traits&lt;WeightMap&gt;::value_type delta,
  60. WeightMap weight_map);
  61. // helper functions
  62. template&lt;typename Graph, typename CentralityMap&gt;
  63. typename property_traits&lt;CentralityMap&gt;::value_type
  64. central_point_dominance(const Graph&amp; g, CentralityMap centrality);
  65. </pre>
  66. <p>The <tt class="docutils literal"><span class="pre">brandes_betweenness_centrality()</span></tt> function computes the
  67. betweenness centrality of the vertices and edges in a graph. The
  68. method of calculating betweenness centrality in <em>O(V)</em> space is due to
  69. Brandes <a class="citation-reference" href="#brandes01" id="id1">[Brandes01]</a>. The algorithm itself is a modification of
  70. Brandes algorithm by Edmonds <a class="citation-reference" href="#edmonds09" id="id2">[Edmonds09]</a>.</p>
  71. <div class="contents topic" id="contents">
  72. <p class="topic-title first">Contents</p>
  73. <ul class="simple">
  74. <li><a class="reference internal" href="#where-defined" id="id3">Where Defined</a></li>
  75. <li><a class="reference internal" href="#parameters" id="id4">Parameters</a></li>
  76. <li><a class="reference internal" href="#complexity" id="id5">Complexity</a></li>
  77. <li><a class="reference internal" href="#algorithm-description" id="id6">Algorithm Description</a></li>
  78. <li><a class="reference internal" href="#bibliography" id="id7">Bibliography</a></li>
  79. </ul>
  80. </div>
  81. <div class="section" id="where-defined">
  82. <h1><a class="toc-backref" href="#id3">Where Defined</a></h1>
  83. <p>&lt;<tt class="docutils literal"><span class="pre">boost/graph/distributed/betweenness_centrality.hpp</span></tt>&gt;</p>
  84. <p>also accessible from</p>
  85. <p>&lt;<tt class="docutils literal"><span class="pre">boost/graph/betweenness_centrality.hpp</span></tt>&gt;</p>
  86. </div>
  87. <div class="section" id="parameters">
  88. <h1><a class="toc-backref" href="#id4">Parameters</a></h1>
  89. <dl class="docutils">
  90. <dt>IN: <tt class="docutils literal"><span class="pre">const</span> <span class="pre">Graph&amp;</span> <span class="pre">g</span></tt></dt>
  91. <dd>The graph type must be a model of <a class="reference external" href="DistributedGraph.html">Distributed Graph</a>. The graph
  92. type must also model the <a class="reference external" href="http://www.boost.org/libs/graph/doc/IncidenceGraph.html">Incidence Graph</a> concept. 0-weighted
  93. edges in <tt class="docutils literal"><span class="pre">g</span></tt> will result in undefined behavior.</dd>
  94. <dt>IN: <tt class="docutils literal"><span class="pre">CentralityMap</span> <span class="pre">centrality</span></tt></dt>
  95. <dd><p class="first">A centrality map may be supplied to the algorithm, if not supplied a
  96. <tt class="docutils literal"><span class="pre">dummy_property_map</span></tt> will be used and no vertex centrality
  97. information will be recorded. The <tt class="docutils literal"><span class="pre">CentralityMap</span></tt> type must be a
  98. <a class="reference external" href="distributed_property_map.html">Distributed Property Map</a>. The key type must be the graph's
  99. vertex descriptor type.</p>
  100. <p class="last"><strong>Default</strong>: A <tt class="docutils literal"><span class="pre">dummy_property_map</span></tt>.</p>
  101. </dd>
  102. <dt>IN: <tt class="docutils literal"><span class="pre">EdgeCentralityMap</span> <span class="pre">edge_centrality_map</span></tt></dt>
  103. <dd><p class="first">An edge centrality map may be supplied to the algorithm, if not
  104. supplied a <tt class="docutils literal"><span class="pre">dummy_property_map</span></tt> will be used and no edge
  105. centrality information will be recorded. The <tt class="docutils literal"><span class="pre">EdgeCentralityMap</span></tt>
  106. type must be a <a class="reference external" href="distributed_property_map.html">Distributed Property Map</a>. The key type must be
  107. the graph's vertex descriptor type.</p>
  108. <p class="last"><strong>Default</strong>: A <tt class="docutils literal"><span class="pre">dummy_property_map</span></tt>.</p>
  109. </dd>
  110. <dt>IN: <tt class="docutils literal"><span class="pre">IncomingMap</span> <span class="pre">incoming</span></tt></dt>
  111. <dd><p class="first">The incoming map contains the incoming edges to a vertex that are
  112. part of shortest paths to that vertex. The <tt class="docutils literal"><span class="pre">IncomingMap</span></tt> type
  113. must be a <a class="reference external" href="distributed_property_map.html">Distributed Property Map</a>. Its key type and value type
  114. must both be the graph's vertex descriptor type.</p>
  115. <dl class="last docutils">
  116. <dt><strong>Default</strong>: An <tt class="docutils literal"><span class="pre">iterator_property_map</span></tt> created from a</dt>
  117. <dd><tt class="docutils literal"><span class="pre">std::vector</span></tt> of <tt class="docutils literal"><span class="pre">std::vector</span></tt> of the graph's vertex
  118. descriptor type.</dd>
  119. </dl>
  120. </dd>
  121. <dt>IN: <tt class="docutils literal"><span class="pre">DistanceMap</span> <span class="pre">distance</span></tt></dt>
  122. <dd><p class="first">The distance map records the distance to vertices during the
  123. shortest paths portion of the algorithm. The <tt class="docutils literal"><span class="pre">DistanceMap</span></tt> type
  124. must be a <a class="reference external" href="distributed_property_map.html">Distributed Property Map</a>. Its key type must be the
  125. graph's vertex descriptor type.</p>
  126. <dl class="last docutils">
  127. <dt><strong>Default</strong>: An <tt class="docutils literal"><span class="pre">iterator_property_map</span></tt> created from a</dt>
  128. <dd><tt class="docutils literal"><span class="pre">std::vector</span></tt> of the value type of the <tt class="docutils literal"><span class="pre">CentralityMap</span></tt>.</dd>
  129. </dl>
  130. </dd>
  131. <dt>IN: <tt class="docutils literal"><span class="pre">DependencyMap</span> <span class="pre">dependency</span></tt></dt>
  132. <dd><p class="first">The dependency map records the dependency of each vertex during the
  133. centrality calculation portion of the algorithm. The
  134. <tt class="docutils literal"><span class="pre">DependencyMap</span></tt> type must be a <a class="reference external" href="distributed_property_map.html">Distributed Property Map</a>. Its
  135. key type must be the graph's vertex descriptor type.</p>
  136. <dl class="last docutils">
  137. <dt><strong>Default</strong>: An <tt class="docutils literal"><span class="pre">iterator_property_map</span></tt> created from a</dt>
  138. <dd><tt class="docutils literal"><span class="pre">std::vector</span></tt> of the value type of the <tt class="docutils literal"><span class="pre">CentralityMap</span></tt>.</dd>
  139. </dl>
  140. </dd>
  141. </dl>
  142. <p>IN: <tt class="docutils literal"><span class="pre">PathCountMap</span> <span class="pre">path_count</span></tt></p>
  143. <blockquote>
  144. <p>The path count map records the number of shortest paths each vertex
  145. is on during the centrality calculation portion of the algorithm.
  146. The <tt class="docutils literal"><span class="pre">PathCountMap</span></tt> type must be a <a class="reference external" href="distributed_property_map.html">Distributed Property Map</a>.
  147. Its key type must be the graph's vertex descriptor type.</p>
  148. <dl class="docutils">
  149. <dt><strong>Default</strong>: An <tt class="docutils literal"><span class="pre">iterator_property_map</span></tt> created from a</dt>
  150. <dd><tt class="docutils literal"><span class="pre">std::vector</span></tt> of the graph's degree size type.</dd>
  151. </dl>
  152. </blockquote>
  153. <dl class="docutils">
  154. <dt>IN: <tt class="docutils literal"><span class="pre">VertexIndexMap</span> <span class="pre">vertex_index</span></tt></dt>
  155. <dd><p class="first">A model of <a class="reference external" href="http://www.boost.org/libs/property_map/ReadablePropertyMap.html">Readable Property Map</a> whose key type is the vertex
  156. descriptor type of the graph <tt class="docutils literal"><span class="pre">g</span></tt> and whose value type is an
  157. integral type. The property map should map from vertices to their
  158. (local) indices in the range <em>[0, num_vertices(g))</em>.</p>
  159. <p class="last"><strong>Default</strong>: <tt class="docutils literal"><span class="pre">get(vertex_index,</span> <span class="pre">g)</span></tt></p>
  160. </dd>
  161. <dt>IN: <tt class="docutils literal"><span class="pre">WeightMap</span> <span class="pre">weight_map</span></tt></dt>
  162. <dd>A model of <a class="reference external" href="http://www.boost.org/libs/property_map/ReadablePropertyMap.html">Readable Property Map</a> whose key type is the edge
  163. descriptor type of the graph <tt class="docutils literal"><span class="pre">g</span></tt>. If not supplied the betweenness
  164. centrality calculation will be unweighted.</dd>
  165. <dt>IN: <tt class="docutils literal"><span class="pre">Buffer</span> <span class="pre">sources</span></tt></dt>
  166. <dd><p class="first">A model of <a class="reference external" href="http://www.boost.org/libs/graph/doc/Buffer.html">Buffer</a> containing the starting vertices for the
  167. algorithm. If <tt class="docutils literal"><span class="pre">sources</span></tt> is empty a complete betweenness
  168. centrality calculation using all vertices in <tt class="docutils literal"><span class="pre">g</span></tt> will be
  169. performed. The value type of the Buffer must be the graph's vertex
  170. descriptor type.</p>
  171. <p class="last"><strong>Default</strong>: An empty <tt class="docutils literal"><span class="pre">boost::queue</span></tt> of int.</p>
  172. </dd>
  173. </dl>
  174. </div>
  175. <div class="section" id="complexity">
  176. <h1><a class="toc-backref" href="#id5">Complexity</a></h1>
  177. <p>Computing the shortest paths, counting them, and computing the
  178. contribution to the centrality map is <em>O(V log V)</em>. Calculating exact
  179. betweenness centrality requires counting the shortest paths from all
  180. vertices in <tt class="docutils literal"><span class="pre">g</span></tt>, thus exact betweenness centrality is <em>O(V^2 log
  181. V)</em>.</p>
  182. </div>
  183. <div class="section" id="algorithm-description">
  184. <h1><a class="toc-backref" href="#id6">Algorithm Description</a></h1>
  185. <p>For the vertices in <tt class="docutils literal"><span class="pre">sources</span></tt> (or all vertices in <tt class="docutils literal"><span class="pre">g</span></tt> when
  186. <tt class="docutils literal"><span class="pre">sources</span></tt> is empty) the algorithm first calls a customized
  187. implementation of <a class="reference external" href="dijkstra_shortest_paths.html">delta_stepping_shortest_paths</a> which maintains a
  188. shortest path tree using an <tt class="docutils literal"><span class="pre">IncomingMap</span></tt>. The <tt class="docutils literal"><span class="pre">IncomingMap</span></tt>
  189. contains the source of all incoming edges on shortest paths.</p>
  190. <p>The <tt class="docutils literal"><span class="pre">IncomingMap</span></tt> defines the shortest path DAG at the target of the
  191. edges in the shortest paths tree. In the bidirectional case edge
  192. flags could be used to translate the shortest paths information to the
  193. source of the edges. Setting edge flags during the shortest path
  194. computation rather than using an <tt class="docutils literal"><span class="pre">IncomingMap</span></tt> would result in
  195. adding an <em>O(V)</em> factor to the inner loop of the shortest paths
  196. computation to account for having to clear edge flags when a new
  197. shortest path is found. This would increase the complexity of the
  198. algorithm. Asymptotically, the current implementation is better,
  199. however using edge flags in the bidirectional case would reduce the
  200. number of supersteps required by the depth of the shortest paths DAG
  201. for each vertex. Currently an <tt class="docutils literal"><span class="pre">outgoing</span></tt> map is explicitly
  202. constructed by simply reversing the edges in the incoming map. Once
  203. the <tt class="docutils literal"><span class="pre">outgoing</span></tt> map is constructed it is traversed in dependency
  204. order from the source of the shortest paths calculation in order to
  205. compute path counts. Once path counts are computed the shortest paths
  206. DAG is again traversed in dependency order from the source to
  207. calculate the dependency and centrality of each vertex.</p>
  208. <p>The algorithm is complete when the centrality has been computed from
  209. all vertices in <tt class="docutils literal"><span class="pre">g</span></tt>.</p>
  210. </div>
  211. <div class="section" id="bibliography">
  212. <h1><a class="toc-backref" href="#id7">Bibliography</a></h1>
  213. <table class="docutils citation" frame="void" id="brandes01" rules="none">
  214. <colgroup><col class="label" /><col /></colgroup>
  215. <tbody valign="top">
  216. <tr><td class="label"><a class="fn-backref" href="#id1">[Brandes01]</a></td><td>Ulrik Brandes. A Faster Algorithm for Betweenness
  217. Centrality. In the Journal of Mathematical Sociology, volume 25
  218. number 2, pages 163--177, 2001.</td></tr>
  219. </tbody>
  220. </table>
  221. <table class="docutils citation" frame="void" id="edmonds09" rules="none">
  222. <colgroup><col class="label" /><col /></colgroup>
  223. <tbody valign="top">
  224. <tr><td class="label"><a class="fn-backref" href="#id2">[Edmonds09]</a></td><td>Nick Edmonds, Torsten Hoefler, and Andrew Lumsdaine.
  225. A Space-Efficient Parallel Algorithm for Computing Betweenness
  226. Centrality in Sparse Networks. Indiana University tech report.
  227. 2009.</td></tr>
  228. </tbody>
  229. </table>
  230. <hr class="docutils" />
  231. <p>Copyright (C) 2009 The Trustees of Indiana University.</p>
  232. <p>Authors: Nick Edmonds and Andrew Lumsdaine</p>
  233. </div>
  234. </div>
  235. <div class="footer">
  236. <hr class="footer" />
  237. Generated on: 2009-05-31 00:21 UTC.
  238. 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.
  239. </div>
  240. </body>
  241. </html>