# samarthh01/cora-link-prediction architecture

> Architecture diagram of the GitHub repository samarthh01/cora-link-prediction, generated by GitDiagram from its file tree, README and a sample of source files (last updated 2026-12-02). It is an AI-made overview: check details against the source.

- Interactive diagram: https://gitdiagram.com/samarthh01/cora-link-prediction
- Repository: https://github.com/samarthh01/cora-link-prediction

## Overview

This repository compares SQL-derived structural features with a two-layer GCN for Cora citation-link prediction. The workflow loads Cora, creates seeded train/validation/test link splits, trains and evaluates each approach, and aggregates five-seed results. The graph separates shared data preparation, SQL baseline, GCN, and experiment aggregation. Source excerpts show the principal calls; the SQL feature query is present in the tree but was not excerpted, so its internal operations are not expanded.

Main entry points: [`baseline_sql.py`](https://github.com/samarthh01/cora-link-prediction/blob/main/baseline_sql.py) (SQL baseline runner), [`gnn.py`](https://github.com/samarthh01/cora-link-prediction/blob/main/gnn.py) (GCN runner), [`run_all.py`](https://github.com/samarthh01/cora-link-prediction/blob/main/run_all.py) (Five-seed runner), [`data.py`](https://github.com/samarthh01/cora-link-prediction/blob/main/data.py) (Link splits)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_data["Data preparation"]
  node_splits["Link splits<br/>[data.py]"]
end

subgraph group_sql["SQL baseline"]
  node_sql_runner["SQL baseline runner<br/>[baseline_sql.py]"]
  node_feature_engineering["SQL features<br/>[baseline_sql.py]"]
  node_feature_query["Feature query<br/>[features.sql]"]
  node_logistic_model["Logistic regression<br/>[baseline_sql.py]"]
  node_sql_metrics["SQL evaluation<br/>[baseline_sql.py]"]
end

subgraph group_gcn["GCN model"]
  node_gcn_runner["GCN runner<br/>[gnn.py]"]
  node_gcn_encoder["GCN encoder<br/>[gnn.py]"]
  node_dot_decoder["Dot-product decoder<br/>[gnn.py]"]
  node_gcn_training["GCN training<br/>[gnn.py]"]
  node_gcn_evaluation["GCN evaluation<br/>[gnn.py]"]
end

subgraph group_experiments["Experiment results"]
  node_suite_runner["Five-seed runner<br/>[run_all.py]"]
  node_summary_output["Summary results<br/>[run_all.py]"]
end

node_researcher(("Researcher"))
node_cora[("Cora dataset")]

node_researcher -->|"runs baseline"| node_sql_runner
node_researcher -->|"runs variants"| node_gcn_runner
node_researcher -->|"runs suite"| node_suite_runner
node_cora -->|"loads dataset"| node_splits
node_sql_runner -->|"loads splits"| node_splits
node_sql_runner -->|"computes features"| node_feature_engineering
node_feature_engineering -->|"reads query"| node_feature_query
node_sql_runner -->|"fits model"| node_logistic_model
node_sql_runner -->|"evaluates scores"| node_sql_metrics
node_gcn_runner -->|"loads splits"| node_splits
node_gcn_runner -->|"trains"| node_gcn_training
node_gcn_training -->|"encodes nodes"| node_gcn_encoder
node_gcn_training -->|"scores pairs"| node_dot_decoder
node_gcn_runner -->|"evaluates checkpoints"| node_gcn_evaluation
node_gcn_evaluation -->|"encodes nodes"| node_gcn_encoder
node_gcn_evaluation -->|"scores pairs"| node_dot_decoder
node_suite_runner -->|"runs baseline"| node_sql_runner
node_suite_runner -->|"runs variants"| node_gcn_runner
node_suite_runner -->|"writes summary"| node_summary_output

click node_splits "https://github.com/samarthh01/cora-link-prediction/blob/main/data.py"
click node_sql_runner "https://github.com/samarthh01/cora-link-prediction/blob/main/baseline_sql.py"
click node_feature_engineering "https://github.com/samarthh01/cora-link-prediction/blob/main/baseline_sql.py"
click node_feature_query "https://github.com/samarthh01/cora-link-prediction/blob/main/sql/features.sql"
click node_logistic_model "https://github.com/samarthh01/cora-link-prediction/blob/main/baseline_sql.py"
click node_sql_metrics "https://github.com/samarthh01/cora-link-prediction/blob/main/baseline_sql.py"
click node_gcn_runner "https://github.com/samarthh01/cora-link-prediction/blob/main/gnn.py"
click node_gcn_encoder "https://github.com/samarthh01/cora-link-prediction/blob/main/gnn.py"
click node_dot_decoder "https://github.com/samarthh01/cora-link-prediction/blob/main/gnn.py"
click node_gcn_training "https://github.com/samarthh01/cora-link-prediction/blob/main/gnn.py"
click node_gcn_evaluation "https://github.com/samarthh01/cora-link-prediction/blob/main/gnn.py"
click node_suite_runner "https://github.com/samarthh01/cora-link-prediction/blob/main/run_all.py"
click node_summary_output "https://github.com/samarthh01/cora-link-prediction/blob/main/run_all.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_splits toneBlue
class node_sql_runner,node_feature_engineering,node_feature_query,node_logistic_model,node_sql_metrics,node_cora toneAmber
class node_gcn_runner,node_gcn_encoder,node_dot_decoder,node_gcn_training,node_gcn_evaluation toneMint
class node_suite_runner,node_summary_output toneRose
class node_researcher toneIndigo
```

## Components

### Data preparation

- [Link splits](https://github.com/samarthh01/cora-link-prediction/blob/main/data.py): `data.py`

### SQL baseline

- [SQL baseline runner](https://github.com/samarthh01/cora-link-prediction/blob/main/baseline_sql.py): `baseline_sql.py`
- [SQL features](https://github.com/samarthh01/cora-link-prediction/blob/main/baseline_sql.py): `baseline_sql.py`
- [Feature query](https://github.com/samarthh01/cora-link-prediction/blob/main/sql/features.sql): `sql/features.sql`
- [Logistic regression](https://github.com/samarthh01/cora-link-prediction/blob/main/baseline_sql.py): `baseline_sql.py`
- [SQL evaluation](https://github.com/samarthh01/cora-link-prediction/blob/main/baseline_sql.py): `baseline_sql.py`

### GCN model

- [GCN runner](https://github.com/samarthh01/cora-link-prediction/blob/main/gnn.py): `gnn.py`
- [GCN encoder](https://github.com/samarthh01/cora-link-prediction/blob/main/gnn.py): `gnn.py`
- [Dot-product decoder](https://github.com/samarthh01/cora-link-prediction/blob/main/gnn.py): `gnn.py`
- [GCN training](https://github.com/samarthh01/cora-link-prediction/blob/main/gnn.py): `gnn.py`
- [GCN evaluation](https://github.com/samarthh01/cora-link-prediction/blob/main/gnn.py): `gnn.py`

### Experiment results

- [Five-seed runner](https://github.com/samarthh01/cora-link-prediction/blob/main/run_all.py): `run_all.py`
- [Summary results](https://github.com/samarthh01/cora-link-prediction/blob/main/run_all.py): `run_all.py`

### Other components

- **Researcher**
- **Cora dataset**

## Connections

- Researcher → SQL baseline runner: runs baseline (evidence: `README.md`)
- Researcher → GCN runner: runs variants (evidence: `README.md`)
- Researcher → Five-seed runner: runs suite (evidence: `README.md`)
- Cora dataset → Link splits: loads dataset (evidence: `data.py`)
- SQL baseline runner → Link splits: loads splits (evidence: `baseline_sql.py`)
- SQL baseline runner → SQL features: computes features (evidence: `baseline_sql.py`)
- SQL features → Feature query: reads query (evidence: `baseline_sql.py`)
- SQL baseline runner → Logistic regression: fits model (evidence: `baseline_sql.py`)
- SQL baseline runner → SQL evaluation: evaluates scores (evidence: `baseline_sql.py`)
- GCN runner → Link splits: loads splits (evidence: `gnn.py`)
- GCN runner → GCN training: trains (evidence: `gnn.py`)
- GCN training → GCN encoder: encodes nodes (evidence: `gnn.py`)
- GCN training → Dot-product decoder: scores pairs (evidence: `gnn.py`)
- GCN runner → GCN evaluation: evaluates checkpoints (evidence: `gnn.py`)
- GCN evaluation → GCN encoder: encodes nodes (evidence: `gnn.py`)
- GCN evaluation → Dot-product decoder: scores pairs (evidence: `gnn.py`)
- Five-seed runner → SQL baseline runner: runs baseline (evidence: `run_all.py`)
- Five-seed runner → GCN runner: runs variants (evidence: `run_all.py`)
- Five-seed runner → Summary results: writes summary (evidence: `run_all.py`)
