File: betweenness_centrality.rst

package info (click to toggle)
boost1.55 1.55.0%2Bdfsg-3
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 487,824 kB
  • ctags: 673,349
  • sloc: cpp: 2,098,430; xml: 106,036; ansic: 46,744; python: 32,427; sh: 11,864; cs: 2,121; asm: 1,640; makefile: 984; perl: 714; yacc: 456; php: 132; fortran: 43; sql: 13; csh: 6
file content (236 lines) | stat: -rw-r--r-- 10,127 bytes parent folder | download | duplicates (13)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
.. Copyright (C) 2004-2009 The Trustees of Indiana University.
   Use, modification and distribution is subject to the Boost Software
   License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
   http://www.boost.org/LICENSE_1_0.txt)

=============================
|Logo| Betweenness Centrality
=============================

::

  // named parameter versions
  template<typename Graph, typename Param, typename Tag, typename Rest>
  void 
  brandes_betweenness_centrality(const Graph& g, 
                                 const bgl_named_params<Param,Tag,Rest>& params);

  template<typename Graph, typename CentralityMap>
  void 
  brandes_betweenness_centrality(const Graph& g, CentralityMap centrality);

  template<typename Graph, typename CentralityMap, typename EdgeCentralityMap>
  void 
  brandes_betweenness_centrality(const Graph& g, CentralityMap centrality,
                                 EdgeCentralityMap edge_centrality_map);

  // non-named parameter versions
  template<typename Graph, typename CentralityMap, typename EdgeCentralityMap,
           typename IncomingMap, typename DistanceMap, typename DependencyMap, 
           typename PathCountMap, typename VertexIndexMap, typename Buffer>
  void  
  brandes_betweenness_centrality(const Graph& g, 
                                 CentralityMap centrality,
                                 EdgeCentralityMap edge_centrality_map,
                                 IncomingMap incoming, 
                                 DistanceMap distance, 
                                 DependencyMap dependency,     
                                 PathCountMap path_count,   
                                 VertexIndexMap vertex_index,
                                 Buffer sources,
                                 typename property_traits<DistanceMap>::value_type delta);

  template<typename Graph, typename CentralityMap, typename EdgeCentralityMap, 
           typename IncomingMap, typename DistanceMap, typename DependencyMap, 
           typename PathCountMap, typename VertexIndexMap, typename WeightMap, 
           typename Buffer>    
  void 
  brandes_betweenness_centrality(const Graph& g, 
                                 CentralityMap centrality,
                                 EdgeCentralityMap edge_centrality_map,
                                 IncomingMap incoming, 
                                 DistanceMap distance, 
                                 DependencyMap dependency,
                                 PathCountMap path_count, 
                                 VertexIndexMap vertex_index,
                                 Buffer sources,
                                 typename property_traits<WeightMap>::value_type delta,
                                 WeightMap weight_map);

  // helper functions
  template<typename Graph, typename CentralityMap>
  typename property_traits<CentralityMap>::value_type
  central_point_dominance(const Graph& g, CentralityMap centrality);

The ``brandes_betweenness_centrality()`` function computes the
betweenness centrality of the vertices and edges in a graph.  The
method of calculating betweenness centrality in *O(V)* space is due to
Brandes [Brandes01]_.  The algorithm itself is a modification of
Brandes algorithm by Edmonds [Edmonds09]_.

.. contents::

Where Defined
-------------
<``boost/graph/distributed/betweenness_centrality.hpp``>

also accessible from

<``boost/graph/betweenness_centrality.hpp``>

Parameters
----------

IN:  ``const Graph& g``
  The graph type must be a model of `Distributed Graph`_.  The graph
  type must also model the `Incidence Graph`_ concept.  0-weighted
  edges in ``g`` will result in undefined behavior.

IN: ``CentralityMap centrality`` 
  A centrality map may be supplied to the algorithm, if not supplied a
  ``dummy_property_map`` will be used and no vertex centrality
  information will be recorded.  The ``CentralityMap`` type must be a
  `Distributed Property Map`_.  The key type must be the graph's
  vertex descriptor type.

  **Default**: A ``dummy_property_map``.

IN:  ``EdgeCentralityMap edge_centrality_map``
  An edge centrality map may be supplied to the algorithm, if not
  supplied a ``dummy_property_map`` will be used and no edge
  centrality information will be recorded.  The ``EdgeCentralityMap``
  type must be a `Distributed Property Map`_.  The key type must be
  the graph's vertex descriptor type.

  **Default**: A ``dummy_property_map``.

IN:  ``IncomingMap incoming``
  The incoming map contains the incoming edges to a vertex that are
  part of shortest paths to that vertex.  The ``IncomingMap`` type
  must be a `Distributed Property Map`_.  Its key type and value type
  must both be the graph's vertex descriptor type.

  **Default**: An ``iterator_property_map`` created from a
    ``std::vector`` of ``std::vector`` of the graph's vertex
    descriptor type.

IN:  ``DistanceMap distance``
  The distance map records the distance to vertices during the
  shortest paths portion of the algorithm.  The ``DistanceMap`` type
  must be a `Distributed Property Map`_.  Its key type must be the
  graph's vertex descriptor type.

  **Default**: An ``iterator_property_map`` created from a
    ``std::vector`` of the value type of the ``CentralityMap``.

IN: ``DependencyMap dependency`` 
  The dependency map records the dependency of each vertex during the
  centrality calculation portion of the algorithm.  The
  ``DependencyMap`` type must be a `Distributed Property Map`_.  Its
  key type must be the graph's vertex descriptor type.

  **Default**: An ``iterator_property_map`` created from a
    ``std::vector`` of the value type of the ``CentralityMap``.

IN:  ``PathCountMap path_count``

  The path count map records the number of shortest paths each vertex
  is on during the centrality calculation portion of the algorithm.
  The ``PathCountMap`` type must be a `Distributed Property Map`_.
  Its key type must be the graph's vertex descriptor type.

  **Default**: An ``iterator_property_map`` created from a
    ``std::vector`` of the graph's degree size type.

IN:  ``VertexIndexMap vertex_index``
  A model of `Readable Property Map`_ whose key type is the vertex
  descriptor type of the graph ``g`` and whose value type is an
  integral type. The property map should map from vertices to their
  (local) indices in the range *[0, num_vertices(g))*.

  **Default**: ``get(vertex_index, g)``

IN:  ``WeightMap weight_map``
  A model of `Readable Property Map`_ whose key type is the edge
  descriptor type of the graph ``g``.  If not supplied the betweenness
  centrality calculation will be unweighted.

IN: ``Buffer sources`` 
  A model of Buffer_ containing the starting vertices for the
  algorithm.  If ``sources`` is empty a complete betweenness
  centrality calculation using all vertices in ``g`` will be
  performed.  The value type of the Buffer must be the graph's vertex
  descriptor type.

  **Default**: An empty ``boost::queue`` of int.

Complexity
----------

Computing the shortest paths, counting them, and computing the
contribution to the centrality map is *O(V log V)*.  Calculating exact
betweenness centrality requires counting the shortest paths from all
vertices in ``g``, thus exact betweenness centrality is *O(V^2 log
V)*.

Algorithm Description
---------------------

For the vertices in ``sources`` (or all vertices in ``g`` when
``sources`` is empty) the algorithm first calls a customized
implementation of delta_stepping_shortest_paths_ which maintains a
shortest path tree using an ``IncomingMap``.  The ``IncomingMap``
contains the source of all incoming edges on shortest paths.

The ``IncomingMap`` defines the shortest path DAG at the target of the
edges in the shortest paths tree.  In the bidirectional case edge
flags could be used to translate the shortest paths information to the
source of the edges.  Setting edge flags during the shortest path
computation rather than using an ``IncomingMap`` would result in
adding an *O(V)* factor to the inner loop of the shortest paths
computation to account for having to clear edge flags when a new
shortest path is found.  This would increase the complexity of the
algorithm.  Asymptotically, the current implementation is better,
however using edge flags in the bidirectional case would reduce the
number of supersteps required by the depth of the shortest paths DAG
for each vertex.  Currently an ``outgoing`` map is explicitly
constructed by simply reversing the edges in the incoming map.  Once
the ``outgoing`` map is constructed it is traversed in dependency
order from the source of the shortest paths calculation in order to
compute path counts.  Once path counts are computed the shortest paths
DAG is again traversed in dependency order from the source to
calculate the dependency and centrality of each vertex.

The algorithm is complete when the centrality has been computed from
all vertices in ``g``.

Bibliography
------------

.. [Brandes01] Ulrik Brandes.  A Faster Algorithm for Betweenness
  Centrality. In the Journal of Mathematical Sociology, volume 25
  number 2, pages 163--177, 2001.

.. [Edmonds09] Nick Edmonds, Torsten Hoefler, and Andrew Lumsdaine.
  A Space-Efficient Parallel Algorithm for Computing Betweenness
  Centrality in Sparse Networks.  Indiana University tech report.
  2009.

-----------------------------------------------------------------------------

Copyright (C) 2009 The Trustees of Indiana University.

Authors: Nick Edmonds and Andrew Lumsdaine

.. |Logo| image:: pbgl-logo.png
            :align: middle
            :alt: Parallel BGL
            :target: http://www.osl.iu.edu/research/pbgl

.. _delta_stepping_shortest_paths: dijkstra_shortest_paths.html
.. _Distributed Graph: DistributedGraph.html
.. _Incidence Graph: http://www.boost.org/libs/graph/doc/IncidenceGraph.html
.. _Readable Property Map: http://www.boost.org/libs/property_map/ReadablePropertyMap.html
.. _Buffer: http://www.boost.org/libs/graph/doc/Buffer.html
.. _Process Group: process_group.html
.. _Distributed Property Map: distributed_property_map.html