We want to recover a graph when part of its adjacency matrix is masked. Two families of methods do this: link predictors such as node2vec, GraphSAGE and LPFormer, and generative models such as DiGress and GDSS, which inpaint the masked part. Each approach leaves a gap.
The two gaps
- Link predictors score each pair of nodes separately, so they miss the coupling between the edges they predict, the way one masked edge depends on another.
- Generative models start from noise, so they do not use the scores a link predictor already provides.
Prior-Informed Flow Matching (PIFM) addresses both in two stages.
- Prior. A link predictor scores every masked pair, one pair at a time.
- Flow. A learned flow starts from those scores and corrects all the masked pairs together.
Started from any of five link predictors, PIFM ranks the masked pairs better than the predictor alone on three benchmarks.
Problem formulation
Part of a graph is hidden, and we want to recover it. A binary mask $\xi$ marks the entries of the adjacency matrix $A$ that we can see, and the observation is $A^O = \xi \odot A$. From $A^O$ and $\xi$ we reconstruct $A$. Each reconstruction should be close to its true graph, and the reconstructions together should look like real graphs.
We call a pair of nodes an observed pair when its entry in $A$ is visible, and a masked pair when it is hidden. A masked pair is an edge or a non-edge, and the observation does not say which. In the experiments on this page, every pair of nodes, edge or non-edge, is masked independently and uniformly at random, with probability one half.
We follow one graph through the page and call it the running graph. It is a protein graph from the ENZYMES test set, with 23 nodes and 45 edges. Of its 253 node pairs, 119 are masked, and 25 of the masked pairs are true edges. The figure shows the full graph, the mask and what we observe.
Edge-wise link prediction
A link predictor scores one masked pair at a time. The score of a pair is its probability of being an edge. Both node2vec and GraphSAGE build a representation $z_i$ for every node and score a pair from the representations of its two nodes. LPFormer adds attention over context nodes that it selects for each pair, and it too outputs one score per pair. We call such a predictor edge-wise, and we call its scores on the masked pairs the prior.
The scoring rule carries a model of the graph, in which each edge is drawn as
$$A_{ij} \sim \mathrm{Bernoulli}\bigl(f(z_i, z_j)\bigr), \quad i < j.$$
Here $f$ maps the representations of two nodes to an edge probability, and the draws are independent across pairs once $z_1, \dots, z_n$ are fixed. Under this model, once the representations are fixed, whether one masked pair is an edge says nothing about another. We call a dependence between the edges of a graph coupling, and this model has none.
Real graphs have coupling, and the paper’s toy example makes this concrete. We call it the square. Four nodes form the cycle 0, 1, 2, 3, and all four cycle edges are observed. The two diagonals $e_{02}$ and $e_{13}$ are masked. In this example the two diagonals always agree. Both are present with probability 0.6, which is the outcome $[1,1]$, and both are absent with probability 0.4, which is $[0,0]$. We call an outcome valid when the diagonals agree and invalid when they disagree.
A predictor that scores each diagonal on its own gives each one probability 0.6. That is the correct probability for each diagonal, but scoring them separately loses the coupling between them. Sampling the two diagonals independently gives $[1,1]$ 36% of the time, $[0,0]$ 16% of the time and an invalid outcome 48% of the time. Rounding at 0.5 gives $[1,1]$ every time. No edge-wise rule reproduces the square.
Perception-distortion tradeoff
The tradeoff comes from image restoration. Blau and Michaeli showed that when a signal is restored from a degraded observation, the restoration closest to the truth on average and the restoration that looks like real data are in general different. A restored image with the lowest error is blurry, and a sharp one has a higher error. The result does not depend on the signal being an image, and we apply it to graphs.
For any signal, the distortion is how far a reconstruction lies from its truth, on average. The perception is how far the distribution of the reconstructions lies from that of real data. Lower is better for both. The figure shows both on a photograph and on the square. The posterior mean, the average of every completion that agrees with the observation, is a blurred photograph or a square with 0.6 on each diagonal: closest to the truth on average, and unlike any real photograph or graph. A posterior sample, one such completion drawn at random, looks real and has twice the distortion.
The curve below is the lowest distortion that any estimator reaches at each level of perception. Better perception costs distortion, so the curve falls from the top left to the bottom right, and no estimator reaches the Impossible region. The two ends of the curve are known. Under squared error, the posterior mean $\mathbb{E}[A \mid A^O]$ has the lowest distortion, and an edge-wise predictor approximates it one pair at a time. It need not be a graph: in the square it is $(0.6, 0.6)$. At the other end are the estimators with perfect perception, whose reconstructions are distributed like real graphs. Freirich and colleagues showed that the one among them with the lowest distortion is the optimal transport of the posterior mean onto the distribution of real graphs.
Prior-informed start
PIFM starts its flow at the prior. Its two stages follow the two ends of the curve. In the first stage, any link predictor produces the prior, which stands in for the posterior mean. In the second stage, a flow starts from the prior and carries it toward the distribution of real graphs. We call the matrix that the flow begins from the start, $A_0$. It keeps every observed entry and fills every masked pair with the prior’s score. The figure follows the running graph from the mask through both stages. The flow returns a score for each masked pair. Cutting the scores at a threshold chosen on validation graphs gives a graph, which we compare with the truth.
Written out, the start is
$$A_0 = A^O + (1-\xi) \odot \bigl(f_{\text{prior}}(A^O) + \epsilon_s\bigr).$$
Here $f_{\text{prior}}(A^O)$ is the prior’s matrix of scores, the factor $1-\xi$ keeps only the masked pairs, and $\epsilon_s$ is small Gaussian noise. A flow from Gaussian noise starts with no information about the masked pairs. PIFM starts where the link predictor ends.
Flow refinement
The flow corrects all the masked pairs jointly, which an edge-wise predictor cannot do. It is a rectified flow. During training we take a true graph with adjacency matrix $A_1$, mask it and build its start $A_0$. The straight path between the two is $A_t = (1-t)A_0 + tA_1$ for $t$ in $[0,1]$, and its velocity is the constant $A_1 - A_0$. A network $v_\theta$ learns this velocity by regression, with the loss
$$\mathcal{L}(\theta) = \mathbb{E}_{t,\,A_0,\,A_1} \bigl\| v_\theta(A_t, t) - (A_1 - A_0) \bigr\|_F^2.$$
The expectation runs over training graphs, masks and times $t$ drawn uniformly, and the norm adds the squared error over all entries. The models behind the benchmark results on this page also add this regression at $t = 0$, the only time a one-step sampler evaluates, with weight 5.
The network is a permutation-equivariant graph network. With an equivariant prior, relabeling the nodes of the input therefore relabels the reconstruction in the same way (Theorem 1 of the paper). The network reads the whole matrix $A_t$ at once, so its correction to one masked pair can depend on every other entry. This is where the coupling between edges enters.
At inference we start from $A_0$ and take $K$ Euler steps. We call $K$ the step count, and the prior itself is $K = 0$. After every step we reset the observed entries to their values in $A^O$, so each step is
$$\hat{A} \leftarrow A^O + (1-\xi) \odot \Bigl(\hat{A} + \tfrac{1}{K}\, v_\theta\bigl(\hat{A}, \tfrac{k}{K}\bigr)\Bigr).$$
The matrix $\hat{A}$ begins at $A_0$, and $k/K$ is the time at step $k = 0, \dots, K-1$. Only the masked pairs move.
The square shows what the coupling buys. For the square the velocity that minimizes the loss has a closed form, so the figure runs the exact flow in your browser. Each sample starts at the prior $(0.6, 0.6)$ plus a little noise.
With one step every sample lands on $(0.6, 0.6)$, the posterior mean at the lowest-distortion end of the curve. With 100 steps the samples split onto the two valid outcomes in proportion 60 to 40, and none ends invalid. The paper’s trained network does the same. Over 200 samples at $K = 100$, the outcome $[1,1]$ appears with frequency 0.63 and $[0,0]$ with frequency 0.37, and no sample is invalid.
Refinement on a real graph
On the running graph, one step of the flow ranks the masked pairs better than the prior. Its start is the LPFormer prior, and the flow is the one trained on ENZYMES. On the 119 masked pairs, the prior ranks true edges above non-edges with an area under the ROC curve (AUC) of 68.6, in percent as everywhere on this page. One step of the flow raises it to 84.6.
The prior is confident. Of its masked-pair scores, 84% lie within 0.1 of 0 or 1, and 15 of the 26 pairs it scores above 0.9 are non-edges. One step softens the scores, so that only 25% stay that close to 0 or 1, and it reorders them. The AUC gain comes from this new order. More steps push the scores back toward 0 and 1, and the AUC falls to 77.0 at $K = 2$, 72.5 at $K = 10$ and 69.1 at $K = 100$. At $K = 100$, 68% of the scores lie within 0.1 of 0 or 1. The one-step reconstruction ranks the masked pairs best, and the many-step reconstruction moves toward a graph.
Effect of the step count
We observe the perception-distortion tradeoff as the step count grows: one step gives the lowest distortion, and on sparse graphs many steps give the best perception. We measure distortion as 100 minus the AUC on the masked pairs, and perception as the NSPDK MMD² between the reconstructed graphs and the real test graphs. The figure plots them on the axes of the schematic, with the LPFormer prior, on ENZYMES and on two more benchmarks, PROTEINS and IMDB-B.
On ENZYMES one step reaches AUC 73.16 at MMD² 0.2472. At $K = 100$ the AUC is 60.99 and the MMD² falls to 0.0796. That is 3.1 times lower than at one step and below the prior’s 0.1254. PROTEINS follows the same path. One step gives AUC 74.12 at MMD² 0.1650, and $K = 100$ gives AUC 63.84 at MMD² 0.0468, which is 3.5 times lower. On the denser IMDB-B graphs one step already gives both the highest AUC and the lowest MMD².
The step count selects one of a family of reconstructions. One step returns an improved estimate of the posterior mean, which ranks the masked pairs best. Many steps return a sample that targets the distribution of real graphs. So we set $K$ by the use: one step to rank masked pairs, many steps to draw sparse graphs close to real ones.
Results
PIFM improves each of the five priors on all three benchmarks. The benchmarks are the TU datasets ENZYMES, PROTEINS and IMDB-B, masked as in the first section. The prior comes from one of five link predictors, node2vec, GraphSAGE, VGAE, NCNC or LPFormer, and we report AUC on the masked pairs, averaged over five seeds.
The table gives each prior alone and PIFM started from it. PIFM has the higher AUC in all 15 pairs of prior and dataset. LPFormer is the strongest prior. PIFM lifts it from 65.62 to 73.16 on ENZYMES, from 67.67 to 74.12 on PROTEINS and from 89.79 to 94.99 on IMDB-B. The largest gains are on IMDB-B: PIFM lifts GraphSAGE from 73.51 to 93.46 and VGAE from 69.75 to 92.46. The plot under the table shows the size of each gain.
Methods that use no prior rank the masked pairs less well than PIFM started from LPFormer. DiGress with RePaint reaches 58.99, 61.94 and 88.37 AUC on the three datasets, and a flow started from Gaussian noise reaches 58.45, 61.29 and 84.66, against 73.16, 74.12 and 94.99 for PIFM.
Conclusion
PIFM splits graph reconstruction into two stages.
- Prior. The prior stands in for the posterior mean, one masked pair at a time.
- Flow. The flow learns a joint correction over all the masked pairs, and on the square it recovers the coupling.
Any link predictor can serve as the prior. One step of the flow gives the lowest distortion, and on sparse graphs many steps give the best perception.
Three directions come next. The first is to test edge coupling directly on real benchmarks, as the square tests it on four nodes. The second is to reconstruct large graphs in full, with sparse or block-wise training in place of the dense matrix of all node pairs. The third is to build discrete and categorical flows for graphs whose nodes and edges carry types.
Paper, code and citation
The paper is on OpenReview, and the code is on GitHub.
@article{chen2026pifm,
title = {Prior-Informed Flow Matching for Graph Reconstruction},
author = {Chen, Haoming and Zilberstein, Nicolas and Segarra, Santiago},
journal = {Transactions on Machine Learning Research},
year = {2026},
url = {https://openreview.net/forum?id=9sEWrLXGPp}
}