Brandes' Betweenness Centrality
Computes the betweenness centrality of each vertex or each edge in the graph.
Complexity: O(VE) for unweighted graphs; O(VE + V(V+E) log V) for weighted graphs. Space: O(VE)
Defined in: <boost/graph/betweenness_centrality.hpp>
Example
#include <iostream>
#include <vector>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/betweenness_centrality.hpp>
int main() {
using Graph = boost::adjacency_list<boost::vecS, boost::vecS, boost::undirectedS>;
Graph g{5};
boost::add_edge(0, 1, g);
boost::add_edge(1, 2, g);
boost::add_edge(2, 3, g);
boost::add_edge(3, 4, g);
std::vector<double> centrality(num_vertices(g), 0.0);
boost::brandes_betweenness_centrality(g,
boost::make_iterator_property_map(centrality.begin(),
get(boost::vertex_index, g)));
std::cout << "Betweenness centrality:\n";
for (std::size_t i = 0; i < centrality.size(); ++i) {
std::cout << " Vertex " << i << ": " << centrality[i] << "\n";
}
}
Betweenness centrality:
Vertex 0: 0
Vertex 1: 3
Vertex 2: 4
Vertex 3: 3
Vertex 4: 0
(1) Named parameter version
template <typename Graph, typename Param, typename Tag, typename Rest>
void brandes_betweenness_centrality(
const Graph& g,
const bgl_named_params<Param, Tag, Rest>& params);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
The graph object on which the algorithm will be applied.
The type |
IN |
|
Named parameters passed via |
(2) Named parameter version (vertex centrality only)
template <typename Graph, typename CentralityMap>
void brandes_betweenness_centrality(
const Graph& g,
CentralityMap centrality_map);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
The graph object on which the algorithm will be applied.
The type |
OUT/UTIL |
|
This property map is used to accumulate the betweenness centrality
of each vertex, and is the primary output of the algorithm. The type
|
(3) Named parameter version (vertex and edge centrality)
template <typename Graph, typename CentralityMap, typename EdgeCentralityMap>
void brandes_betweenness_centrality(
const Graph& g,
CentralityMap centrality_map,
EdgeCentralityMap edge_centrality);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
The graph object on which the algorithm will be applied.
The type |
OUT/UTIL |
|
This property map is used to accumulate the betweenness centrality
of each vertex. The type |
OUT/UTIL |
|
This property map is used to accumulate the betweenness centrality
of each edge. The type |
(4) Positional version (unweighted)
template <typename Graph, typename CentralityMap, typename EdgeCentralityMap,
typename IncomingMap, typename DistanceMap, typename DependencyMap,
typename PathCountMap, typename VertexIndexMap>
void brandes_betweenness_centrality(
const Graph& g,
CentralityMap centrality_map,
EdgeCentralityMap edge_centrality,
IncomingMap incoming,
DistanceMap distance, DependencyMap dependency,
PathCountMap path_count,
VertexIndexMap vertex_index);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
The graph object on which the algorithm will be applied.
The type |
OUT/UTIL |
|
This property map is used to accumulate the betweenness centrality
of each vertex, and is the primary output of the algorithm. The type
|
OUT/UTIL |
|
This property map is used to accumulate the betweenness centrality
of each edge, and is a secondary form of output for the algorithm. The type
|
UTIL |
|
This property map records the set of edges incoming to each vertex that
comprise a shortest path from a particular source vertex through this
vertex, and is used internally by the algorithm. The |
UTIL |
|
The shortest path weight from each source vertex |
UTIL |
|
Property map used internally to accumulate partial betweenness
centrality results. The type |
UTIL |
|
Property map used internally to accumulate the number of paths that pass
through each particular vertex. The type |
IN |
|
This maps each vertex to an integer in the range |
(5) Positional version (weighted)
template <typename Graph, typename CentralityMap, typename EdgeCentralityMap,
typename IncomingMap, typename DistanceMap, typename DependencyMap,
typename PathCountMap, typename VertexIndexMap, typename WeightMap>
void brandes_betweenness_centrality(
const Graph& g,
CentralityMap centrality_map,
EdgeCentralityMap edge_centrality,
IncomingMap incoming,
DistanceMap distance, DependencyMap dependency,
PathCountMap path_count,
VertexIndexMap vertex_index,
WeightMap weight_map);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
The graph object on which the algorithm will be applied.
The type |
OUT/UTIL |
|
This property map is used to accumulate the betweenness centrality of each vertex. See overload (4) for details. |
OUT/UTIL |
|
This property map is used to accumulate the betweenness centrality of each edge. See overload (4) for details. |
UTIL |
|
See overload (4) for details. |
UTIL |
|
See overload (4) for details. |
UTIL |
|
See overload (4) for details. |
UTIL |
|
See overload (4) for details. |
IN |
|
See overload (4) for details. |
IN |
|
The weight or "length" of each edge in the graph. The weights must all be
non-negative, and the algorithm will throw a
|
(6) Named parameters (for overload 1)
| Direction | Named Parameter | Description / Default |
|---|---|---|
OUT/UTIL |
|
This property map is used to accumulate the betweenness centrality
of each vertex, and is the primary output of the algorithm. The type
|
OUT/UTIL |
|
This property map is used to accumulate the betweenness centrality
of each edge, and is a secondary form of output for the algorithm. The type
|
IN |
|
This maps each vertex to an integer in the range |
IN |
|
The weight or "length" of each edge in the graph. The weights must all be
non-negative, and the algorithm will throw a
|
(7) Helper: relative_betweenness_centrality
template <typename Graph, typename CentralityMap>
void relative_betweenness_centrality(
const Graph& g,
CentralityMap centrality_map);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
The graph object. Must model Vertex List Graph. |
IN/OUT |
|
The centrality map that was previously computed by
|
(8) Helper: central_point_dominance
template <typename Graph, typename CentralityMap>
typename property_traits<CentralityMap>::value_type
central_point_dominance(
const Graph& g,
CentralityMap centrality_map);
| Direction | Parameter | Description |
|---|---|---|
IN |
|
The graph object. Must model Vertex List Graph. |
IN |
|
The relative betweenness centrality map (i.e., the centrality map after
calling |
Description
This algorithm [49] computes the betweenness centrality
of each vertex or each edge in the graph. The betweenness centrality of a vertex v is defined by
where
is the number of shortest paths from vertex
s to vertex t and
is the number of shortest
paths from vertex s to vertex t that pass through vertex v.
The edge betweenness centrality indicates for each edge the betweenness centrality that was contributed to the target(s) of the edge (plural for undirected graphs). Similar to (vertex) betweenness centrality, edge betweenness centrality can be used to determine the edges through which most shortest paths must pass. A single invocation of this algorithm can compute either the vertex or edge centrality (or both).
This algorithm can operate either on weighted graphs (if a suitable edge weight
map is supplied) or unweighted graphs (if no edge weight map is supplied). The
result is the absolute betweenness centrality; to convert to the relative
betweenness centrality, which scales each absolute centrality by
(where n is the number of
vertices in the graph), use relative_betweenness_centrality. Given the
relative betweenness centrality, one can compute the central point
dominance [50], which is a measure of
the maximum "betweenness" of any point in the graph: it will be 0 for complete
graphs and 1 for "wheel" graphs (in which there is a central vertex that all
paths include; see Fig. 1). Let
be the vertex
with the largest relative betweenness centrality; then, the central point
dominance is defined as:
| Fig. 1: A wheel graph, where every path travels through the central node. The central point dominance of this graph is 1. |
|---|
|
Returns
The brandes_betweenness_centrality function outputs its results through the
centrality_map and/or edge_centrality_map property maps. The
relative_betweenness_centrality function modifies the centrality map in
place. The central_point_dominance function returns a value of type
property_traits<CentralityMap>::value_type representing the central point
dominance of the graph.
Example
See bc_clustering for an example that
uses betweenness centrality as part of a graph clustering algorithm.
