File: non_distributed_betweenness_centrality.rst

package info (click to toggle)
boost1.88 1.88.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 576,932 kB
  • sloc: cpp: 4,149,234; xml: 136,789; ansic: 35,092; python: 33,910; asm: 5,698; sh: 4,604; ada: 1,681; makefile: 1,633; pascal: 1,139; perl: 1,124; sql: 640; yacc: 478; ruby: 271; java: 77; lisp: 24; csh: 6
file content (219 lines) | stat: -rw-r--r-- 10,078 bytes parent folder | download | duplicates (12)
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
.. 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| Non-Distributed Betweenness Centrality
=============================================

::

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

  template<typename ProcessGroup, typename Graph, typename CentralityMap, 
           typename Buffer>
  void 
  non_distributed_brandes_betweenness_centrality(const ProcessGroup& pg, const Graph& g, 
                                                 CentralityMap centrality, Buffer sources);

  template<typename ProcessGroup, typename Graph, typename CentralityMap, 
           typename EdgeCentralityMap, typename Buffer>
  void 
  non_distributed_brandes_betweenness_centrality(const ProcessGroup& pg, const Graph& g, 
                                                 CentralityMap centrality,
                                                 EdgeCentralityMap edge_centrality_map, 
                                                 Buffer sources);

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

  template<typename ProcessGroup, typename Graph, typename CentralityMap, 
           typename EdgeCentralityMap, typename IncomingMap, typename DistanceMap, 
           typename DependencyMap, typename PathCountMap, typename VertexIndexMap, 
           typename WeightMap, typename Buffer>
  void 
  non_distributed_brandes_betweenness_centrality(const ProcessGroup& pg,
                                                 const Graph& g, 
                                                 CentralityMap centrality,
                                                 EdgeCentralityMap edge_centrality_map,
                                                 IncomingMap incoming, 
                                                 DistanceMap distance, 
                                                 DependencyMap dependency,
                                                 PathCountMap path_count, 
                                                 VertexIndexMap vertex_index,
                                                 WeightMap weight_map,
                                                 Buffer sources);

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

The ``non_distributed_betweenness_centrality()`` function computes the
betweenness centrality of the vertices and edges in a graph.  The name
is somewhat confusing, the graph ``g`` is not a distributed graph,
however the algorithm does run in parallel.  Rather than parallelizing
the individual shortest paths calculations that are required by
betweenness centrality, this variant of the algorithm performs the
shortest paths calculations in parallel with each process in ``pg``
calculating the shortest path from a different set of source vertices
using the BGL's implementation of `Dijkstra shortest paths`_.  Each
process accumulates into it's local centrality map and once all the
shortest paths calculations are performed a reduction is performed to
combine the centrality from all the processes.

.. contents::

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

Parameters
----------

IN: ``const ProcessGroup& pg`` 
  The process group over which the the processes involved in
  betweenness centrality communicate.  The process group type must
  model the `Process Group`_ concept.

IN: ``const Graph& g`` 
  The graph type must be a model of the `Incidence Graph`_ concept.

IN: ``CentralityMap centrality`` 
  A centrality map may be supplied to the algorithm, if one is not
  supplied a ``dummy_property_map`` will be used and no vertex
  centrality information will be recorded.  The key type of the
  ``CentralityMap`` 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 one is
  not supplied a ``dummy_property_map`` will be used and no edge
  centrality information will be recorded.  The key type of the
  ``EdgeCentralityMap`` 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.  Its key type must be the
  graph's vertex descriptor type and its value type must be the
  graph's edge descriptor type.

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

IN:  ``DistanceMap distance``
  The distance map records the distance to vertices during the
  shortest paths portion of the algorithm.  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.  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.
  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
----------

Each of the shortest paths calculations is *O(V log V)* and each of
them may be run in parallel (one per process in ``pg``).  The
reduction phase to calculate the total centrality at the end of the
shortest paths phase is *O(V log V)*.

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

The algorithm uses a non-distributed (sequential) graph, as well as
non-distributed property maps.  Each process contains a separate copy
of the sequential graph ``g``.  In order for the algorithm to be
correct, these copies of ``g`` must be identical.  The ``sources``
buffer contains the vertices to use as the source of single source
shortest paths calculations when approximating betweenness centrality
using a subset of the vertices in the graph.  If ``sources`` is empty
then a complete betweenness centrality calculation is performed using
all vertices.

In the sequential phase of the algorithm each process computes
shortest paths from a subset of the vertices in the graph using the
Brandes shortest paths methods from the BGL's betweenness centrality
implementation.  In the parallel phase of the algorithm a reduction is
performed to sum the values computed by each process for all vertices
in the graph.

Either weighted or unweighted betweenness centrality is calculated
depending on whether a ``WeightMap`` is passed.

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

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

.. _Process Group: process_group.html
.. _Buffer: http://www.boost.org/libs/graph/doc/Buffer.html
.. _Dijkstra shortest paths: http://www.boost.org/libs/graph/doc/dijkstra_shortest_paths.html
.. _Readable Property Map: http://www.boost.org/libs/property_map/ReadablePropertyMap.html
.. _Incidence Graph: http://www.boost.org/libs/graph/doc/IncidenceGraph.html