qalgora-Q Docs Hub量子文档 ✦ Ask AI✦ 问问文档

Quantum PageRank

◐ Design-level API
This page documents qalgora-Q API design, architecture, or adaptation workflows. Code examples illustrate intended usage and are not guaranteed to run in the current reference implementation.

Rank the nodes of a network with a quantum walk — evolving a continuous-time open-system process whose steady state encodes node importance. It is the quantum analogue of classical PageRank, and in one place it fills in exactly the blind spot the classical version leaves behind.

The problem it solves

Given a directed graph — web pages and hyperlinks, papers and citations, accounts and transfers — we want to know: which nodes are most "important"? The naive idea is to count incoming edges, but that is easy to game, and it ignores the fact that being pointed to by an important node should carry more weight than being pointed to by an unknown one. PageRank's core insight is to define importance recursively: a node's importance is the sum of the importances of the nodes that point to it.

Classical PageRank realises this recursion as a random walk on the graph: a "surfer" hops along outgoing edges at random, occasionally restarting from a random page. Each node's importance is the long-run occupation probability of the walk sitting on it. Quantum PageRank keeps this whole idea but replaces the classical random walk with a quantum walk.

Encoding the graph — the Google matrix

To feed the graph to the algorithm, we first build its stochastic matrix: normalise each node's outgoing edges uniformly to get one-step hopping probabilities. But a pure stochastic matrix has two defects — "dangling" nodes with no outgoing edges trap the walk, and isolated subgraphs cannot reach one another. PageRank patches both with a "teleportation" term: with probability α (typically 0.85) follow a link, and with probability 1−α teleport to an arbitrary node. The convex combination of the two is the Google matrix

G = α·S + (1−α)·(1/N)·𝟙

where S is the link matrix (with dangling nodes patched), 𝟙 is the all-ones matrix, and N is the number of nodes. Classical PageRank is then the principal eigenvector of G corresponding to eigenvalue 1.

Watch the convention: whether S is row- or column-stochastic decides whether the ranking is the left or right eigenvector, and references differ on this. The (1−α)·(1/N)·𝟙 term is exactly a uniform teleport — it sends weight to every node with equal probability.

From a classical walk to a quantum walk

A classical random walk is incoherent: every step is a probabilistic hop, with no phase and no interference. A quantum walk instead places the "surfer" in a superposition over many nodes, with each branch carrying a coherent complex amplitude that can interfere with the others. But a purely unitary quantum walk never settles into a steady state — it oscillates forever, and ranking demands a stable reading.

The remedy is to use an open-system quantum walk: encode the Google matrix into a Lindblad generator and layer a little dissipation on top of the coherent quantum evolution. Under a suitable Lindblad construction and connectivity/ergodicity conditions, the dissipation can drive the dynamics to converge to a steady state; the quantum coherence that survives gives that steady state a resolving power the classical version lacks. Integrating the resulting open-system dynamics, the steady-state occupation probability of each node gives the ranking.

One definition among several
This page describes the open-system / Lindblad formulation of quantum PageRank. Other definitions exist — for instance a discrete-time quantum walk (DTQW) with a time-averaged distribution — and they need not agree node-for-node.

Its relation to classical PageRank — and that blind spot

When dissipation dominates, the quantum PageRank ranking smoothly reduces to classical PageRank — the classical algorithm is a limiting case of the quantum one, not something it contradicts. Where the two genuinely diverge is on the symmetric and degenerate nodes that the classical algorithm cannot handle. Quantum PageRank may distinguish some nodes that score identically classically but differ in higher-order connectivity structure or dynamical response; however, nodes protected by a strict graph automorphism symmetry should not receive different scores from any ranking method that does not break that symmetry. Where such symmetry is only approximate, the phase interference of the quantum walk is sensitive to the wider connectivity pattern a node sits in, so it can break near-ties and produce differentiated rankings.

An honest look at its usefulness

  • This is a continuous-time simulation problem, not an algorithm with a known speedup. Today's quantum PageRank is implemented mainly by simulating open-system dynamics; for graphs at real network scale there is no proven asymptotic speedup over classical sparse-matrix power iteration.
  • Encoding the graph is itself a cost. Loading an N-node graph into a quantum state and reading out N occupation probabilities can eat up any gain the evolution phase might offer — the same "data in, data out" bottleneck that haunts many quantum algorithms.
  • Its value lies in ranking semantics, not speed. What is truly unique is its ability to break degeneracy, not to compute the ranking faster. It is better understood as a semantically enriched variant of classical PageRank than as an accelerated version of it.
  • The choice of α still matters. As in the classical version, the teleportation probability 1−α tunes how sensitive the ranking is to graph structure; it is a modelling choice that does not disappear just because the walk became quantum.

The algorithm, step by step

  1. Build the Google matrix G from the graph (the link matrix plus a teleportation term, weighted by α).
  2. Encode G into a Lindblad generator so the coherent quantum walk carries a little dissipation.
  3. Starting from a uniform initial state, integrate the open-system dynamics over time.
  4. Read out the steady-state occupation probability of each node and sort by it as the importance score.

Seeing it in code

Read the snippet below against the theory above: from_google_matrix(G, alpha=0.85) is exactly what turns the Google matrix with its teleportation term into a Lindblad generator L; Schedule supplies the time steps for the integration; evolve propagates the open-system dynamics starting from uniform_state; and final_occupations() reads out the steady-state occupation probabilities — the node importance scores.

import qalgora
from qalgora import operators
import numpy as np

# build the Lindblad generator from the graph's Google matrix G
L = operators.from_google_matrix(G, alpha=0.85)

schedule = qalgora.Schedule(steps=np.linspace(0, 10, 100), parameters=["t"])
result = qalgora.evolve(L, dimensions=dims, schedule=schedule,
                        initial_state=uniform_state)
ranking = result.final_occupations()      # node importance scores
Specification API — not in the open reference build yet
This example shows a qalgora-Q specification API (or a third-party library) that the open reference build does not bundle today. It documents the intended interface; to run code now, use the reference build’s supported core API.
Why quantum?
The quantum walk may distinguish some nodes that score identically classically but differ in higher-order connectivity structure or dynamical response; nodes protected by a strict graph automorphism symmetry, however, should not be ranked differently by any method that does not break that symmetry. Its distinction is resolving power in the ranking, not faster computation — keep that in mind as you read this code. The open systems and the Lindblad equation page explains the dissipative dynamics this relies on to converge to a steady state.

量子 PageRank

◐ 设计接口
本页描述的是 qalgora-Q 的接口设计、架构设计或适配工作流。相关代码用于说明预期用法,当前参考实现不保证可以直接运行。

借助一个量子游走对网络节点排序——演化一个连续时间的开放系统过程,其稳态编码了节点的重要性。它是经典 PageRank 的量子类比,且在一处恰好补上了经典版本的盲点。

它解决的问题

给定一张有向图——网页与超链接、论文与引用、账户与转账——我们想知道:哪些节点最"重要"?朴素的想法是数入边,但这很容易被操纵,也忽略了"被一个重要节点指向"应当比"被一个无名节点指向"更有分量。PageRank 的核心洞见是递归地定义重要性:一个节点的重要性,来自指向它的那些节点的重要性之和。

经典 PageRank 把这一递归实现为图上的一次随机游走:一个"冲浪者"沿出边随机跳转,偶尔随机重启。各节点的重要性,就是这个游走在其上停留的长期占据概率。量子 PageRank 保留这套思想,但把经典随机游走换成量子游走

编码图 Google 矩阵

要把图喂给算法,先构造它的随机矩阵:把每个节点的出边均匀归一,得到一步跳转概率。但纯粹的随机矩阵有两个毛病——没有出边的"悬挂"节点会让游走卡死,孤立的子图之间彼此不可达。PageRank 用一个"传送"项修补这两点:以概率 α(典型取 0.85)沿链接跳转,以概率 1−α 随机传送到任意节点。两者的凸组合就是 Google 矩阵

G = α·S + (1−α)·(1/N)·𝟙

其中 S 是(修补悬挂节点后的)链接矩阵,𝟙 是全 1 矩阵,N 是节点数。经典 PageRank 即 G 对应于本征值 1 的主本征向量。

需留意约定:S 取行随机还是列随机,决定了排名对应左本征向量还是右本征向量,不同文献在此并不一致。(1−α)·(1/N)·𝟙 项正是均匀传送——它以相等概率把权重送往每个节点。

从经典游走到量子游走

经典随机游走是非相干的:每一步都是一次概率性跳转,没有相位、没有干涉。量子游走则让"冲浪者"处于多个节点的叠加之中,各分支携带可相干的复振幅,能彼此干涉。但纯酉演化的量子游走永不收敛到稳态——它会无限震荡,而排序恰恰需要一个稳定的读数。

解决之道是采用一个开放系统的量子游走:把 Google 矩阵编码进一个 Lindblad 生成元,在相干的量子演化之外,叠加一点点耗散。在适当的 Lindblad 构造和连通/遍历条件下,耗散可使动力学收敛到稳态;而保留下来的量子相干,则赋予该稳态经典版本所不具备的分辨力。对所得开放系统动力学积分,各节点的稳态占据概率即给出排名。

这只是诸多定义之一
本页描述的是量子 PageRank 的开放系统 / Lindblad 表述。还存在其他定义——例如基于时间平均分布的离散时间量子游走(DTQW)——它们逐节点的结果未必一致。

它与经典 PageRank 的关系 以及那处盲点

当耗散占主导时,量子 PageRank 的排名平滑回退到经典 PageRank——后者是前者的一个极限情形,而非被它否定。两者真正分道扬镳的地方,在于经典算法束手无策的对称与退化节点。量子 PageRank 可能区分一些经典同分但在更高阶连接结构或动力学响应上不同的节点;但受严格图自同构对称性保护的节点,任何不破坏该对称性的排序方法都不应给出不同分数。当这种对称性只是近似成立时,量子游走的相位干涉对节点所处的更广连接模式敏感,能打破近似并列,给出有差异的排名。

诚实地看待它的实用性

  • 这是一个连续时间的模拟问题,而非已知有加速的算法。当前的量子 PageRank 主要靠模拟开放系统动力学来实现,对真实网络规模的图,目前并无相对经典稀疏矩阵幂法的、已被证明的渐近加速。
  • 编码图本身就是成本。把一张 N 节点的图载入量子态、再读出 N 个占据概率,其代价会侵蚀掉演化阶段任何可能的收益——这与众多量子算法面临的"数据进出"瓶颈如出一辙。
  • 它的价值更多在于排序的语义而非速度。真正独特的是它打破退化的能力,而非更快地算出排名。把它当作经典 PageRank 的一个语义增强变体来理解,比当作其加速版更贴切。
  • α 的选择仍然要紧。和经典版本一样,传送概率 1−α 调控着排名对图结构的敏感度;它是建模选择,不会因为换成量子游走就消失。

算法逐步拆解

  1. 由图构造 Google 矩阵 G(链接矩阵叠加传送项,由 α 加权)。
  2. 把 G 编码进一个 Lindblad 生成元,使相干量子游走带有少量耗散。
  3. 从一个均匀初态出发,对开放系统动力学随时间积分。
  4. 读取稳态的各节点占据概率,作为重要性得分排序。

对照代码理解

请对照上文原理来读下面这段:from_google_matrix(G, alpha=0.85) 正是把带传送项的 Google 矩阵转成一个 Lindblad 生成元 LSchedule 给出积分的时间步;evolveuniform_state 出发演化开放系统动力学;而 final_occupations() 读出的正是稳态占据概率——即节点重要性得分。

import qalgora
from qalgora import operators
import numpy as np

# build the Lindblad generator from the graph's Google matrix G
L = operators.from_google_matrix(G, alpha=0.85)

schedule = qalgora.Schedule(steps=np.linspace(0, 10, 100), parameters=["t"])
result = qalgora.evolve(L, dimensions=dims, schedule=schedule,
                        initial_state=uniform_state)
ranking = result.final_occupations()      # node importance scores
规范接口 · 参考实现暂未包含
此示例展示的是 qalgora-Q 规范中的接口(或第三方库),开放参考实现目前尚未内置,仅用于说明预期用法;如需立即运行,请使用参考实现已支持的核心 API。
为何用量子
量子游走可能区分一些经典同分但在更高阶连接结构或动力学响应上不同的节点;但受严格图自同构对称性保护的节点,任何不破坏该对称性的方法都不应给出不同排名。其独特之处在于排序的分辨力,而非算得更快——读这段代码时请把这一点记在心里。开放系统与 Lindblad 方程页面解释了这里赖以收敛到稳态的耗散动力学。