# melifluos/subgraph-sketching architecture

> Architecture diagram of the GitHub repository melifluos/subgraph-sketching, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-11-24). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/melifluos/subgraph-sketching
- Repository: https://github.com/melifluos/subgraph-sketching

## Overview

subgraph-sketching is a graph link-prediction research package: it prepares graph data and supervision edges, builds either hashed link features or SEAL enclosing-subgraph examples, trains prediction models, and evaluates link scores. It also includes a separate heuristic-scoring experiment path and documents ELPH and scalable BUDDY as core approaches. The graph follows documented workflow and source-index references; unsampled internals are not treated as inspected, so uncertain connections are omitted.

Main entry points: [`src/runners/run.py`](https://github.com/melifluos/subgraph-sketching/blob/main/src/runners/run.py) (Experiment runner), [`src/data.py`](https://github.com/melifluos/subgraph-sketching/blob/main/src/data.py) (Dataset and splits), [`src/runners/run_heuristics.py`](https://github.com/melifluos/subgraph-sketching/blob/main/src/runners/run_heuristics.py) (Heuristic experiments), [`src/runners/inference.py`](https://github.com/melifluos/subgraph-sketching/blob/main/src/runners/inference.py) (Batch inference)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Experiment workflow"]
  node_runner["Experiment runner<br/>[run.py]"]
  node_data["Dataset and splits<br/>[data.py]"]
  node_train["Training loop<br/>[train.py]"]
  node_inference["Batch inference<br/>[inference.py]"]
  node_utils["Shared utilities<br/>[utils.py]"]
end

subgraph group_features["Graph features"]
  node_hashdata["Hashed link data<br/>[elph.py]"]
  node_hashing["Subgraph sketches<br/>[hashing.py]"]
  node_heuristics["Link heuristics<br/>[heuristics.py]"]
  node_sealdata["SEAL subgraphs<br/>[seal.py]"]
  node_labels["Subgraph labeling"]
  node_lcc["Largest component<br/>[lcc.py]"]
end

subgraph group_models["Prediction models"]
  node_elph["ELPH and BUDDY<br/>[elph.py]"]
  node_gnn["GNN layers<br/>[gnn.py]"]
  node_sealmodel["SEAL GNNs<br/>[seal.py]"]
  node_transx["TransX model<br/>[transx.py]"]
end

subgraph group_evaluation["Scoring and tracking"]
  node_evaluation["LP metrics<br/>[evaluation.py]"]
  node_heuristicrun["Heuristic experiments<br/>[run_heuristics.py]"]
  node_wandb["Experiment tracking setup<br/>[wandb_setup.py]"]
end

node_user(("Researcher"))

node_user -->|"configures and starts"| node_runner
node_runner -->|"loads splits"| node_data
node_runner -->|"runs training"| node_train
node_runner -->|"runs inference"| node_inference
node_runner -->|"selects model"| node_elph
node_runner -->|"selects model"| node_sealmodel
node_data -->|"uses SEAL datasets"| node_sealdata
node_data -->|"uses hashed datasets"| node_hashdata
node_data -->|"uses component utility"| node_lcc
node_hashdata -->|"computes sketches"| node_hashing
node_hashdata -->|"uses heuristic features"| node_heuristics
node_sealdata -->|"constructs labels"| node_labels
node_elph -->|"uses layers"| node_gnn
node_elph -->|"computes hashes"| node_hashing
node_sealmodel -->|"uses label encodings"| node_labels
node_inference -->|"evaluates predictions"| node_evaluation
node_heuristicrun -->|"loads graph splits"| node_data
node_heuristicrun -->|"scores candidate links"| node_heuristics
node_heuristicrun -->|"evaluates scores"| node_evaluation
node_runner -->|"configures tracking"| node_wandb
node_runner -->|"uses shared helpers"| node_utils
node_inference -->|"uses shared helpers"| node_utils

click node_runner "https://github.com/melifluos/subgraph-sketching/blob/main/src/runners/run.py"
click node_data "https://github.com/melifluos/subgraph-sketching/blob/main/src/data.py"
click node_train "https://github.com/melifluos/subgraph-sketching/blob/main/src/runners/train.py"
click node_inference "https://github.com/melifluos/subgraph-sketching/blob/main/src/runners/inference.py"
click node_hashdata "https://github.com/melifluos/subgraph-sketching/blob/main/src/datasets/elph.py"
click node_hashing "https://github.com/melifluos/subgraph-sketching/blob/main/src/hashing.py"
click node_heuristics "https://github.com/melifluos/subgraph-sketching/blob/main/src/heuristics.py"
click node_sealdata "https://github.com/melifluos/subgraph-sketching/blob/main/src/datasets/seal.py"
click node_labels "https://github.com/melifluos/subgraph-sketching/blob/main/src/labelling_tricks.py"
click node_lcc "https://github.com/melifluos/subgraph-sketching/blob/main/src/lcc.py"
click node_elph "https://github.com/melifluos/subgraph-sketching/blob/main/src/models/elph.py"
click node_gnn "https://github.com/melifluos/subgraph-sketching/blob/main/src/models/gnn.py"
click node_sealmodel "https://github.com/melifluos/subgraph-sketching/blob/main/src/models/seal.py"
click node_transx "https://github.com/melifluos/subgraph-sketching/blob/main/src/models/transx.py"
click node_evaluation "https://github.com/melifluos/subgraph-sketching/blob/main/src/evaluation.py"
click node_heuristicrun "https://github.com/melifluos/subgraph-sketching/blob/main/src/runners/run_heuristics.py"
click node_wandb "https://github.com/melifluos/subgraph-sketching/blob/main/src/wandb_setup.py"
click node_utils "https://github.com/melifluos/subgraph-sketching/blob/main/src/utils.py"

classDef toneNeutral fill:#f8fafc,stroke:#334155,stroke-width:1.5px,color:#0f172a
classDef toneBlue fill:#dbeafe,stroke:#2563eb,stroke-width:1.5px,color:#172554
classDef toneAmber fill:#fef3c7,stroke:#d97706,stroke-width:1.5px,color:#78350f
classDef toneMint fill:#dcfce7,stroke:#16a34a,stroke-width:1.5px,color:#14532d
classDef toneRose fill:#ffe4e6,stroke:#e11d48,stroke-width:1.5px,color:#881337
classDef toneIndigo fill:#e0e7ff,stroke:#4f46e5,stroke-width:1.5px,color:#312e81
classDef toneTeal fill:#ccfbf1,stroke:#0f766e,stroke-width:1.5px,color:#134e4a
class node_runner,node_data,node_train,node_inference,node_utils toneBlue
class node_hashdata,node_hashing,node_heuristics,node_sealdata,node_labels,node_lcc toneAmber
class node_elph,node_gnn,node_sealmodel,node_transx toneMint
class node_evaluation,node_heuristicrun,node_wandb toneRose
class node_user toneIndigo
```

## Components

### Experiment workflow

- [Experiment runner](https://github.com/melifluos/subgraph-sketching/blob/main/src/runners/run.py): `src/runners/run.py`
- [Dataset and splits](https://github.com/melifluos/subgraph-sketching/blob/main/src/data.py): `src/data.py`
- [Training loop](https://github.com/melifluos/subgraph-sketching/blob/main/src/runners/train.py): `src/runners/train.py`
- [Batch inference](https://github.com/melifluos/subgraph-sketching/blob/main/src/runners/inference.py): `src/runners/inference.py`
- [Shared utilities](https://github.com/melifluos/subgraph-sketching/blob/main/src/utils.py): `src/utils.py`

### Graph features

- [Hashed link data](https://github.com/melifluos/subgraph-sketching/blob/main/src/datasets/elph.py): `src/datasets/elph.py`
- [Subgraph sketches](https://github.com/melifluos/subgraph-sketching/blob/main/src/hashing.py): `src/hashing.py`
- [Link heuristics](https://github.com/melifluos/subgraph-sketching/blob/main/src/heuristics.py): `src/heuristics.py`
- [SEAL subgraphs](https://github.com/melifluos/subgraph-sketching/blob/main/src/datasets/seal.py): `src/datasets/seal.py`
- [Subgraph labeling](https://github.com/melifluos/subgraph-sketching/blob/main/src/labelling_tricks.py): `src/labelling_tricks.py`
- [Largest component](https://github.com/melifluos/subgraph-sketching/blob/main/src/lcc.py): `src/lcc.py`

### Prediction models

- [ELPH and BUDDY](https://github.com/melifluos/subgraph-sketching/blob/main/src/models/elph.py): `src/models/elph.py`
- [GNN layers](https://github.com/melifluos/subgraph-sketching/blob/main/src/models/gnn.py): `src/models/gnn.py`
- [SEAL GNNs](https://github.com/melifluos/subgraph-sketching/blob/main/src/models/seal.py): `src/models/seal.py`
- [TransX model](https://github.com/melifluos/subgraph-sketching/blob/main/src/models/transx.py): `src/models/transx.py`

### Scoring and tracking

- [LP metrics](https://github.com/melifluos/subgraph-sketching/blob/main/src/evaluation.py): `src/evaluation.py`
- [Heuristic experiments](https://github.com/melifluos/subgraph-sketching/blob/main/src/runners/run_heuristics.py): `src/runners/run_heuristics.py`
- [Experiment tracking setup](https://github.com/melifluos/subgraph-sketching/blob/main/src/wandb_setup.py): `src/wandb_setup.py`

### Other components

- **Researcher**

## Connections

- Researcher → Experiment runner: configures and starts (evidence: `README.md`)
- Experiment runner → Dataset and splits: loads splits (evidence: `src/runners/run.py`)
- Experiment runner → Training loop: runs training (evidence: `src/runners/run.py`)
- Experiment runner → Batch inference: runs inference (evidence: `src/runners/run.py`)
- Experiment runner → ELPH and BUDDY: selects model (evidence: `src/runners/run.py`)
- Experiment runner → SEAL GNNs: selects model (evidence: `src/runners/run.py`)
- Dataset and splits → SEAL subgraphs: uses SEAL datasets (evidence: `src/data.py`)
- Dataset and splits → Hashed link data: uses hashed datasets (evidence: `src/data.py`)
- Dataset and splits → Largest component: uses component utility (evidence: `src/data.py`)
- Hashed link data → Subgraph sketches: computes sketches (evidence: `src/datasets/elph.py`)
- Hashed link data → Link heuristics: uses heuristic features (evidence: `src/datasets/elph.py`)
- SEAL subgraphs → Subgraph labeling: constructs labels (evidence: `src/datasets/seal.py`)
- ELPH and BUDDY → GNN layers: uses layers (evidence: `src/models/elph.py`)
- ELPH and BUDDY → Subgraph sketches: computes hashes (evidence: `src/models/elph.py`)
- SEAL GNNs → Subgraph labeling: uses label encodings (evidence: `src/models/seal.py`)
- Batch inference → LP metrics: evaluates predictions (evidence: `src/runners/inference.py`)
- Heuristic experiments → Dataset and splits: loads graph splits (evidence: `src/runners/run_heuristics.py`)
- Heuristic experiments → Link heuristics: scores candidate links (evidence: `src/runners/run_heuristics.py`)
- Heuristic experiments → LP metrics: evaluates scores (evidence: `src/runners/run_heuristics.py`)
- Experiment runner → Experiment tracking setup: configures tracking (evidence: `src/runners/run.py`)
- Experiment runner → Shared utilities: uses shared helpers (evidence: `src/runners/run.py`)
- Batch inference → Shared utilities: uses shared helpers (evidence: `src/runners/inference.py`)
