non_distributed_betweenness_centrality.rst 9.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219
  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| Non-Distributed Betweenness Centrality
  7. =============================================
  8. ::
  9. // named parameter versions
  10. template<typename ProcessGroup, typename Graph, typename Param, typename Tag, typename Rest>
  11. void
  12. non_distributed_brandes_betweenness_centrality(const ProcessGroup& pg, const Graph& g,
  13. const bgl_named_params<Param,Tag,Rest>& params);
  14. template<typename ProcessGroup, typename Graph, typename CentralityMap,
  15. typename Buffer>
  16. void
  17. non_distributed_brandes_betweenness_centrality(const ProcessGroup& pg, const Graph& g,
  18. CentralityMap centrality, Buffer sources);
  19. template<typename ProcessGroup, typename Graph, typename CentralityMap,
  20. typename EdgeCentralityMap, typename Buffer>
  21. void
  22. non_distributed_brandes_betweenness_centrality(const ProcessGroup& pg, const Graph& g,
  23. CentralityMap centrality,
  24. EdgeCentralityMap edge_centrality_map,
  25. Buffer sources);
  26. // non-named parameter versions
  27. template<typename ProcessGroup, typename Graph, typename CentralityMap,
  28. typename EdgeCentralityMap, typename IncomingMap, typename DistanceMap,
  29. typename DependencyMap, typename PathCountMap, typename VertexIndexMap,
  30. typename Buffer>
  31. void
  32. non_distributed_brandes_betweenness_centrality(const ProcessGroup& pg,
  33. const Graph& g,
  34. CentralityMap centrality,
  35. EdgeCentralityMap edge_centrality_map,
  36. IncomingMap incoming,
  37. DistanceMap distance,
  38. DependencyMap dependency,
  39. PathCountMap path_count,
  40. VertexIndexMap vertex_index,
  41. Buffer sources);
  42. template<typename ProcessGroup, typename Graph, typename CentralityMap,
  43. typename EdgeCentralityMap, typename IncomingMap, typename DistanceMap,
  44. typename DependencyMap, typename PathCountMap, typename VertexIndexMap,
  45. typename WeightMap, typename Buffer>
  46. void
  47. non_distributed_brandes_betweenness_centrality(const ProcessGroup& pg,
  48. const Graph& g,
  49. CentralityMap centrality,
  50. EdgeCentralityMap edge_centrality_map,
  51. IncomingMap incoming,
  52. DistanceMap distance,
  53. DependencyMap dependency,
  54. PathCountMap path_count,
  55. VertexIndexMap vertex_index,
  56. WeightMap weight_map,
  57. Buffer sources);
  58. // helper functions
  59. template<typename Graph, typename CentralityMap>
  60. typename property_traits<CentralityMap>::value_type
  61. central_point_dominance(const Graph& g, CentralityMap centrality);
  62. The ``non_distributed_betweenness_centrality()`` function computes the
  63. betweenness centrality of the vertices and edges in a graph. The name
  64. is somewhat confusing, the graph ``g`` is not a distributed graph,
  65. however the algorithm does run in parallel. Rather than parallelizing
  66. the individual shortest paths calculations that are required by
  67. betweenness centrality, this variant of the algorithm performs the
  68. shortest paths calculations in parallel with each process in ``pg``
  69. calculating the shortest path from a different set of source vertices
  70. using the BGL's implementation of `Dijkstra shortest paths`_. Each
  71. process accumulates into it's local centrality map and once all the
  72. shortest paths calculations are performed a reduction is performed to
  73. combine the centrality from all the processes.
  74. .. contents::
  75. Where Defined
  76. -------------
  77. <``boost/graph/distributed/betweenness_centrality.hpp``>
  78. Parameters
  79. ----------
  80. IN: ``const ProcessGroup& pg``
  81. The process group over which the the processes involved in
  82. betweenness centrality communicate. The process group type must
  83. model the `Process Group`_ concept.
  84. IN: ``const Graph& g``
  85. The graph type must be a model of the `Incidence Graph`_ concept.
  86. IN: ``CentralityMap centrality``
  87. A centrality map may be supplied to the algorithm, if one is not
  88. supplied a ``dummy_property_map`` will be used and no vertex
  89. centrality information will be recorded. The key type of the
  90. ``CentralityMap`` must be the graph's vertex descriptor type.
  91. **Default**: A ``dummy_property_map``.
  92. IN: ``EdgeCentralityMap edge_centrality_map``
  93. An edge centrality map may be supplied to the algorithm, if one is
  94. not supplied a ``dummy_property_map`` will be used and no edge
  95. centrality information will be recorded. The key type of the
  96. ``EdgeCentralityMap`` must be the graph's vertex descriptor type.
  97. **Default**: A ``dummy_property_map``.
  98. IN: ``IncomingMap incoming``
  99. The incoming map contains the incoming edges to a vertex that are
  100. part of shortest paths to that vertex. Its key type must be the
  101. graph's vertex descriptor type and its value type must be the
  102. graph's edge descriptor type.
  103. **Default**: An ``iterator_property_map`` created from a
  104. ``std::vector`` of ``std::vector`` of the graph's edge descriptor
  105. type.
  106. IN: ``DistanceMap distance``
  107. The distance map records the distance to vertices during the
  108. shortest paths portion of the algorithm. Its key type must be the
  109. graph's vertex descriptor type.
  110. **Default**: An ``iterator_property_map`` created from a
  111. ``std::vector`` of the value type of the ``CentralityMap``.
  112. IN: ``DependencyMap dependency``
  113. The dependency map records the dependency of each vertex during the
  114. centrality calculation portion of the algorithm. Its key type must
  115. be the graph's vertex descriptor type.
  116. **Default**: An ``iterator_property_map`` created from a
  117. ``std::vector`` of the value type of the ``CentralityMap``.
  118. IN: ``PathCountMap path_count``
  119. The path count map records the number of shortest paths each vertex
  120. is on during the centrality calculation portion of the algorithm.
  121. Its key type must be the graph's vertex descriptor type.
  122. **Default**: An ``iterator_property_map`` created from a
  123. ``std::vector`` of the graph's degree size type.
  124. IN: ``VertexIndexMap vertex_index``
  125. A model of `Readable Property Map`_ whose key type is the vertex
  126. descriptor type of the graph ``g`` and whose value type is an
  127. integral type. The property map should map from vertices to their
  128. (local) indices in the range *[0, num_vertices(g))*.
  129. **Default**: ``get(vertex_index, g)``
  130. IN: ``WeightMap weight_map``
  131. A model of `Readable Property Map`_ whose key type is the edge
  132. descriptor type of the graph ``g``. If not supplied the betweenness
  133. centrality calculation will be unweighted.
  134. IN: ``Buffer sources``
  135. A model of Buffer_ containing the starting vertices for the
  136. algorithm. If ``sources`` is empty a complete betweenness
  137. centrality calculation using all vertices in ``g`` will be
  138. performed. The value type of the Buffer must be the graph's vertex
  139. descriptor type.
  140. **Default**: An empty ``boost::queue`` of int.
  141. Complexity
  142. ----------
  143. Each of the shortest paths calculations is *O(V log V)* and each of
  144. them may be run in parallel (one per process in ``pg``). The
  145. reduction phase to calculate the total centrality at the end of the
  146. shortest paths phase is *O(V log V)*.
  147. Algorithm Description
  148. ---------------------
  149. The algorithm uses a non-distributed (sequential) graph, as well as
  150. non-distributed property maps. Each process contains a separate copy
  151. of the sequential graph ``g``. In order for the algorithm to be
  152. correct, these copies of ``g`` must be identical. The ``sources``
  153. buffer contains the vertices to use as the source of single source
  154. shortest paths calculations when approximating betweenness centrality
  155. using a subset of the vertices in the graph. If ``sources`` is empty
  156. then a complete betweenness centrality calculation is performed using
  157. all vertices.
  158. In the sequential phase of the algorithm each process computes
  159. shortest paths from a subset of the vertices in the graph using the
  160. Brandes shortest paths methods from the BGL's betweenness centrality
  161. implementation. In the parallel phase of the algorithm a reduction is
  162. performed to sum the values computed by each process for all vertices
  163. in the graph.
  164. Either weighted or unweighted betweenness centrality is calculated
  165. depending on whether a ``WeightMap`` is passed.
  166. -----------------------------------------------------------------------------
  167. Copyright (C) 2009 The Trustees of Indiana University.
  168. Authors: Nick Edmonds and Andrew Lumsdaine
  169. .. |Logo| image:: pbgl-logo.png
  170. :align: middle
  171. :alt: Parallel BGL
  172. :target: http://www.osl.iu.edu/research/pbgl
  173. .. _Process Group: process_group.html
  174. .. _Buffer: http://www.boost.org/libs/graph/doc/Buffer.html
  175. .. _Dijkstra shortest paths: http://www.boost.org/libs/graph/doc/dijkstra_shortest_paths.html
  176. .. _Readable Property Map: http://www.boost.org/libs/property_map/ReadablePropertyMap.html
  177. .. _Incidence Graph: http://www.boost.org/libs/graph/doc/IncidenceGraph.html