Structural Dependency Criticality via PageRank: the model, the solver and its validation

PageRank on a dependency graph

Picture a random walker moving through the dependency map. At each step, with probability \(\alpha\) (the damping factor, here 0.85), the walker follows one of the current system’s dependencies, chosen at random. Otherwise it restarts at a system drawn from a restart distribution \(v\). A system’s PageRank score is the long-run share of time the walker spends there. Systems that many important systems depend on are visited often and score highly.

In matrix form, with \(M\) the column-stochastic transition matrix (\(M_{ij} = 1/d_j\) when system \(j\) depends on system \(i\) and \(d_j\) is \(j\)’s number of dependencies), the scores \(p^*\) solve

\[ p^* = \alpha \left( M p^* + \Big(\textstyle\sum_{j \in \mathcal{D}} p^*_j\Big)\, u \right) + (1 - \alpha)\, v , \]

where \(\mathcal{D}\) is the set of dangling systems (systems with no dependencies of their own) and \(u\) is where their mass goes. The scores are non-negative and sum to one. They rank systems relative to each other. They carry no units of probability of failure, loss or exposure.

What \(\alpha\) is and is not. \(\alpha\) is the probability that the walk follows a dependency rather than restarting. As \(\alpha\) falls toward zero, every score tends to \(1/n\), so the model says all systems matter equally. It is not a measure of how tightly or loosely coupled the architecture is. Coupling strength belongs in edge weights or in the cascade model (Failure Cascades). The Sensitivity page shows how the scores move across \(\alpha\) from 0.5 to 0.99.

Why not eigenvector centrality. This graph is a directed acyclic graph: following dependencies never leads back to the start. The adjacency matrix of such a graph has every eigenvalue equal to zero, so there is no leading eigenvector to rank by, and eigenvector centrality degenerates. The restart term in PageRank guarantees a unique, strictly positive solution.

Dangling systems

4 systems have no dependencies of their own: Cloud_IAM, Root_DNS, IdP_Auth_Okta, and Secrets_Vault. Together they hold 36.4% of PageRank mass. Something must happen to the walker when it reaches one, and the choice affects every score:

  • Uniform (default, \(u = 1/n\)): the walker jumps to a random system. This is igraph’s convention and is used for the headline results. It raises the lowest possible score from the restart floor \((1-\alpha)/n =\) 0.60% to the observed minimum of 1.84%, because mass collected by the dangling systems is recycled to every system.
  • Self-loop: the dangling system keeps the walker. Mass accumulates at the foundation systems.
  • Personalization (\(u = v\)): the walker restarts according to the restart distribution. This is the natural choice for business-weighted PageRank below, and it is igraph’s convention for personalized PageRank.

Operationally, none of these means much (“after reaching the vault, jump to a random service”). The Sensitivity page reports how much the ranking changes between them.

Business-weighted PageRank

With a uniform restart distribution, every system starts the walk equally often, so a back-office batch job counts as much as the payment API. Setting \(v\) to the business weights from params.yaml makes the walk start only at the 8 client-facing systems, in proportion to the business value delivered through them. The resulting score reads as “the share of business-weighted dependency paths that pass through this system”. Business weights are illustrative assumptions.

Edge weights

The solver accepts an optional edge weight. Each system’s outgoing weights are normalized by its total outgoing weight, so a heavier edge carries a larger share of the walk. All weights in this study are 1. The validation below includes a test case in which every dependency on Ledger_DB has weight 2.

Implementation

The solver builds the adjacency matrix as a sparse matrix (Matrix::sparseMatrix), normalizes columns in one step, and runs power iteration until the L1 change between successive iterates falls below 1 × 10-9. It returns a convergence flag and warns if max_iter is reached first.

Display code
# Power-iteration PageRank on a sparse column-stochastic matrix.
#
# dangling: what a sink (an asset with no dependencies) does with its mass
#   "uniform"         spread over all n assets (igraph's default convention)
#   "self_loop"       keep it (the sink points to itself)
#   "personalization" spread according to the personalization vector v
# personalization: restart distribution v (defaults to uniform 1/n)

compute_custom_pagerank <- function(nodes, edges, alpha = 0.85, tol = 1e-9, max_iter = 500,
                                    dangling = c("uniform", "self_loop", "personalization"),
                                    personalization = NULL) {
  dangling <- match.arg(dangling)
  n <- nrow(nodes)
  w <- if ("weight" %in% names(edges)) edges$weight else rep(1, nrow(edges))

  v <- if (is.null(personalization)) rep(1 / n, n) else personalization / sum(personalization)

  # A[i, j] = weight of the edge j -> i (j depends on i)
  A <- sparseMatrix(i = edges$to, j = edges$from, x = w, dims = c(n, n))
  out_strength <- colSums(A)
  is_sink <- out_strength == 0

  M <- A %*% Diagonal(x = ifelse(is_sink, 0, 1 / out_strength))
  if (dangling == "self_loop") M <- M + Diagonal(x = as.numeric(is_sink))
  sink_target <- switch(dangling, uniform = rep(1 / n, n), personalization = v, self_loop = rep(0, n))

  p <- rep(1 / n, n)
  residual_log <- numeric(max_iter)
  converged <- FALSE
  for (iter in seq_len(max_iter)) {
    sink_mass <- if (dangling == "self_loop") 0 else sum(p[is_sink])
    p_next <- alpha * (as.vector(M %*% p) + sink_mass * sink_target) + (1 - alpha) * v
    residual <- sum(abs(p_next - p))
    residual_log[iter] <- residual
    p <- p_next
    if (residual < tol) {
      converged <- TRUE
      break
    }
  }
  if (!converged) {
    warning(sprintf("PageRank did not converge in %d iterations (residual %.2e)", max_iter, residual))
  }

  list(
    criticality_vector = p,
    iterations = iter,
    converged = converged,
    residuals = residual_log[seq_len(iter)],
    transition_matrix = M,
    adjacency_matrix = A,
    sink = is_sink
  )
}

pagerank_params <- function(params) params$pagerank[c("alpha", "tol", "max_iter")]

# Convenience wrapper: vector of scores named by asset
pr_scores <- function(nodes, edges, params, ...) {
  pp <- pagerank_params(params)
  res <- compute_custom_pagerank(nodes, edges, alpha = pp$alpha, tol = pp$tol, max_iter = pp$max_iter, ...)
  set_names(res$criticality_vector, nodes$name)
}

# Ties in PageRank are exact in theory but differ in the last bits numerically.
rank_desc <- function(x) rank(-round(x, 10), ties.method = "min")

Validation against igraph

The custom solver is compared with igraph::page_rank() (PRPACK backend) in three configurations: uniform restart, business-weighted restart, and weighted edges.

Display code
res$validation |>
  select(rank_custom, name, tier, p_custom, p_igraph, abs_delta) |>
  slice_head(n = 10) |>
  gt_house(
    title = "Custom power iteration vs. igraph: top 10 systems",
    subtitle = "Uniform restart, α = 0.85, convergence tolerance 10⁻⁹"
  ) |>
  cols_label(
    rank_custom = "Rank", name = "Asset", tier = "Tier",
    p_custom = "Custom solver", p_igraph = "igraph", abs_delta = "Absolute difference"
  ) |>
  fmt_number(columns = c(p_custom, p_igraph), decimals = 6) |>
  fmt_scientific(columns = abs_delta, decimals = 2)
Custom power iteration vs. igraph: top 10 systems
Uniform restart, α = 0.85, convergence tolerance 10⁻⁹
Rank Asset Tier Custom solver igraph Absolute difference
1 Secrets_Vault Tier 0: Foundational Core 0.152724 0.152724 3.63 × 10−11
2 Cloud_IAM Tier 0: Foundational Core 0.137918 0.137918 5.44 × 10−11
3 Kafka_Bus Tier 0: Foundational Core 0.054528 0.054528 4.90 × 10−12
4 Core_Postgres_DB Tier 1: Data & Persistence 0.051971 0.051971 1.31 × 10−12
5 Redis_Session_Cache Tier 1: Data & Persistence 0.049502 0.049502 4.09 × 10−12
6 IdP_Auth_Okta Tier 0: Foundational Core 0.047327 0.047327 6.36 × 10−12
7 Ledger_DB Tier 1: Data & Persistence 0.035811 0.035811 3.77 × 10−12
8 Order_Routing_Svc Tier 2: Microservices 0.033003 0.033003 7.60 × 10−12
8 Payment_Execution_API Tier 2: Microservices 0.033003 0.033003 7.60 × 10−12
8 User_Profile_Svc Tier 2: Microservices 0.033003 0.033003 7.60 × 10−12

How to read the table. Each row is one of the ten systems with the highest PageRank, in rank order. The two score columns show the PageRank share computed by this project’s own solver and by igraph, a widely used reference library, written as fractions of one (0.15 means 15%). The last column is the gap between them in scientific notation, where 5e-11 means 0.00000000005.

What the table tells you. The two solvers agree to within 5.4e-11 for every system, far below any precision a decision could use, and they rank all 25 systems identically. The project’s solver is therefore built correctly, and the later pages can rely on it. Agreement shows that the arithmetic is right. It does not show that the dependency map, or PageRank itself, is the right model of the estate.

Display code
v <- res$validation
stopifnot(
  res$solution$converged,
  res$max_discrepancy < 1e-8,
  res$max_discrepancy_business < 1e-8,
  res$max_discrepancy_weighted < 1e-8,
  all(v$rank_custom == v$rank_igraph)
)
cat(sprintf(
  "Validation passed\nIterations to convergence: %d\nMax |difference|, uniform restart:  %.2e\nMax |difference|, business-weighted: %.2e\nMax |difference|, weighted edges:    %.2e\n",
  res$solution$iterations, res$max_discrepancy, res$max_discrepancy_business, res$max_discrepancy_weighted
))
#> Validation passed
#> Iterations to convergence: 23
#> Max |difference|, uniform restart:  5.44e-11
#> Max |difference|, business-weighted: 7.24e-11
#> Max |difference|, weighted edges:    3.16e-11

The chunk above stops the render if any check fails, so a published page always means the checks passed. The largest difference across all 25 systems is 5.4 × 10-9 percentage points. This confirms the solver is implemented correctly. It does not show that the model is a good description of the estate; the remaining pages address that.

Convergence

Display code
tibble(iteration = seq_along(sol$residuals), residual = sol$residuals) |>
  ggplot(aes(iteration, residual)) +
  geom_hline(yintercept = res$params$pagerank$tol, linetype = "dashed", color = "#888888") +
  geom_line(color = "#2a78d6", linewidth = 0.8) +
  geom_point(color = "#2a78d6", size = 2) +
  annotate("text", x = 1, y = res$params$pagerank$tol, label = "stopping tolerance",
           hjust = 0, vjust = -0.6, size = 3.5, color = "#555555") +
  scale_y_log10(labels = trans_format("log10", math_format(10^.x))) +
  labs(
    title = "Power iteration convergence",
    subtitle = "L1 change between successive iterates, ||p(k+1) − p(k)||",
    x = "Iteration",
    y = "L1 change between iterates (log scale)"
  )

How to read the plot. The horizontal axis counts the solver’s repeated passes over the dependency map. The vertical axis shows how much the scores changed from one pass to the next, summed over all systems, on a logarithmic scale where each gridline is ten times smaller than the one above it. The dashed line marks the stopping tolerance: once the change falls below it, the solver stops.

What the plot tells you. The change shrinks by a steady factor at every pass, which shows as a straight downward line on this scale, and the solver stops after 23 passes. The plotted change is not the exact error, but the true error is at most about 5.7 times the last change, which is still negligible. The scores are stable: more passes would not alter any figure on this site.