# deepgraphlearning/nbfnet architecture

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

- Interactive diagram: https://gitdiagram.com/deepgraphlearning/nbfnet
- Repository: https://github.com/deepgraphlearning/nbfnet

## Overview

NBFNet is a PyTorch/TorchDrug link-prediction framework for knowledge graphs and homogeneous graphs, including inductive relation prediction. The main workflow is configured dataset loading and splitting, task-specific sampling and scoring, Bellman-Ford-style relational message passing, then training, validation, and testing; a separate workflow visualizes ranked path interpretations. The graph preserves the documented benchmark and visualization branches. Some registry-based wiring is indirect, so those relationships are shown as unverified rather than asserted as direct calls.

Main entry points: [`script/run.py`](https://github.com/deepgraphlearning/nbfnet/blob/master/script/run.py) (Run experiments), [`script/visualize.py`](https://github.com/deepgraphlearning/nbfnet/blob/master/script/visualize.py) (Visualize paths), [`nbfnet/util.py`](https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/util.py) (Runtime utilities), [`nbfnet/dataset.py`](https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/dataset.py) (Graph datasets)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_entry["Experiment entry"]
  node_run["Run experiments<br/>[run.py]"]
  node_visualize["Visualize paths<br/>[visualize.py]"]
  node_config["Experiment configs"]
  node_runtime["Runtime utilities<br/>[util.py]"]
end

subgraph group_data["Graph data"]
  node_datasets["Graph datasets<br/>[dataset.py]"]
  node_benchmarks["Benchmark datasets<br/>[dataset.py]"]
end

subgraph group_learning["Prediction model"]
  node_task["Prediction tasks<br/>[task.py]"]
  node_model["NBFNet model<br/>[model.py]"]
  node_convolution["Relational convolution<br/>[layer.py]"]
end

subgraph group_analysis["Evaluation and interpretation"]
  node_pathviz["Path interpretation<br/>[model.py]"]
end

node_user(("Researcher"))

node_user -->|"starts training"| node_run
node_user -->|"requests paths"| node_visualize
node_run -->|"loads settings"| node_config
node_run -->|"uses utilities"| node_runtime
node_visualize -->|"uses utilities"| node_runtime
node_runtime -->|"splits dataset"| node_datasets
node_runtime -->|"builds task"| node_task
node_run -.->|"loads registry"| node_datasets
node_visualize -.->|"loads registry"| node_datasets
node_task -->|"scores queries"| node_model
node_model -->|"uses layers"| node_convolution
node_visualize -->|"requests interpretations"| node_pathviz
node_pathviz -->|"computes paths"| node_model
node_datasets -->|"loads benchmark data"| node_benchmarks
node_run -->|"trains and evaluates"| node_task
node_visualize -->|"builds solver"| node_task

click node_run "https://github.com/deepgraphlearning/nbfnet/blob/master/script/run.py"
click node_visualize "https://github.com/deepgraphlearning/nbfnet/blob/master/script/visualize.py"
click node_config "https://github.com/deepgraphlearning/nbfnet/tree/master/config"
click node_runtime "https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/util.py"
click node_datasets "https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/dataset.py"
click node_task "https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/task.py"
click node_model "https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/model.py"
click node_convolution "https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/layer.py"
click node_pathviz "https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/model.py"
click node_benchmarks "https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/dataset.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_run,node_visualize,node_config,node_runtime toneBlue
class node_datasets,node_benchmarks toneAmber
class node_task,node_model,node_convolution toneMint
class node_pathviz toneRose
class node_user toneIndigo
```

## Components

### Experiment entry

- [Run experiments](https://github.com/deepgraphlearning/nbfnet/blob/master/script/run.py): `script/run.py`
- [Visualize paths](https://github.com/deepgraphlearning/nbfnet/blob/master/script/visualize.py): `script/visualize.py`
- [Experiment configs](https://github.com/deepgraphlearning/nbfnet/tree/master/config): `config`
- [Runtime utilities](https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/util.py): `nbfnet/util.py`

### Graph data

- [Graph datasets](https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/dataset.py): `nbfnet/dataset.py`
- [Benchmark datasets](https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/dataset.py): `nbfnet/dataset.py`

### Prediction model

- [Prediction tasks](https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/task.py): `nbfnet/task.py`
- [NBFNet model](https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/model.py): `nbfnet/model.py`
- [Relational convolution](https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/layer.py): `nbfnet/layer.py`

### Evaluation and interpretation

- [Path interpretation](https://github.com/deepgraphlearning/nbfnet/blob/master/nbfnet/model.py): `nbfnet/model.py`

### Other components

- **Researcher**

## Connections

- Researcher → Run experiments: starts training (evidence: `README.md`)
- Researcher → Visualize paths: requests paths (evidence: `README.md`)
- Run experiments → Experiment configs: loads settings (evidence: `script/run.py`)
- Run experiments → Runtime utilities: uses utilities (evidence: `script/run.py`)
- Visualize paths → Runtime utilities: uses utilities (evidence: `script/visualize.py`)
- Runtime utilities → Graph datasets: splits dataset (evidence: `nbfnet/util.py`)
- Runtime utilities → Prediction tasks: builds task (evidence: `nbfnet/util.py`)
- Run experiments → Graph datasets: loads registry (evidence: `script/run.py`)
- Visualize paths → Graph datasets: loads registry (evidence: `script/visualize.py`)
- Prediction tasks → NBFNet model: scores queries (evidence: `nbfnet/task.py`)
- NBFNet model → Relational convolution: uses layers (evidence: `nbfnet/model.py`)
- Visualize paths → Path interpretation: requests interpretations (evidence: `script/visualize.py`)
- Path interpretation → NBFNet model: computes paths (evidence: `nbfnet/model.py`)
- Graph datasets → Benchmark datasets: loads benchmark data (evidence: `nbfnet/dataset.py`)
- Run experiments → Prediction tasks: trains and evaluates (evidence: `script/run.py`)
- Visualize paths → Prediction tasks: builds solver (evidence: `script/visualize.py`)
