learngraphtheory.org

Guest

Sign in to keep your graphs and progress.

Algorithm Selection

Select an algorithm and generate steps to begin visualization

Katz Centrality Visualizer

Every walk counts, the short ones most

Counts every walk that ends at a vertex, a walk of k steps weighted α^k, on top of a base score for each vertex, so it also ranks graphs without cycles

Time: O(k(V + E))
Space: O(V)
Use Case: Citation networks, influence in social networks, ranking in directed graphs
Showing the example graph for this algorithm.
Algorithm Execution

Select an algorithm and generate steps to begin visualization

About Katz Centrality

Katz centrality, proposed by Leo Katz in 1953 as a status index, ranks a vertex by the walks that end at it. A walk of one step counts α, a walk of two steps α², and so on, so near influence weighs most and far influence fades. Every vertex also gets a base score β, which is the difference from eigenvector centrality: on a directed graph without cycles, such as a citation network, the eigenvector is all zeros, while Katz still separates the vertices. The sum converges when α is below 1 / λ, where λ is the largest eigenvalue of the adjacency matrix.

How it works

The scores solve x = β + αAᵀx, and the visualizer finds them by iteration: every vertex starts at β = 1, then in each round takes 1 plus α times the sum of the scores of the vertices that point to it. After k rounds the scores count every walk of up to k steps, and each round adds less, by a factor of about αλ. Here α = 0.2, lowered to 0.9 / λ when that would come too close to 1 / λ, and on a graph without cycles λ = 0, so the scores are exact after as many rounds as the longest path. Vertices grow with their score, the edges into the vertex being updated light up, and the panel lists the scores with each in-degree. In the example citation network E has fewer citations than D but ends higher, because the papers that cite it are cited themselves.

Applications

Katz centrality ranks papers and patents in citation networks, people in social and communication networks, and packages in software dependency graphs, all directed and often acyclic. The same series of walks gives the Katz index for link prediction, one of the strongest classic scores in the study by Liben-Nowell and Kleinberg. PageRank can be seen as a normalised relative, in which a vertex shares its score among its out-links instead of passing all of it on. NetworkX and igraph provide it, and α sets how far influence travels: near 0 it approaches in-degree, near 1 / λ eigenvector centrality.

Pseudocode

A fixed-point iteration: each round passes a share α of every score along the edges.

Katz(G, alpha, beta):
    x(v) = beta for every vertex v
    repeat until the scores stop changing:
        for each vertex v:
            x2(v) = beta + alpha * sum of w(u, v) * x(u)   over edges u -> v
        x = x2
    return x                       // needs alpha < 1 / lambda

In matrix form the scores are x = β(I − αAᵀ)⁻¹1, the sum β(1 + αAᵀ1 + α²(Aᵀ)²1 + ...). The k-th term counts the walks of length k that end at each vertex, weighted by αᵏ. The series converges exactly when α < 1 / λ, λ being the largest eigenvalue of the adjacency matrix.

Worked example, step by step

The citation network loaded on this page, with α = 0.2 and β = 1.

Example graph: Arcs A → D, B → D, C → D, F → E, G → E, H → F, A → F, B → F, H → G, C → G, A → G. A, B, C and H cite, nobody cites them.

  1. Start. All 8 vertices start at β = 1. The graph has no cycle, so λ = 0 and any α converges. Eigenvector centrality would give every vertex 0 here.
  2. Iteration 1. A, B, C and H keep 1, nothing points to them. D = 1 + 0.2 × 3 = 1.6, F = 1.6, G = 1.6 and E = 1 + 0.2 × (1 + 1) = 1.4. D leads.
  3. Iteration 2. E now adds the new scores of F and G: 1 + 0.2 × (1.6 + 1.6) = 1.64. The walks of length 2 into E, through F or G, are counted. E takes the lead.
  4. Iteration 3. Nothing changes. The longest path has two arcs, so after two rounds every walk is counted and the scores are exact.

E 1.64, D 1.6, F 1.6, G 1.6, and 1 for A, B, C and H. E has 2 citations and D has 3, yet E ranks first, because the papers that cite E are cited themselves.

Complexity, and where it comes from

Time: O(m) per iteration · Space: O(n)

Each iteration reads every edge once. The error shrinks by a factor of about αλ per round, so reaching an accuracy ε takes about log ε / log(αλ) rounds, few when α is well below 1 / λ. On a graph without cycles it ends after as many rounds as the longest path, as here. Solving the linear system (I − αAᵀ)x = β1 directly costs O(n³), only sensible for small graphs.

When to use Katz Centrality, and when not to

Katz and its relatives among the centrality measures.

AlternativePrefer it whenCost
In-degreeOnly direct links matter. It is Katz with α close to 0.O(n + m)
Eigenvector centralityThe graph is strongly connected and undirected or nearly so. Without β it collapses to 0 on acyclic and weakly connected parts.O(m) per iteration
PageRankA vertex with many out-links should pass less to each one, as on the web. Each vertex divides its score among its out-links.O(m) per iteration

Common pitfalls

  • Choosing α too large. With α ≥ 1 / λ the series diverges and the scores grow without bound. Compute λ first, or take α well below it. The visualizer lowers α to 0.9 / λ when 0.2 would come too close.
  • Mixing up the direction. Katz counts the walks that end at a vertex, so on a directed graph the in-links matter. NetworkX does the same and asks you to reverse the graph for out-links. Using the wrong direction ranks the citing papers instead of the cited ones.
  • Comparing raw numbers between tools. NetworkX normalises the vector to length 1 by default, other tools keep β = 1 or report β-free scores. The numbers differ, the ranking does not. Compare rankings, or normalise the same way.

Frequently asked questions

What does β do?
β gives every vertex a little score of its own, independent of the graph. Without it the scores on an acyclic graph all drop to 0, as in eigenvector centrality. Because the scores are linear in β, its value does not change the ranking.
How should α be chosen?
α decides how far influence travels. Near 0 Katz ranks almost by in-degree, near 1 / λ it approaches eigenvector centrality. Common choices are 0.1 or a value like 0.85 / λ. Try a few and keep the one whose ranking makes sense for the data.
How is Katz used for link prediction?
The Katz index of a pair a, b sums αᵏ times the number of walks of length k from a to b. Pairs joined by many short walks are likely to be linked soon. Liben-Nowell and Kleinberg found it among the best classic predictors.

Related algorithms: Eigenvector Centrality, PageRank, HITS (Hubs and Authorities), Harmonic Centrality, Link Prediction

Built by Mohammed Islam HadjoudjWork with me

An example graph: you can change it, or start blank.

Zoom Controls

35%
Nodes: 8
Edges: 11