# pablovd/cosmographnet architecture

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

- Interactive diagram: https://gitdiagram.com/pablovd/cosmographnet
- Repository: https://github.com/pablovd/cosmographnet

## Overview

CosmoGraphNet turns CAMELS galaxy catalogues into graphs, then trains or evaluates a graph neural network for either cosmological-parameter inference or galaxy power-spectrum prediction. The main workflow is configuration → graph-dataset construction and splitting → GNN → training/testing → saved predictions and plots. Separate capabilities include hyperparameter optimization, cross-suite evaluation, power-spectrum extrapolation tests, and graph visualization. The README documents the latter test workflows, but their implementation details were not sampled; those connections are therefore left unverified.

Main entry points: [`main.py`](https://github.com/pablovd/cosmographnet/blob/master/main.py) (Run orchestrator), [`Source/training.py`](https://github.com/pablovd/cosmographnet/blob/master/Source/training.py) (Train and test), [`visualize_graphs.py`](https://github.com/pablovd/cosmographnet/blob/master/visualize_graphs.py) (Graph visualization), [`Source/load_data.py`](https://github.com/pablovd/cosmographnet/blob/master/Source/load_data.py) (Graph construction)

## Diagram (Mermaid)

```mermaid
flowchart TD

subgraph group_workflow["Training and inference"]
  node_config["Run configuration<br/>[hyperparameters.py]"]
  node_driver["Run orchestrator<br/>[main.py]"]
  node_training["Train and test<br/>[training.py]"]
  node_models["Saved models"]
  node_constants["Shared runtime settings<br/>[constants.py]"]
end

subgraph group_architecture["Graph model"]
  node_gnn["Graph network<br/>[metalayer.py]"]
  node_message["Message passing<br/>[metalayer.py]"]
end

subgraph group_evaluation["Evaluation and analysis"]
  node_predictions["Prediction outputs"]
  node_plots["Result plotting<br/>[plotting.py]"]
  node_optimizer["Hyperparameter search"]
  node_crosstest["Cross-suite test<br/>[crosstest.py]"]
  node_psexperiment["Spectrum extrapolation<br/>[ps_test.py]"]
  node_graphview["Graph visualization"]
end

subgraph group_data["Simulation data"]
  node_graphdata["Graph construction<br/>[load_data.py]"]
  node_split["Dataset splitting<br/>[load_data.py]"]
  node_catalogues[("CAMELS catalogues")]
  node_spectra[("Power spectra")]
end

node_user(("Researcher"))

node_user -->|"runs"| node_driver
node_config -->|"configures"| node_driver
node_driver -->|"creates dataset"| node_graphdata
node_graphdata -->|"reads catalogues"| node_catalogues
node_graphdata -->|"reads targets"| node_spectra
node_driver -->|"splits dataset"| node_split
node_driver -->|"initializes"| node_gnn
node_gnn -->|"runs layers"| node_message
node_driver -->|"trains and tests"| node_training
node_training -->|"forwards batches"| node_gnn
node_training -->|"saves weights"| node_models
node_driver -->|"loads weights"| node_models
node_training -->|"saves predictions"| node_predictions
node_driver -->|"plots results"| node_plots
node_plots -->|"reads predictions"| node_predictions
node_optimizer -->|"runs trials"| node_driver
node_crosstest -->|"evaluates suites"| node_driver
node_user -->|"runs evaluation"| node_psexperiment
node_user -->|"visualizes graphs"| node_graphview
node_graphview -->|"reads catalogues"| node_catalogues
node_graphview -->|"uses plotting helpers"| node_plots
node_driver -.->|"uses runtime settings"| node_constants

click node_config "https://github.com/pablovd/cosmographnet/blob/master/hyperparameters.py"
click node_driver "https://github.com/pablovd/cosmographnet/blob/master/main.py"
click node_graphdata "https://github.com/pablovd/cosmographnet/blob/master/Source/load_data.py"
click node_split "https://github.com/pablovd/cosmographnet/blob/master/Source/load_data.py"
click node_spectra "https://github.com/pablovd/cosmographnet/tree/master/PS_files"
click node_gnn "https://github.com/pablovd/cosmographnet/blob/master/Source/metalayer.py"
click node_message "https://github.com/pablovd/cosmographnet/blob/master/Source/metalayer.py"
click node_training "https://github.com/pablovd/cosmographnet/blob/master/Source/training.py"
click node_models "https://github.com/pablovd/cosmographnet/tree/master/Models"
click node_plots "https://github.com/pablovd/cosmographnet/blob/master/Source/plotting.py"
click node_optimizer "https://github.com/pablovd/cosmographnet/blob/master/hyperparams_optimization.py"
click node_crosstest "https://github.com/pablovd/cosmographnet/blob/master/crosstest.py"
click node_psexperiment "https://github.com/pablovd/cosmographnet/blob/master/ps_test.py"
click node_graphview "https://github.com/pablovd/cosmographnet/blob/master/visualize_graphs.py"
click node_constants "https://github.com/pablovd/cosmographnet/blob/master/Source/constants.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_config,node_driver,node_training,node_models,node_constants toneBlue
class node_gnn,node_message toneAmber
class node_predictions,node_plots,node_optimizer,node_crosstest,node_psexperiment,node_graphview toneMint
class node_graphdata,node_split,node_catalogues,node_spectra toneRose
class node_user toneIndigo
```

## Components

### Training and inference

- [Run configuration](https://github.com/pablovd/cosmographnet/blob/master/hyperparameters.py): `hyperparameters.py`
- [Run orchestrator](https://github.com/pablovd/cosmographnet/blob/master/main.py): `main.py`
- [Train and test](https://github.com/pablovd/cosmographnet/blob/master/Source/training.py): `Source/training.py`
- [Saved models](https://github.com/pablovd/cosmographnet/tree/master/Models): `Models`
- [Shared runtime settings](https://github.com/pablovd/cosmographnet/blob/master/Source/constants.py): `Source/constants.py`

### Graph model

- [Graph network](https://github.com/pablovd/cosmographnet/blob/master/Source/metalayer.py): `Source/metalayer.py`
- [Message passing](https://github.com/pablovd/cosmographnet/blob/master/Source/metalayer.py): `Source/metalayer.py`

### Evaluation and analysis

- **Prediction outputs**
- [Result plotting](https://github.com/pablovd/cosmographnet/blob/master/Source/plotting.py): `Source/plotting.py`
- [Hyperparameter search](https://github.com/pablovd/cosmographnet/blob/master/hyperparams_optimization.py): `hyperparams_optimization.py`
- [Cross-suite test](https://github.com/pablovd/cosmographnet/blob/master/crosstest.py): `crosstest.py`
- [Spectrum extrapolation](https://github.com/pablovd/cosmographnet/blob/master/ps_test.py): `ps_test.py`
- [Graph visualization](https://github.com/pablovd/cosmographnet/blob/master/visualize_graphs.py): `visualize_graphs.py`

### Simulation data

- [Graph construction](https://github.com/pablovd/cosmographnet/blob/master/Source/load_data.py): `Source/load_data.py`
- [Dataset splitting](https://github.com/pablovd/cosmographnet/blob/master/Source/load_data.py): `Source/load_data.py`
- **CAMELS catalogues**
- [Power spectra](https://github.com/pablovd/cosmographnet/tree/master/PS_files): `PS_files`

### Other components

- **Researcher**

## Connections

- Researcher → Run orchestrator: runs (evidence: `README.md`)
- Run configuration → Run orchestrator: configures (evidence: `main.py`)
- Run orchestrator → Graph construction: creates dataset (evidence: `main.py`)
- Graph construction → CAMELS catalogues: reads catalogues (evidence: `Source/load_data.py`)
- Graph construction → Power spectra: reads targets (evidence: `Source/load_data.py`)
- Run orchestrator → Dataset splitting: splits dataset (evidence: `main.py`)
- Run orchestrator → Graph network: initializes (evidence: `main.py`)
- Graph network → Message passing: runs layers (evidence: `Source/metalayer.py`)
- Run orchestrator → Train and test: trains and tests (evidence: `main.py`)
- Train and test → Graph network: forwards batches (evidence: `Source/training.py`)
- Train and test → Saved models: saves weights (evidence: `Source/training.py`)
- Run orchestrator → Saved models: loads weights (evidence: `main.py`)
- Train and test → Prediction outputs: saves predictions (evidence: `Source/training.py`)
- Run orchestrator → Result plotting: plots results (evidence: `main.py`)
- Result plotting → Prediction outputs: reads predictions (evidence: `Source/plotting.py`)
- Hyperparameter search → Run orchestrator: runs trials (evidence: `hyperparams_optimization.py`)
- Cross-suite test → Run orchestrator: evaluates suites (evidence: `crosstest.py`)
- Researcher → Spectrum extrapolation: runs evaluation (evidence: `README.md`)
- Researcher → Graph visualization: visualizes graphs (evidence: `README.md`)
- Graph visualization → CAMELS catalogues: reads catalogues (evidence: `visualize_graphs.py`)
- Graph visualization → Result plotting: uses plotting helpers (evidence: `visualize_graphs.py`)
- Run orchestrator → Shared runtime settings: uses runtime settings
