Computer Engineering is coming soon

We're still writing and reviewing the notes for every subject, and we'll open it when every subject is ready. Meanwhile you can practise aptitude, ask Aria about any subject, or see the branches that are ready.

Node centrality measures

Node centrality measures quantify how 'important' or 'central' a node is in a network using different ideas (local links, distances, control of paths, influence by neighbors, random-walk importance).

Drafted with Aria, reviewed by the AiCanCode.org team · Updated . How we write and check our notes. Spotted an error? Use Give Feedback at the bottom of the page.

Why it matters

Two or three sentences: where an engineer uses this.

Engineers use node centrality measures to identify important devices, users or servers in networks (for routing, caching, monitoring, influence detection and anomaly detection). Centrality helps pick nodes for resource placement, detect bottlenecks or influencers, and prioritize security checks in communication and social systems.

Key ideas

Explain from first principles; define terms before use.

  • Graph: a set of nodes (also called vertices) and edges (links) connecting pairs of nodes. Here edges can be undirected or directed; unless stated otherwise we treat undirected and unweighted graphs first.
  • Adjacency matrix A: a square matrix where element A_ij = 1 if there is an edge from node i to j (or between i and j for undirected), and 0 otherwise.

We study different notions of "central":

  1. Degree centrality (local importance).
  • Definition: The degree of a node is the number of edges incident on it. The degree centrality of node v is its degree; the normalized degree centrality divides degree by (n-1) where n is number of nodes. This measures how many direct neighbours v has.
  • Assumption: works for simple graphs without self-loops (if self-loops exist, count or ignore per question) and is purely local.
  1. Closeness centrality (distance-based importance).
  • Definition: For a node v, let d(v,t) be the shortest-path distance from v to node t. The closeness centrality is commonly given by (n-1)/sum_{t!=v} d(v,t). Larger value means v is on average closer to others.
  • Assumptions: graph is connected (for directed graphs, strongly connected for standard closeness, or compute with directed distances on the set reachable from v). For disconnected graphs use the harmonic closeness variant: sum of reciprocals of distances, i.e. sum_{t!=v} 1/d(v,t) where 1/∞ = 0. Universities often ask derivation of normalization (why (n-1)/sum d) — it makes values comparable across different n and gives higher value for smaller average distance.
  1. Betweenness centrality (control of shortest paths).
  • Definition: For nodes s and t, let σ_{st} be the number of shortest paths from s to t, and let σ_{st}(v) be the number of those shortest paths that pass through v (not counting endpoints). The betweenness centrality of v is sum_{s≠v≠t} σ_{st}(v)/σ_{st}. For undirected graphs we sum over unordered pairs and typically normalize by dividing by (n-1)(n-2)/2 (number of unordered pairs excluding v). For directed graphs, sum over ordered pairs and normalize by (n-1)(n-2).
  • Assumptions: shortest-paths are the model of information flow; weights matter if graph is weighted.
  • Derivation that examiners expect: show counting over all pairs, exclude s=v or t=v, explain normalization factor and why it is (n-1)(n-2)/2 for undirected.
  1. Eigenvector centrality (importance from important neighbours).
  • Definition: The eigenvector centrality vector x satisfies x = (1/λ) A x, i.e. A x = λ x, where λ is an eigenvalue. The centrality of node i is the i-th entry of the principal eigenvector (corresponding to largest eigenvalue). Nodes connected to high-scoring nodes get higher score.
  • Assumptions: for an undirected connected graph (or a directed strongly connected graph) with nonnegative A, the Perron–Frobenius theorem ensures a unique positive principal eigenvector. For directed graphs, state the edge orientation: using Ax = λx emphasizes out-neighbour influence, while A^T x = λx emphasizes in-neighbour influence (the common convention). Exam derivation: set up Ax = λx (or A^T x = λx for in-link centrality) and show how power iteration converges to the principal eigenvector.
  1. Katz centrality and PageRank (walk-based and random-walk importance).
  • Katz centrality: counts all walks from other nodes to v, exponentially weighted by walk length with attenuation α; for directed graphs use in-walks via A^T: x = α A^T x + β 1, whose solution is x = (I - α A^T)^{-1} β 1. Equivalently, the walk-sum form is [(I - α A^T)^{-1} - I] 1 when β = 1 (removing the length-0 term). Requirement: α < 1/λ_max (λ_max = spectral radius of A) for convergence of the power series.
  • PageRank: a random-walk model with teleportation (damping factor d, usually 0.85). PageRank vector p satisfies p = (1-d)/n · 1 + d · M p where M is column-stochastic matrix (columns = outgoing link distribution). Derivation in exams: set up linear system, show iterative power method.

Diagrams to draw in answers where needed:

  • For degree/closeness/betweenness example draw a labelled small graph with nodes labelled A,B,C,D and edges explicitly. Label shortest-paths used in betweenness calculation. For eigenvector centrality draw the same graph and annotate the iterative multiplication steps (A * x -> new vector).

Formulas

Each formula on its own line, then explain symbols, SI unit (dimensionless here) and when it applies.

deg(v) = number of edges incident on v — deg(v) is integer, unit: dimensionless. Applies to simple graphs; for directed graphs separate indegree and outdegree.

C_D(v) = deg(v)/(n-1) — C_D(v) is normalized degree centrality; n is number of nodes; dimensionless; applies when comparing nodes in same graph.

C_C(v) = (n-1) / sum_{t != v} d(v,t) — C_C(v) is closeness centrality; d(v,t) is shortest-path distance; dimensionless; assumes graph connected (or use harmonic form otherwise).

C_C^harmonic(v) = sum_{t != v} 1/d(v,t) — harmonic closeness; treat 1/∞ = 0; dimensionless; use for disconnected graphs.

C_B(v) = sum_{s ≠ t, s ≠ v, t ≠ v} σ_{st}(v)/σ_{st} — betweenness centrality raw sum; σ_{st} number of shortest s–t paths; dimensionless; normalize by dividing by (n-1)(n-2)/2 for undirected graphs or by (n-1)(n-2) for directed graphs.

A x = λ x — eigenvector centrality condition; x is eigenvector, λ is eigenvalue; x_i is centrality of node i; dimensionless; principal eigenvector (largest λ) used when A >= 0 and graph connected.

K = [(I - α A^T)^{-1} - I] 1 — Katz centrality vector K (in-link formulation; for undirected A^T = A); α is attenuation scalar; 1 is vector of ones; requires α < 1/λ_max for convergence; dimensionless.

p = (1-d)/n · 1 + d · M p — PageRank steady-state equation; p is PageRank vector (sum to 1), d is damping factor (typical 0.85), M is column-stochastic link matrix; handle dangling nodes by replacing empty columns with 1/n before forming M; dimensionless; applies to directed/undirected after building M.

Worked examples

Three model exam-style worked answers using a single small graph. Draw the graph: nodes A,B,C,D. Edges: A–B, A–C, B–C, C–D. (Triangle A-B-C plus leaf D connected to C). Label nodes A,B,C,D.

Example 1 — Degree, closeness and betweenness (numerical):

  1. Degrees: deg(A)=2 (B,C), deg(B)=2 (A,C), deg(C)=3 (A,B,D), deg(D)=1 (C).
  2. Normalized degree centrality: n=4 so divide by (n-1)=3.
    • C_D(A)=2/3=0.6667, C_D(B)=2/3=0.6667, C_D(C)=3/3=1.0000, C_D(D)=1/3=0.3333. Final: A=0.6667, B=0.6667, C=1.0000, D=0.3333.
  3. Closeness: compute shortest distances from each node.
    • From A: d(A,B)=1, d(A,C)=1, d(A,D)=2 → sum=4 → C_C(A)=(n-1)/sum = 3/4 = 0.75.
    • From B: same symmetry → C_C(B)=0.75.
    • From C: d(C,A)=1,d(C,B)=1,d(C,D)=1 → sum=3 → C_C(C)=3/3=1.00.
    • From D: d(D,C)=1,d(D,A)=2,d(D,B)=2 → sum=5 → C_C(D)=3/5=0.6. Final closeness: A=0.75, B=0.75, C=1.00, D=0.60.
  4. Betweenness (count shortest paths between pairs passing through node): list unordered node pairs: (A,B),(A,C),(A,D),(B,C),(B,D),(C,D).
    • Which pairs have shortest path through C? (A,D): A–C–D passes through C; (B,D): B–C–D passes through C. Both are unique shortest paths. So σ_{A,D}(C)=1, σ_{B,D}(C)=1.
    • No other pair's shortest path uses A or B internally. So raw betweenness: C:2, A:0, B:0, D:0.
    • Normalize for undirected by dividing by (n-1)(n-2)/2 = 3. So normalized C_B(C)=2/3=0.6667; others 0. Final betweenness: C=0.6667, A=B=D=0.0.

Example 2 — Eigenvector centrality (power iteration):

  • Adjacency matrix order [A,B,C,D]: row A: 0 1 1 0 row B: 1 0 1 0 row C: 1 1 0 1 row D: 0 0 1 0
  • Start vector x0 = [1,1,1,1]^T. Multiply: x1 = A x0 = [2,2,3,1]. Multiply again: x2 = A x1 = [5,5,5,3]. Multiply again: x3 = A x2 = [10,10,13,5]. Normalize by largest entry (make max =1) to compare: x3 / 13 ≈ [0.769,0.769,1.000,0.385].
  • So principal eigenvector gives centrality ranking C > A = B > D. Final approximate eigenvector centralities: C=1.00, A≈0.769, B≈0.769, D≈0.385.
  • Explain: power iteration will converge to principal eigenvector; signs positive by Perron–Frobenius because A is nonnegative and graph connected.

Example 3 — PageRank iteration (one small convergence trace):

  • Use damping factor d = 0.85, N=4. Initial p0 = [0.25,0.25,0.25,0.25]. Out-degrees: A=2,B=2,C=3,D=1. Column-stochastic contribution from a node j to its neighbours is 1/outdeg(j) each.
  • Compute p1 using p = (1-d)/N · 1 + d · M p0. Teleport = (1-0.85)/4 = 0.0375.
    • p1(A)=0.0375+0.85*(p0(B)/2 + p0(C)/3)=0.2145833
    • p1(B)=0.2145833
    • p1(C)=0.4625
    • p1(D)=0.1083333
  • After a few iterations we approach steady state; iteration 6 gave approximately p ≈ [0.248, 0.248, 0.358, 0.145]. So PageRank ranks C highest, then A and B similar, then D. Final approximate PageRank after convergence: C≈0.36, A≈0.25, B≈0.25, D≈0.15.

(Include these calculations step-by-step in exam answers; show each multiplication and normalization.)

Common mistakes

  • Counting endpoints in betweenness sums (do not count s or t when measuring σ_{st}(v)).
  • Not normalizing betweenness correctly (use right denominator for directed vs undirected normalization).
  • Confusing degree centrality with eigenvector centrality — high degree does not necessarily mean high eigenvector centrality if neighbours are low-scoring.
  • For PageRank, forgetting to account for dangling nodes (nodes with zero out-degree) or teleportation term; forgetting to make M column-stochastic.
  • For Katz centrality, choosing α ≥ 1/λ_max and getting divergence; not stating the convergence requirement.

For your exam

Kinds of questions and what full-marks answers include:

  • Definitions: give precise definitions for degree, closeness, betweenness, eigenvector, Katz and PageRank centralities; state assumptions (directed/undirected, connected/disconnected) — full marks require formula and a short remark on when it applies.
  • Short notes: compare measures (local vs global, path-based vs spectral), state pros and cons, and a one-line application each.
  • Derivations: derive betweenness normalization factor, show why eigenvector centrality leads to eigenproblem Ax = λx and mention Perron–Frobenius condition; show Katz power-series expansion and condition α < 1/λ_max.
  • Numericals: compute centrality values on a small labelled graph step-by-step and show final numeric answers with normalization. Show shortest-path calculations explicitly in betweenness and closeness.
  • Diagrams: draw the graph, label nodes and edges, mark shortest paths used in counts. Full marks require clear drawing plus labelled distances and paths.

Quick check

Three short questions:

  1. What does degree centrality measure? 2. In closeness centrality formula (n-1)/sum d(v,t), what must you check about the graph? 3. For PageRank, what is the role of the damping factor d?

Answers: 1) Number of direct neighbours (local connectivity). 2) That the graph is connected (if not, use harmonic closeness or handle infinite distances). 3) d is probability of following a link (1-d is teleport probability); it ensures convergence and prevents rank sink.

Finished this topic? Mark it so your progress, study plan and readiness keep up.

Stuck on something here?