SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2606.30249 · 2026

Curvature-Guided Sheaf Diffusion for Unsupervised Community Detection on Heterophilic Graphs

Feifan Wang

arXiv · PDF

Code that ran

1 of 1 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (0 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 1 has no contract verdict; 0 failures of our instrument; 0 no recorded run), measured 2026-11-23; bodies inline only under a permissive licence as GitHub detects it. Not a reproduction of the paper's results.

"Ran" means the function executed on a synthesized input and returned a value. It is not a reproduction of the paper's results. This record, dated, as JSON: /api/ran/2606.30249.json · badge: /api/ran/2606.30249.svg

Each repository's role is a label: a classifier's output recorded on the link, or, where no role is recorded, what the Papers with Code archive marked. The line under it names its basis. Neither says who wrote the code.

RepositoryRoleRan
woodywff/cgsd community
Papers with Code archive
1 ran · 0 no recorded run
FunctionStatusWhere it lives
SheafDiffusion Ran
ran on a synthesized input
woodywff/cgsd/cgsd/sheaf.py
code served (permissive licence) · get_code("ec5a50bbda19c483")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, class construct-then-call prompt, model not recorded) and returned Tensor, ndim 2, dtype family float; no output shape is stated. The image it ran in was not recorded. If your copy returns the same type and ndim on these inputs, it matched what we observed; nothing here checks that. It does NOT mean the output is correct: nothing has compared it to the paper.

import numpy as np
import torch
import torch.nn as nn
from torch_geometric.utils import degree

class SheafDiffusion(nn.Module):
    """Curvature-guided sheaf diffusion with self-loops and residual connection.

    Pure torch; no labels.
    """

    def __init__(self, in_features: int, out_features: int, n_heads: int=2, dropout: float=0.5):
        super().__init__()
        self.n_heads = n_heads
        self.head_projections = nn.ModuleList([nn.Linear(in_features, out_features, bias=False) for _ in range(n_heads)])
        self.residual = nn.Linear(in_features, out_features * n_heads, bias=False)
        self._init_weights()

    def _init_weights(self):
        for proj in self.head_projections:
            nn.init.xavier_uniform_(proj.weight, gain=1.414)
        nn.init.xavier_uniform_(self.residual.weight, gain=1.414)

    def forward(self, x: torch.Tensor, edge_index: torch.Tensor, curvature: torch.Tensor | np.ndarray | None=None) -> torch.Tensor:
        """Apply curvature-guided sheaf diffusion.

        Args:
            x: [N, in_features]
            edge_index: [2, E]
            curvature: [E] edge-wise curvature values
        Returns:
            [N, out_features * n_heads]
        """
        N = x.shape[0]
        row, col = edge_index
        E = row.shape[0]
        deg = degree(row, N, dtype=x.dtype)
        deg_inv_sqrt = deg.pow(-0.5)
        deg_inv_sqrt[~torch.isfinite(deg_inv_sqrt)] = 0
        norm = deg_inv_sqrt[row] * deg_inv_sqrt[col]
        if curvature is not None:
            curv = curvature if isinstance(curvature, torch.Tensor) else torch.tensor(curvature, dtype=x.dtype, device=x.device)
            curv_norm = torch.sigmoid(curv)
            edge_w = norm * curv_norm
        else:
            edge_w = norm
        head_outputs = []
        for h in range(self.n_heads):
            h_x = self.head_projections[h](x)
            msg = h_x[col] * edge_w.unsqueeze(1)
            out_h = torch.zeros_like(h_x)
            out_h.index_add_(0, row, msg)
            head_outputs.append(out_h)
        out = torch.cat(head_outputs, dim=1)
        residual = self.residual(x)
        out = 0.5 * out + 0.5 * residual
        return out


INIT_ARGS = {
    'in_features': 4,
    'out_features': 3,
    'n_heads': 2,
    'dropout': 0.5,
}

ARGS = {
    'x': torch.randn(2, 4),
    'edge_index': torch.tensor([[0, 1, 0, 1], [1, 0, 0, 1]], dtype=torch.long),
    'curvature': torch.randn(4),
}

model = SheafDiffusion(**INIT_ARGS)
output = model(**ARGS)
print(output.shape)
Setup block drafted by
a language model, class construct-then-call prompt, model not recorded
Imports
numpy, torch, torch_geometric — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Tensor, ndim 2, dtype family float — no output shape is stated: observe_signature.py observed this class with its constructor sizes canonicalised where it could, which the node does not record, so its shape is not stated as this setup block's
dtype family
int means an integer dtype; float means any other dtype the instrument saw, bool and complex included (fixture_check.py records only these two families)
Environment
image not recorded; re-verify against syntology-harvest-sandbox:v5-deps; not recorded for this sample: the harness installs a cuda-to-cpu shim (cuda_shim.py) before every sample and no run records whether a sample needed it; seed: torch and numpy seeded to 0 by the harness immediately before the class was constructed from INIT_ARGS (fixture_check.py)

Also present in other papers' code

Of 1 samples lifted from this paper's linked repositories, 1 carry a function identity and 0 do not. Of the 1 distinct functions with an identity, 0 are also present in other papers whose code we hold (0 with at least one paper dated earlier, 0 the same month, 0 later) and 1 are only here among the 52,977 papers whose code Syntology holds (as of 2026-09-26).

Only here means: among the 52,977 papers whose code Syntology holds (51,887 with lifted samples, 1,090 through their assemblies only), as of 2026-09-26, no other paper's lifted samples or current assembly bricks contain an identical function body after normalisation.

Presence, not direction: an identical function body in two papers' repositories does not say who wrote it, which came from which, or that either paper's method rests on it. Matching is exact after normalisation, so a renamed or edited function is not matched. Dates are when papers appeared, not when code was written. Only .py files the harvester lifted are covered; notebooks are not read. A new-style arXiv id YYMM.NNNN dates a paper to the month 20YY-MM; otherwise Paper.year dates it to the year; otherwise it is undated. Dates are when the paper appeared, not when the code was written. Read 2026-11-23.

Repositories linked to this paper

Some links come from the archived Papers with Code dataset (CC BY-SA 4.0): attribution and licence.

Abstract

Detecting communities in heterophilic graphs-where connected nodes often belong to different classes-is hard for unsupervised methods: classical modularity and spectral methods are feature agnostic, while deep graph-clustering methods rely on contrastive or generative machinery that is opaque. We propose Curvature-Guided Sheaf Diffusion (CGSD), a fully unsupervised community-detection algorithm that uses the discrete Forman-Ricci curvature of each edge as its single topological signal, propagated through every stage of an end-to-end pipeline. CGSD makes three concrete contributions: (i) a curvaturegated sheaf-diffusion encoder that gates edge messages by σ(κ e ) and is trained from three label-free structural losses (modularity, anticollapse, curvature-weighted reconstruction); (ii) a curvature-aware spectral clusterer (CSpec) that re-weights the k-NN affinity of the embedding by σ(ακ e * ) before Ng-Jordan-Weiss; and (iii) a unified labelfree evaluation against nine truly-unsupervised baselines. On five heterophilic benchmarks (Cora, Cornell, Texas, Wisconsin, Chameleon), CGSD wins outright on Wisconsin and Chameleon and is competitive on the remaining three against nine unsupervised baselines. The gain over the strongest baseline is driven by the clusterer, not the encoder: on the same embedding, CSpec improves mean NMI from 0.091 with K-Means to 0.107 (+15%, paired t-test p = 0.008). The mechanism is interpretable: intra-community and inter-community curvature distributions are visibly separated. Code is open-sourced at https://github.com/woodywff/cgsd.

For agents

The same record, over MCP at https://syntology.ai/mcp:

get_harvested_code_for_paper("2606.30249")
get_code_for_paper("2606.30249")
have("2606.30249")

The run record, dated, one paper per request, free:

curl https://syntology.ai/api/ran/2606.30249.json

A badge for a README (the split and the date, never a ratio):

[![Syntology run record](https://syntology.ai/api/ran/2606.30249.svg)](https://syntology.ai/paper/2606.30249)

Connect an agent — have() is free.