SYNTOLOGY HomeExplorerAtlasCodeMethodologyAboutDevelopersFeedPricing
Paper · 2112.13143 · NeurIPS · 2022

GREED: A Neural Framework for Learning Graph Distance Functions

Yogish Sabharwal, Rishabh Ranjan, Siddharth Grover, Sourav Medya, Venkat Chakravarthy, Sayan Ranu

arXiv · PDF · Open in the Atlas

Code that ran

6 of 15 samples (functions and classes) lifted from this paper's linked repositories executed on a synthesized input in Syntology's jail (2 of them constructed an object rather than computing a result; 0 honoured the contract we drafted, 0 violated it and 6 have no contract verdict; 0 failures of our instrument; 9 no recorded run), measured 2026-11-23; repository links from the Papers with Code archive attributed under CC BY-SA, no affiliation; 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/2112.13143.json · badge: /api/ran/2112.13143.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
idea-iitd/greed canonical (classifier label)
classifier basis not recorded on the link
4 ran · 8 no recorded run
idea-iitd/neurosed marked official in Papers with Code
Papers with Code archive
2 ran · 1 no recorded run
FunctionStatusWhere it lives
EmbedModel Ran
ran on a synthesized input · constructed an object; no result was computed
idea-iitd/neurosed/neuro/models.py
code served (permissive licence) · get_code("24e67ae2ebba81da")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, EmbedModel: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type 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 torch
import torch_geometric as tg
from torch_geometric.data import Data, Batch

torch.manual_seed(0)

# Create a small graph dataset
def create_small_graph():
    """Create a tiny graph with 4 nodes and 3 edges"""
    x = torch.randn(4, 8)  # 4 nodes, 8 input features
    edge_index = torch.tensor([
        [0, 1, 2, 3],
        [1, 2, 3, 0]
    ], dtype=torch.long)
    return Data(x=x, edge_index=edge_index)

# Create a batch of 2 graphs
graph1 = create_small_graph()
graph1.batch = torch.tensor([0, 0, 0, 0], dtype=torch.long)

graph2 = create_small_graph()
graph2.batch = torch.tensor([1, 1, 1, 1], dtype=torch.long)

# Combine into a single batched graph
batched_graph = Batch.from_data_list([graph1, graph2])

ARGS = {
    'n_layers': 2,
    'input_dim': 8,
    'hidden_dim': 4,
    'output_dim': 3,
    'conv': 'gin',
    'pool': 'add'
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torch_geometric — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type EmbedModel — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a EmbedModel output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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: none by the harness; any seed is in the setup block
SiameseModel Ran
ran on a synthesized input · constructed an object; no result was computed
idea-iitd/neurosed/neuro/models.py
code served (permissive licence) · get_code("6be2041a0ee69000")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned an instance of its own class, SiameseModel: the run constructed the object and did not call it, so no result was computed. The image it ran in was not recorded. If your copy returns the same type 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 torch
import torch.nn as nn
import torch_geometric as tg
from torch_geometric.data import Data

torch.manual_seed(0)

# Create a minimal config object
class Config:
    device = 'cpu'
    n_workers = 0

config = Config()

# Create a minimal embedding model
class MinimalEmbedModel(nn.Module):
    def __init__(self):
        super().__init__()
        self.linear = nn.Linear(3, 4)
    
    def forward(self, x):
        # x is a Batch object from torch_geometric
        # Return embeddings of shape [num_nodes, embedding_dim]
        return self.linear(x.x)

# Create minimal graph data objects
def create_minimal_graph(num_nodes=3, num_edges=2):
    x = torch.randn(num_nodes, 3)
    edge_index = torch.randint(0, num_nodes, (2, num_edges))
    return Data(x=x, edge_index=edge_index)

# Create a minimal SiameseModel subclass for testing
class MinimalSiamese(nn.Module):
    def __init__(self, embed_model):
        super().__init__()
        self.embed_model = embed_model
        self.weighted = False
    
    def forward_emb(self, gx, hx):
        # Simple inner product similarity
        return torch.sum(gx * hx, dim=-1)
    
    def forward(self, g, h):
        if self.weighted:
            self.gs = torch.tensor([x.num_nodes for x in g.to_data_list()], device=config.device)
            self.hs = torch.tensor([x.num_nodes for x in h.to_data_list()], device=config.device)
        gx = self.embed_model(g)
        hx = self.embed_model(h)
        return self.forward_emb(gx, hx)
    
    def to(self, device):
        return super().to(device)

# Instantiate components
embed_model = MinimalEmbedModel()

ARGS = {
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torch_geometric, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type SiameseModel — the run constructed an instance of its own class and did not call it; no shape is stated — the instrument coerces any output to an array; for a SiameseModel output the recorded ndim 0 and dtype family float describe that coercion, not the output, and are not stated
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: none by the harness; any seed is in the setup block
k_hop_nbr_nx Ran
ran on a synthesized input
idea-iitd/greed/neuro/datasets.py
code served (permissive licence) · get_code("ba67b4e72ce713f6")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned Data. The image it ran in was not recorded. If your copy returns the same type 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 torch
import torch_geometric as tg
import networkx as nx

torch.manual_seed(0)

# Create a small NetworkX graph
nx_g = nx.Graph()
nx_g.add_edges_from([(0, 1), (1, 2), (2, 3), (3, 4), (1, 4)])

# Define parameters
src = 0
n_hops = 2

ARGS = {
    "nx_g": nx_g,
    "src": src,
    "n_hops": n_hops
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
networkx, torch, torch_geometric — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type Data — a Data output has no array shape of its own; none is stated
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: none by the harness; any seed is in the setup block
label_graphs Ran
ran on a synthesized input
idea-iitd/greed/neuro/utils.py
code served (permissive licence) · get_code("f37d5e53c04dea18")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list, ndim 1, 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 torch
import torch.nn.functional as F
from torch_geometric.data import Data

torch.manual_seed(0)

# Create minimal graph objects with required attributes
class MinimalGraph:
    def __init__(self, num_nodes, y_val):
        self.num_nodes = num_nodes
        self.y = y_val
        self.x = None
    
    def __getitem__(self, key):
        if key == 'y':
            return self.y
        raise KeyError(key)
    
    def __setitem__(self, key, value):
        if key == 'y':
            self.y = value
        else:
            setattr(self, key, value)
    
    def __delattr__(self, name):
        if name == 'y':
            self.y = None
        else:
            super().__delattr__(name)

# Create test graphs
graph1 = MinimalGraph(num_nodes=5, y_val=torch.tensor([0, 1, 0, 2, 1]))
graph2 = MinimalGraph(num_nodes=3, y_val=torch.tensor([1, 2, 0]))

graphs = [graph1, graph2]

ARGS = {
    'graphs': graphs,
    'num_classes': None
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torch_geometric, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list, ndim 1, dtype family float — a list output has no array shape of its own; none is stated
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: none by the harness; any seed is in the setup block
preprocess Ran
ran on a synthesized input
idea-iitd/greed/neuro/h2mn_utils.py
code served (permissive licence) · get_code("fe57c0339c66673f")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned list. The image it ran in was not recorded. If your copy returns the same type 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 torch
import torch.nn
import torch_geometric as tg
from torch_geometric.data import Data

torch.manual_seed(0)

# Create small synthetic graphs
graph1 = Data(
    x=torch.randn(5, 4),  # 5 nodes, 4 features
    edge_index=torch.tensor([[0, 1, 2, 3], [1, 2, 3, 4]], dtype=torch.long)
)

graph2 = Data(
    x=torch.randn(3, 4),  # 3 nodes, 4 features
    edge_index=torch.tensor([[0, 1], [1, 2]], dtype=torch.long)
)

graphs = [graph1, graph2]
max_degree = 3

ARGS = {
    "graphs": graphs,
    "max_degree": max_degree
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch, torch_geometric, tqdm — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type list — a list output has no array shape of its own; none is stated
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: none by the harness; any seed is in the setup block
to_pyged Ran
ran on a synthesized input
idea-iitd/greed/neuro/utils.py
code served (permissive licence) · get_code("958f56a630836334")
How it ran

Ran in Syntology's sandbox on this synthesized input (drafted by a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API) and returned tuple. The image it ran in was not recorded. If your copy returns the same type 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 torch
import torch.nn as nn

torch.manual_seed(0)

class MockGraph:
    def __init__(self):
        # x: node features, shape (num_nodes, num_features)
        # argmax will be taken along dim=1, so we need num_features > 1
        self.x = torch.tensor([
            [0.1, 0.9, 0.2, 0.3],
            [0.8, 0.1, 0.05, 0.05]
        ], dtype=torch.float32)
        
        # edge_index: shape (2, num_edges)
        # Each column is an edge (source, target)
        self.edge_index = torch.tensor([
            [0, 1, 0],
            [1, 0, 1]
        ], dtype=torch.long)

g = MockGraph()

ARGS = {
    'g': g
}
Setup block drafted by
a language model, Claude Haiku 4.5, prompt python_fixture_v1, through the batch API
Imports
torch — import names as written, not package names to install; a name the repository itself provides is not a package
Returned
type tuple — a tuple output has no array shape of its own; none is stated
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: none by the harness; any seed is in the setup block
NeuralSiameseModel Not yet run
unverified (harvested, no recorded run)
idea-iitd/neurosed/neuro/models.py
code served (permissive licence) · get_code("1c519e2c43db9290")
How it ran

no invocation recorded.

batch_of_dataset Not yet run
unverified (harvested, no recorded run)
idea-iitd/greed/neuro/utils.py
code served (permissive licence) · get_code("37246958bf6c1aec")
How it ran

no invocation recorded.

err Not yet run
unverified (harvested, no recorded run)
idea-iitd/greed/neuro/metrics.py
code served (permissive licence) · get_code("cb067683b0ecbb1b")
How it ran

no invocation recorded.

k_hop_nbr_func Not yet run
unverified (harvested, no recorded run)
idea-iitd/greed/neuro/datasets.py
code served (permissive licence) · get_code("cc5d89845905b06b")
How it ran

no invocation recorded.

mse Not yet run
unverified (harvested, no recorded run)
idea-iitd/greed/neuro/metrics.py
code served (permissive licence) · get_code("706a15018478eff5")
How it ran

no invocation recorded.

random_bfs_sample Not yet run
unverified (harvested, no recorded run)
idea-iitd/greed/neuro/datasets.py
code served (permissive licence) · get_code("339bda326bbc90d3")
How it ran

no invocation recorded.

sim_to_ged Not yet run
unverified (harvested, no recorded run)
idea-iitd/greed/neuro/h2mn_utils.py
code served (permissive licence) · get_code("99e446f9903a7a19")
How it ran

no invocation recorded.

sim_to_sed Not yet run
unverified (harvested, no recorded run)
idea-iitd/greed/neuro/h2mn_utils.py
code served (permissive licence) · get_code("46d5d380b2a8610c")
How it ran

no invocation recorded.

weighted_mse Not yet run
unverified (harvested, no recorded run)
idea-iitd/greed/neuro/metrics.py
code served (permissive licence) · get_code("c1ac97b5adf74a26")
How it ran

no invocation recorded.

Also present in other papers' code

Of 15 samples lifted from this paper's linked repositories, 15 carry a function identity and 0 do not. Of the 15 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 15 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

Among various distance functions for graphs, graph and subgraph edit distances (GED and SED respectively) are two of the most popular and expressive measures. Unfortunately, exact computations for both are NP-hard. To overcome this computational bottleneck, neural approaches to learn and predict edit distance in polynomial time have received much interest. While considerable progress has been made, there exist limitations that need to be addressed. First, the efficacy of an approximate distance function lies not only in its approximation accuracy, but also in the preservation of its properties. To elaborate, although GED is a metric, its neural approximations do not provide such a guarantee. This prohibits their usage in higher order tasks that rely on metric distance functions, such as clustering or indexing. Second, several existing frameworks for GED do not extend to SED due to SED being asymmetric. In this work, we design a novel siamese graph neural network called GREED, which through a carefully crafted inductive bias, learns GED and SED in a property-preserving manner. Through extensive experiments across 10 real graph datasets containing up to 7 million edges, we establish that GREED is not only more accurate than the state of the art, but also up to 3 orders of magnitude faster. Even more significantly, due to preserving the triangle inequality, the generated embeddings are indexable and consequently, even in a CPU-only environment, GREED is up to 50 times faster than GPU-powered baselines for graph / subgraph retrieval.

For agents

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

get_harvested_code_for_paper("2112.13143")
get_code_for_paper("2112.13143")
have("2112.13143")

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

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

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

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

Connect an agent — have() is free.