betweennessCentrality(): Betweenness centrality is a measure of node importance based on the number of shortest paths between other node pairs that pass through that node. It uses Brandes algorithm to efficientlycalculate the betweenness centrality for all nodes in a graph. This algorithm is from the Graph Metrics category of Boost Graph Library.
It is used in a linear system of equations, can be used to reduce the size needed to store the sparse matrix, improve the usage of distributed memory, enhance data locality, in constraint satisfaction problems, etc.
Main characteristics of the function:
Applicable for undirected and directed graphs.
The graph can be either weighted or unweighted.
Returns the relative betweenness centrality of each vertex of the graph
It has time complexity of O(VE) for unweighted graphs and O(VE + V(V+E) log V) for weighted graphs.
It has space complexity is O(VE).
Signature:
betweennessCentrality()
betweennessCentrality (Edges SQL)
RETURNS SET OF (vid, centrality)
OR throws
Parameters:
Parameter
Type
Description
Edges SQL
TEXT
Inner SQL query, as described below.
Inner Query:
Edges SQL: It should be an SQL query which should return a set of rows with the following columns:
Column
Type
Default
Description
id
ANY-INTEGER
Identifier of the edge
source
ANY-INTEGER
Identifier of the first end point vertex of the edge
target
ANY-INTEGER
Identifier of the second end point vertex of the edge
cost
ANY-NUMERICAL | | Weight of the edge (source, target). When negative: edge (source, target) does not exist on the graph.
reverse_cost
ANY-NUMERICAL | -1 | Weight of the edge (target, source). When negative: edge (target, source) does not exist on the graph.
pgr_betweennessCentrality():
betweennessCentrality(): Betweenness centrality is a measure of node importance based on the number of shortest paths between other node pairs that pass through that node. It uses Brandes algorithm to efficientlycalculate the betweenness centrality for all nodes in a graph. This algorithm is from the Graph Metrics category of Boost Graph Library. It is used in a linear system of equations, can be used to reduce the size needed to store the sparse matrix, improve the usage of distributed memory, enhance data locality, in constraint satisfaction problems, etc.
Main characteristics of the function:
Signature:
Parameters:
TEXT
Inner Query:
Edges SQL: It should be an SQL query which should return a set of rows with the following columns:
ANY-INTEGER
ANY-INTEGER
ANY-INTEGER
ANY-NUMERICAL
| | Weight of the edge (source, target). When negative: edge(source, target)
does not exist on the graph.ANY-NUMERICAL
| -1 | Weight of the edge (target, source). When negative: edge(target, source)
does not exist on the graph.Where:
ANY-INTEGER
= SMALLINT, INTEGER, BIGINTANY-NUMERICAL
= SMALLINT, INTEGER, BIGINT, REAL, FLOATResult Columns:
Returns SET OF
(vid, centrality)
BIGINT
FLOAT