# structlearning/graphedx architecture

> Architecture diagram of the GitHub repository structlearning/graphedx, 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/structlearning/graphedx
- Repository: https://github.com/structlearning/graphedx

## Overview

GraphEdX estimates graph edit distance under equal, unequal, and label-aware edit costs. The principal workflow loads graph-pair datasets, trains or evaluates a configured estimator, and reports prediction error. Its model encodes graphs, aligns node and edge representations, and estimates edit costs; the repository also provides baselines and ablation variants. The graph reflects README-documented capabilities and source-index references; unsampled implementation details are represented only where those references support the relationship.

Main entry points: [`GMN/graphembeddingnetwork.py`](https://github.com/structlearning/graphedx/blob/main/GMN/graphembeddingnetwork.py) (Graph encoder), [`src/train_graphedx.py`](https://github.com/structlearning/graphedx/blob/main/src/train_graphedx.py) (Train and test), [`utils/model_utils.py`](https://github.com/structlearning/graphedx/blob/main/utils/model_utils.py) (Model utilities), [`src/train_graphedx_label.py`](https://github.com/structlearning/graphedx/blob/main/src/train_graphedx_label.py) (Label-cost workflow)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Experiment workflow"]
  node_train["Train and test<br/>[train_graphedx.py]"]
  node_labeltrain["Label-cost workflow"]
  node_abltrain["Regularization training<br/>[train_abl_reg.py]"]
  node_data["Graph-pair datasets<br/>[data_utils.py]"]
  node_eval["GED evaluation<br/>[evaluation.py]"]
end

subgraph group_ged["GraphEdX estimator"]
  node_gedx["GraphEdX model<br/>[graphedx.py]"]
  node_gedxlabel["Label-cost model<br/>[graphedx_label.py]"]
  node_ablreg["Regularization variant<br/>[abl_reg.py]"]
  node_ablmax["Max-pooling ablation<br/>[abl_max.py]"]
  node_ablnodeedge["Node-edge ablation"]
  node_ablsparse["Sparse ablation<br/>[abl_sparse.py]"]
  node_ablscores["Baseline scoring ablation"]
end

subgraph group_gmn["Graph representation"]
  node_encoder["Graph encoder"]
  node_matching["Graph matching"]
  node_fastmatching["Fast matching"]
  node_segment["Segment aggregation<br/>[segment.py]"]
  node_config["GMN configuration<br/>[configure.py]"]
  node_gmnloss["GMN training loss<br/>[loss.py]"]
end

subgraph group_baselines["Baselines and ablations"]
  node_baseline["Baseline estimators<br/>[GMN.py]"]
  node_basework["Baseline workflows<br/>[train.py]"]
end

subgraph group_shared["Shared utilities"]
  node_common["Model utilities<br/>[model_utils.py]"]
  node_training["Training utilities<br/>[training_utils.py]"]
  node_helpers["Runtime helpers<br/>[utils.py]"]
end

node_user(("Researcher"))

node_user -->|"runs"| node_train
node_train -->|"loads pairs"| node_data
node_train -->|"selects model"| node_gedx
node_train -->|"imports utilities"| node_common
node_train -->|"imports utilities"| node_training
node_train -->|"imports utilities"| node_helpers
node_train -.->|"evaluates predictions"| node_eval
node_user -->|"runs"| node_labeltrain
node_labeltrain -->|"loads label data"| node_data
node_labeltrain -->|"selects model"| node_gedxlabel
node_user -->|"runs"| node_abltrain
node_abltrain -.->|"trains variant"| node_ablreg
node_gedx -->|"uses encoder"| node_encoder
node_gedx -->|"uses Sinkhorn"| node_common
node_gedxlabel -->|"uses model utilities"| node_common
node_ablreg -->|"uses encoder"| node_encoder
node_ablreg -->|"computes alignment"| node_common
node_ablmax -->|"uses encoder"| node_encoder
node_ablnodeedge -->|"uses encoder"| node_encoder
node_ablsparse -->|"uses encoder"| node_encoder
node_ablscores -->|"uses encoder"| node_encoder
node_encoder -->|"aggregates with"| node_segment
node_matching -->|"extends embedding"| node_encoder
node_fastmatching -->|"uses embedding"| node_encoder
node_user -->|"runs baseline"| node_basework
node_basework -->|"uses datasets"| node_data
node_basework -->|"configures model"| node_baseline
node_baseline -->|"uses embedding"| node_encoder
node_eval -->|"uses loss"| node_gmnloss
node_train -.->|"configures GMN"| node_config

click node_train "https://github.com/structlearning/graphedx/blob/main/src/train_graphedx.py"
click node_labeltrain "https://github.com/structlearning/graphedx/blob/main/src/train_graphedx_label.py"
click node_abltrain "https://github.com/structlearning/graphedx/blob/main/src/train_abl_reg.py"
click node_data "https://github.com/structlearning/graphedx/blob/main/utils/data_utils.py"
click node_eval "https://github.com/structlearning/graphedx/blob/main/GMN/evaluation.py"
click node_gedx "https://github.com/structlearning/graphedx/blob/main/models/graphedx.py"
click node_gedxlabel "https://github.com/structlearning/graphedx/blob/main/models/graphedx_label.py"
click node_ablreg "https://github.com/structlearning/graphedx/blob/main/models/ablations/abl_reg.py"
click node_ablmax "https://github.com/structlearning/graphedx/blob/main/models/ablations/abl_max.py"
click node_ablnodeedge "https://github.com/structlearning/graphedx/blob/main/models/ablations/abl_node_edge_only.py"
click node_ablsparse "https://github.com/structlearning/graphedx/blob/main/models/ablations/abl_sparse.py"
click node_ablscores "https://github.com/structlearning/graphedx/blob/main/models/ablations/abl_baselines_scoring.py"
click node_encoder "https://github.com/structlearning/graphedx/blob/main/GMN/graphembeddingnetwork.py"
click node_matching "https://github.com/structlearning/graphedx/blob/main/GMN/graphmatchingnetwork.py"
click node_fastmatching "https://github.com/structlearning/graphedx/blob/main/GMN/fast_graphmatchingnetwork.py"
click node_segment "https://github.com/structlearning/graphedx/blob/main/GMN/segment.py"
click node_config "https://github.com/structlearning/graphedx/blob/main/GMN/configure.py"
click node_gmnloss "https://github.com/structlearning/graphedx/blob/main/GMN/loss.py"
click node_baseline "https://github.com/structlearning/graphedx/blob/main/baselines/models/GMN.py"
click node_basework "https://github.com/structlearning/graphedx/blob/main/baselines/src/train.py"
click node_common "https://github.com/structlearning/graphedx/blob/main/utils/model_utils.py"
click node_training "https://github.com/structlearning/graphedx/blob/main/utils/training_utils.py"
click node_helpers "https://github.com/structlearning/graphedx/blob/main/utils/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_train,node_labeltrain,node_abltrain,node_data,node_eval toneBlue
class node_gedx,node_gedxlabel,node_ablreg,node_ablmax,node_ablnodeedge,node_ablsparse,node_ablscores toneAmber
class node_encoder,node_matching,node_fastmatching,node_segment,node_config,node_gmnloss toneMint
class node_baseline,node_basework toneRose
class node_common,node_training,node_helpers,node_user toneIndigo
```

## Components

### Experiment workflow

- [Train and test](https://github.com/structlearning/graphedx/blob/main/src/train_graphedx.py): `src/train_graphedx.py`
- [Label-cost workflow](https://github.com/structlearning/graphedx/blob/main/src/train_graphedx_label.py): `src/train_graphedx_label.py`
- [Regularization training](https://github.com/structlearning/graphedx/blob/main/src/train_abl_reg.py): `src/train_abl_reg.py`
- [Graph-pair datasets](https://github.com/structlearning/graphedx/blob/main/utils/data_utils.py): `utils/data_utils.py`
- [GED evaluation](https://github.com/structlearning/graphedx/blob/main/GMN/evaluation.py): `GMN/evaluation.py`

### GraphEdX estimator

- [GraphEdX model](https://github.com/structlearning/graphedx/blob/main/models/graphedx.py): `models/graphedx.py`
- [Label-cost model](https://github.com/structlearning/graphedx/blob/main/models/graphedx_label.py): `models/graphedx_label.py`
- [Regularization variant](https://github.com/structlearning/graphedx/blob/main/models/ablations/abl_reg.py): `models/ablations/abl_reg.py`
- [Max-pooling ablation](https://github.com/structlearning/graphedx/blob/main/models/ablations/abl_max.py): `models/ablations/abl_max.py`
- [Node-edge ablation](https://github.com/structlearning/graphedx/blob/main/models/ablations/abl_node_edge_only.py): `models/ablations/abl_node_edge_only.py`
- [Sparse ablation](https://github.com/structlearning/graphedx/blob/main/models/ablations/abl_sparse.py): `models/ablations/abl_sparse.py`
- [Baseline scoring ablation](https://github.com/structlearning/graphedx/blob/main/models/ablations/abl_baselines_scoring.py): `models/ablations/abl_baselines_scoring.py`

### Graph representation

- [Graph encoder](https://github.com/structlearning/graphedx/blob/main/GMN/graphembeddingnetwork.py): `GMN/graphembeddingnetwork.py`
- [Graph matching](https://github.com/structlearning/graphedx/blob/main/GMN/graphmatchingnetwork.py): `GMN/graphmatchingnetwork.py`
- [Fast matching](https://github.com/structlearning/graphedx/blob/main/GMN/fast_graphmatchingnetwork.py): `GMN/fast_graphmatchingnetwork.py`
- [Segment aggregation](https://github.com/structlearning/graphedx/blob/main/GMN/segment.py): `GMN/segment.py`
- [GMN configuration](https://github.com/structlearning/graphedx/blob/main/GMN/configure.py): `GMN/configure.py`
- [GMN training loss](https://github.com/structlearning/graphedx/blob/main/GMN/loss.py): `GMN/loss.py`

### Baselines and ablations

- [Baseline estimators](https://github.com/structlearning/graphedx/blob/main/baselines/models/GMN.py): `baselines/models/GMN.py`
- [Baseline workflows](https://github.com/structlearning/graphedx/blob/main/baselines/src/train.py): `baselines/src/train.py`

### Shared utilities

- [Model utilities](https://github.com/structlearning/graphedx/blob/main/utils/model_utils.py): `utils/model_utils.py`
- [Training utilities](https://github.com/structlearning/graphedx/blob/main/utils/training_utils.py): `utils/training_utils.py`
- [Runtime helpers](https://github.com/structlearning/graphedx/blob/main/utils/utils.py): `utils/utils.py`

### Other components

- **Researcher**

## Connections

- Researcher → Train and test: runs
- Train and test → Graph-pair datasets: loads pairs (evidence: `src/train_graphedx.py`)
- Train and test → GraphEdX model: selects model
- Train and test → Model utilities: imports utilities (evidence: `src/train_graphedx.py`)
- Train and test → Training utilities: imports utilities (evidence: `src/train_graphedx.py`)
- Train and test → Runtime helpers: imports utilities (evidence: `src/train_graphedx.py`)
- Train and test → GED evaluation: evaluates predictions
- Researcher → Label-cost workflow: runs
- Label-cost workflow → Graph-pair datasets: loads label data (evidence: `src/train_graphedx_label.py`)
- Label-cost workflow → Label-cost model: selects model (evidence: `src/train_graphedx_label.py`)
- Researcher → Regularization training: runs
- Regularization training → Regularization variant: trains variant
- GraphEdX model → Graph encoder: uses encoder (evidence: `models/graphedx.py`)
- GraphEdX model → Model utilities: uses Sinkhorn (evidence: `models/graphedx.py`)
- Label-cost model → Model utilities: uses model utilities (evidence: `models/graphedx_label.py`)
- Regularization variant → Graph encoder: uses encoder (evidence: `models/ablations/abl_reg.py`)
- Regularization variant → Model utilities: computes alignment (evidence: `models/ablations/abl_reg.py`)
- Max-pooling ablation → Graph encoder: uses encoder (evidence: `models/ablations/abl_max.py`)
- Node-edge ablation → Graph encoder: uses encoder (evidence: `models/ablations/abl_node_edge_only.py`)
- Sparse ablation → Graph encoder: uses encoder (evidence: `models/ablations/abl_sparse.py`)
- Baseline scoring ablation → Graph encoder: uses encoder (evidence: `models/ablations/abl_baselines_scoring.py`)
- Graph encoder → Segment aggregation: aggregates with (evidence: `GMN/graphembeddingnetwork.py`)
- Graph matching → Graph encoder: extends embedding (evidence: `GMN/graphmatchingnetwork.py`)
- Fast matching → Graph encoder: uses embedding (evidence: `GMN/fast_graphmatchingnetwork.py`)
- Researcher → Baseline workflows: runs baseline
- Baseline workflows → Graph-pair datasets: uses datasets (evidence: `baselines/src/train.py`)
- Baseline workflows → Baseline estimators: configures model (evidence: `baselines/src/train.py`)
- Baseline estimators → Graph encoder: uses embedding (evidence: `baselines/models/GMN.py`)
- GED evaluation → GMN training loss: uses loss (evidence: `GMN/evaluation.py`)
- Train and test → GMN configuration: configures GMN
