betweenness_centrality.rst 9.9 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236
  1. .. Copyright (C) 2004-2009 The Trustees of Indiana University.
  2. Use, modification and distribution is subject to the Boost Software
  3. License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. http://www.boost.org/LICENSE_1_0.txt)
  5. =============================
  6. |Logo| Betweenness Centrality
  7. =============================
  8. ::
  9. // named parameter versions
  10. template<typename Graph, typename Param, typename Tag, typename Rest>
  11. void
  12. brandes_betweenness_centrality(const Graph& g,
  13. const bgl_named_params<Param,Tag,Rest>& params);
  14. template<typename Graph, typename CentralityMap>
  15. void
  16. brandes_betweenness_centrality(const Graph& g, CentralityMap centrality);
  17. template<typename Graph, typename CentralityMap, typename EdgeCentralityMap>
  18. void
  19. brandes_betweenness_centrality(const Graph& g, CentralityMap centrality,
  20. EdgeCentralityMap edge_centrality_map);
  21. // non-named parameter versions
  22. template<typename Graph, typename CentralityMap, typename EdgeCentralityMap,
  23. typename IncomingMap, typename DistanceMap, typename DependencyMap,
  24. typename PathCountMap, typename VertexIndexMap, typename Buffer>
  25. void
  26. brandes_betweenness_centrality(const Graph& g,
  27. CentralityMap centrality,
  28. EdgeCentralityMap edge_centrality_map,
  29. IncomingMap incoming,
  30. DistanceMap distance,
  31. DependencyMap dependency,
  32. PathCountMap path_count,
  33. VertexIndexMap vertex_index,
  34. Buffer sources,
  35. typename property_traits<DistanceMap>::value_type delta);
  36. template<typename Graph, typename CentralityMap, typename EdgeCentralityMap,
  37. typename IncomingMap, typename DistanceMap, typename DependencyMap,
  38. typename PathCountMap, typename VertexIndexMap, typename WeightMap,
  39. typename Buffer>
  40. void
  41. brandes_betweenness_centrality(const Graph& g,
  42. CentralityMap centrality,
  43. EdgeCentralityMap edge_centrality_map,
  44. IncomingMap incoming,
  45. DistanceMap distance,
  46. DependencyMap dependency,
  47. PathCountMap path_count,
  48. VertexIndexMap vertex_index,
  49. Buffer sources,
  50. typename property_traits<WeightMap>::value_type delta,
  51. WeightMap weight_map);
  52. // helper functions
  53. template<typename Graph, typename CentralityMap>
  54. typename property_traits<CentralityMap>::value_type
  55. central_point_dominance(const Graph& g, CentralityMap centrality);
  56. The ``brandes_betweenness_centrality()`` function computes the
  57. betweenness centrality of the vertices and edges in a graph. The
  58. method of calculating betweenness centrality in *O(V)* space is due to
  59. Brandes [Brandes01]_. The algorithm itself is a modification of
  60. Brandes algorithm by Edmonds [Edmonds09]_.
  61. .. contents::
  62. Where Defined
  63. -------------
  64. <``boost/graph/distributed/betweenness_centrality.hpp``>
  65. also accessible from
  66. <``boost/graph/betweenness_centrality.hpp``>
  67. Parameters
  68. ----------
  69. IN: ``const Graph& g``
  70. The graph type must be a model of `Distributed Graph`_. The graph
  71. type must also model the `Incidence Graph`_ concept. 0-weighted
  72. edges in ``g`` will result in undefined behavior.
  73. IN: ``CentralityMap centrality``
  74. A centrality map may be supplied to the algorithm, if not supplied a
  75. ``dummy_property_map`` will be used and no vertex centrality
  76. information will be recorded. The ``CentralityMap`` type must be a
  77. `Distributed Property Map`_. The key type must be the graph's
  78. vertex descriptor type.
  79. **Default**: A ``dummy_property_map``.
  80. IN: ``EdgeCentralityMap edge_centrality_map``
  81. An edge centrality map may be supplied to the algorithm, if not
  82. supplied a ``dummy_property_map`` will be used and no edge
  83. centrality information will be recorded. The ``EdgeCentralityMap``
  84. type must be a `Distributed Property Map`_. The key type must be
  85. the graph's vertex descriptor type.
  86. **Default**: A ``dummy_property_map``.
  87. IN: ``IncomingMap incoming``
  88. The incoming map contains the incoming edges to a vertex that are
  89. part of shortest paths to that vertex. The ``IncomingMap`` type
  90. must be a `Distributed Property Map`_. Its key type and value type
  91. must both be the graph's vertex descriptor type.
  92. **Default**: An ``iterator_property_map`` created from a
  93. ``std::vector`` of ``std::vector`` of the graph's vertex
  94. descriptor type.
  95. IN: ``DistanceMap distance``
  96. The distance map records the distance to vertices during the
  97. shortest paths portion of the algorithm. The ``DistanceMap`` type
  98. must be a `Distributed Property Map`_. Its key type must be the
  99. graph's vertex descriptor type.
  100. **Default**: An ``iterator_property_map`` created from a
  101. ``std::vector`` of the value type of the ``CentralityMap``.
  102. IN: ``DependencyMap dependency``
  103. The dependency map records the dependency of each vertex during the
  104. centrality calculation portion of the algorithm. The
  105. ``DependencyMap`` type must be a `Distributed Property Map`_. Its
  106. key type must be the graph's vertex descriptor type.
  107. **Default**: An ``iterator_property_map`` created from a
  108. ``std::vector`` of the value type of the ``CentralityMap``.
  109. IN: ``PathCountMap path_count``
  110. The path count map records the number of shortest paths each vertex
  111. is on during the centrality calculation portion of the algorithm.
  112. The ``PathCountMap`` type must be a `Distributed Property Map`_.
  113. Its key type must be the graph's vertex descriptor type.
  114. **Default**: An ``iterator_property_map`` created from a
  115. ``std::vector`` of the graph's degree size type.
  116. IN: ``VertexIndexMap vertex_index``
  117. A model of `Readable Property Map`_ whose key type is the vertex
  118. descriptor type of the graph ``g`` and whose value type is an
  119. integral type. The property map should map from vertices to their
  120. (local) indices in the range *[0, num_vertices(g))*.
  121. **Default**: ``get(vertex_index, g)``
  122. IN: ``WeightMap weight_map``
  123. A model of `Readable Property Map`_ whose key type is the edge
  124. descriptor type of the graph ``g``. If not supplied the betweenness
  125. centrality calculation will be unweighted.
  126. IN: ``Buffer sources``
  127. A model of Buffer_ containing the starting vertices for the
  128. algorithm. If ``sources`` is empty a complete betweenness
  129. centrality calculation using all vertices in ``g`` will be
  130. performed. The value type of the Buffer must be the graph's vertex
  131. descriptor type.
  132. **Default**: An empty ``boost::queue`` of int.
  133. Complexity
  134. ----------
  135. Computing the shortest paths, counting them, and computing the
  136. contribution to the centrality map is *O(V log V)*. Calculating exact
  137. betweenness centrality requires counting the shortest paths from all
  138. vertices in ``g``, thus exact betweenness centrality is *O(V^2 log
  139. V)*.
  140. Algorithm Description
  141. ---------------------
  142. For the vertices in ``sources`` (or all vertices in ``g`` when
  143. ``sources`` is empty) the algorithm first calls a customized
  144. implementation of delta_stepping_shortest_paths_ which maintains a
  145. shortest path tree using an ``IncomingMap``. The ``IncomingMap``
  146. contains the source of all incoming edges on shortest paths.
  147. The ``IncomingMap`` defines the shortest path DAG at the target of the
  148. edges in the shortest paths tree. In the bidirectional case edge
  149. flags could be used to translate the shortest paths information to the
  150. source of the edges. Setting edge flags during the shortest path
  151. computation rather than using an ``IncomingMap`` would result in
  152. adding an *O(V)* factor to the inner loop of the shortest paths
  153. computation to account for having to clear edge flags when a new
  154. shortest path is found. This would increase the complexity of the
  155. algorithm. Asymptotically, the current implementation is better,
  156. however using edge flags in the bidirectional case would reduce the
  157. number of supersteps required by the depth of the shortest paths DAG
  158. for each vertex. Currently an ``outgoing`` map is explicitly
  159. constructed by simply reversing the edges in the incoming map. Once
  160. the ``outgoing`` map is constructed it is traversed in dependency
  161. order from the source of the shortest paths calculation in order to
  162. compute path counts. Once path counts are computed the shortest paths
  163. DAG is again traversed in dependency order from the source to
  164. calculate the dependency and centrality of each vertex.
  165. The algorithm is complete when the centrality has been computed from
  166. all vertices in ``g``.
  167. Bibliography
  168. ------------
  169. .. [Brandes01] Ulrik Brandes. A Faster Algorithm for Betweenness
  170. Centrality. In the Journal of Mathematical Sociology, volume 25
  171. number 2, pages 163--177, 2001.
  172. .. [Edmonds09] Nick Edmonds, Torsten Hoefler, and Andrew Lumsdaine.
  173. A Space-Efficient Parallel Algorithm for Computing Betweenness
  174. Centrality in Sparse Networks. Indiana University tech report.
  175. 2009.
  176. -----------------------------------------------------------------------------
  177. Copyright (C) 2009 The Trustees of Indiana University.
  178. Authors: Nick Edmonds and Andrew Lumsdaine
  179. .. |Logo| image:: pbgl-logo.png
  180. :align: middle
  181. :alt: Parallel BGL
  182. :target: http://www.osl.iu.edu/research/pbgl
  183. .. _delta_stepping_shortest_paths: dijkstra_shortest_paths.html
  184. .. _Distributed Graph: DistributedGraph.html
  185. .. _Incidence Graph: http://www.boost.org/libs/graph/doc/IncidenceGraph.html
  186. .. _Readable Property Map: http://www.boost.org/libs/property_map/ReadablePropertyMap.html
  187. .. _Buffer: http://www.boost.org/libs/graph/doc/Buffer.html
  188. .. _Process Group: process_group.html
  189. .. _Distributed Property Map: distributed_property_map.html