# andreaunali/automatic-graph-generation-for-gnns architecture

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

- Interactive diagram: https://gitdiagram.com/andreaunali/automatic-graph-generation-for-gnns
- Repository: https://github.com/andreaunali/automatic-graph-generation-for-gnns

## Overview

This is a Python library and batch runner for generating image-derived graphs and measuring their structure. The principal workflow reads graph-description JSON, applies each of five connectivity strategies, writes graph JSON with edges, then analyzes the generated graphs and adds structural metrics. The shared generator layer handles common validation and distance-based construction; the README documents capabilities beyond the partial source excerpts. Links are limited to relationships shown in the runner, excerpts, or README.

Main entry points: [`main.py`](https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/main.py) (Batch runner), [`graph_lib.py`](https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py) (Shared generator), [`DATA/data_input`](https://github.com/andreaunali/automatic-graph-generation-for-gnns/tree/main/DATA/data_input) (Graph JSON inputs)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Batch workflow"]
  node_dataset["Graph JSON inputs"]
  node_runner["Batch runner<br/>[main.py]"]
  node_generated["Generated graph JSON"]
end

subgraph group_generation["Graph generation"]
  node_base["Shared generator<br/>[graph_lib.py]"]
  node_regular["Regular morphology<br/>[graph_lib.py]"]
  node_full["Fully connected<br/>[graph_lib.py]"]
  node_random["Random morphology<br/>[graph_lib.py]"]
  node_smallworld["Small-world<br/>[graph_lib.py]"]
  node_pam["PAM small-world<br/>[graph_lib.py]"]
end

subgraph group_analysis["Graph analysis"]
  node_analyzer["Graph analyzer<br/>[graph_lib.py]"]
  node_metrics["Structural metrics<br/>[graph_lib.py]"]
end

subgraph group_integration["External integration"]
  node_kmedoids["scikit-learn-extra"]
end

node_dataset -->|"reads"| node_runner
node_runner -->|"calls build"| node_regular
node_runner -->|"calls build"| node_full
node_runner -->|"calls build"| node_random
node_runner -->|"calls build"| node_smallworld
node_runner -->|"calls build"| node_pam
node_base -->|"base class"| node_regular
node_base -->|"base class"| node_full
node_base -->|"base class"| node_random
node_base -->|"base class"| node_smallworld
node_base -->|"base class"| node_pam
node_regular -->|"builds graph"| node_generated
node_full -->|"builds graph"| node_generated
node_random -->|"builds graph"| node_generated
node_smallworld -->|"builds graph"| node_generated
node_pam -->|"builds graph"| node_generated
node_runner -->|"writes JSON"| node_generated
node_runner -->|"calls analyze"| node_analyzer
node_analyzer -->|"computes"| node_metrics
node_pam -->|"uses PAM"| node_kmedoids

click node_dataset "https://github.com/andreaunali/automatic-graph-generation-for-gnns/tree/main/DATA/data_input"
click node_runner "https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/main.py"
click node_base "https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py"
click node_regular "https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py"
click node_full "https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py"
click node_random "https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py"
click node_smallworld "https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py"
click node_pam "https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py"
click node_analyzer "https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py"
click node_metrics "https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.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_dataset,node_runner,node_generated toneBlue
class node_base,node_regular,node_full,node_random,node_smallworld,node_pam toneAmber
class node_analyzer,node_metrics toneMint
class node_kmedoids toneRose
```

## Components

### Batch workflow

- [Graph JSON inputs](https://github.com/andreaunali/automatic-graph-generation-for-gnns/tree/main/DATA/data_input): `DATA/data_input`
- [Batch runner](https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/main.py): `main.py`
- **Generated graph JSON**

### Graph generation

- [Shared generator](https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py): `graph_lib.py`
- [Regular morphology](https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py): `graph_lib.py`
- [Fully connected](https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py): `graph_lib.py`
- [Random morphology](https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py): `graph_lib.py`
- [Small-world](https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py): `graph_lib.py`
- [PAM small-world](https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py): `graph_lib.py`

### Graph analysis

- [Graph analyzer](https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py): `graph_lib.py`
- [Structural metrics](https://github.com/andreaunali/automatic-graph-generation-for-gnns/blob/main/graph_lib.py): `graph_lib.py`

### External integration

- **scikit-learn-extra**

## Connections

- Graph JSON inputs → Batch runner: reads (evidence: `main.py`)
- Batch runner → Regular morphology: calls build (evidence: `main.py`)
- Batch runner → Fully connected: calls build (evidence: `main.py`)
- Batch runner → Random morphology: calls build (evidence: `main.py`)
- Batch runner → Small-world: calls build (evidence: `main.py`)
- Batch runner → PAM small-world: calls build (evidence: `main.py`)
- Shared generator → Regular morphology: base class (evidence: `README.md`)
- Shared generator → Fully connected: base class (evidence: `README.md`)
- Shared generator → Random morphology: base class (evidence: `README.md`)
- Shared generator → Small-world: base class (evidence: `README.md`)
- Shared generator → PAM small-world: base class (evidence: `README.md`)
- Regular morphology → Generated graph JSON: builds graph (evidence: `README.md`)
- Fully connected → Generated graph JSON: builds graph (evidence: `README.md`)
- Random morphology → Generated graph JSON: builds graph (evidence: `README.md`)
- Small-world → Generated graph JSON: builds graph (evidence: `README.md`)
- PAM small-world → Generated graph JSON: builds graph (evidence: `README.md`)
- Batch runner → Generated graph JSON: writes JSON (evidence: `main.py`)
- Batch runner → Graph analyzer: calls analyze (evidence: `main.py`)
- Graph analyzer → Structural metrics: computes (evidence: `graph_lib.py`)
- PAM small-world → scikit-learn-extra: uses PAM (evidence: `README.md`)
