centrality
Importance score of each node, by one of several measures.
Category: Mathematics > Graph and Network Algorithms
Syntax
c = centrality(G, type)
Computes the centrality measure named by type for every node.
Description
Each measure answers a different question. 'degree' counts the edges at a node. 'betweenness' counts how many shortest paths between other pairs of nodes run through it. 'closeness' is the inverse of the sum of distances to all other nodes, so it is high for nodes near everything. 'pagerank' scores a node by the scores of the nodes that point at it, and 'eigenvector' is the same idea based on the leading eigenvector of the adjacency matrix.
In a star graph the center has the highest score under every measure, which is a handy sanity check.
Input arguments
G- A
graphordigraph. type- Measure:
'degree','betweenness','closeness','pagerank','eigenvector', and for digraphs also the in/out variants such as'indegree'and'outdegree'.
Output arguments
c- Vector with one score per node. Larger means more central.
Example
Star graph
G = graph([1 1 1], [2 3 4]);
centrality(G, 'degree')'
centrality(G, 'betweenness')'
ans = 1×4
3 1 1 1
ans = 1×4
3 0 0 0
Notes
The scaling of some scores (for example how 'closeness' or 'eigenvector' is normalized) was not checked exhaustively against MATLAB; compare absolute values with care.