Metadata-Version: 2.4
Name: graph-universe
Version: 0.1.2
Summary: A library for generating synthetic graph families for inductive generalization experiments of graph learning models.
Author-email: Louis Van Langendonck <louis.van.langendonck@upc.edu>, Guillermo Bernardez <guillermo_bernardez@ucsb.edu>
License: MIT License
        
        Copyright (c) 2025-2026 Louis Van Langendonck, Guillermo Bernardez
        
        Permission is hereby granted, free of charge, to any person obtaining a copy
        of this software and associated documentation files (the "Software"), to deal
        in the Software without restriction, including without limitation the rights
        to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
        copies of the Software, and to permit persons to whom the Software is
        furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in all
        copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
        AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
        OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
        SOFTWARE.
        
Project-URL: Repository, https://github.com/LouisVanLangendonck/GraphUniverse
Project-URL: Homepage, https://github.com/LouisVanLangendonck/GraphUniverse
Project-URL: Bug Tracker, https://github.com/LouisVanLangendonck/GraphUniverse/issues
Project-URL: Changelog, https://github.com/LouisVanLangendonck/GraphUniverse/blob/main/CHANGELOG.md
Keywords: graph,neural-networks,pytorch,graph-generation,community-detection,synthetic-data,graph-foundation-models
Classifier: License :: OSI Approved :: MIT License
Classifier: Development Status :: 4 - Beta
Classifier: Intended Audience :: Science/Research
Classifier: Intended Audience :: Developers
Classifier: Topic :: Scientific/Engineering
Classifier: Topic :: Scientific/Engineering :: Mathematics
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Classifier: Natural Language :: English
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: numpy<3.0,>=1.21.0
Requires-Dist: scipy<2.0,>=1.7.0
Requires-Dist: networkx<4.0,>=2.6.0
Requires-Dist: torch<3.0,>=2.0.0
Requires-Dist: torch-geometric>=2.3.0
Requires-Dist: scikit-learn<2.0,>=1.0.0
Requires-Dist: matplotlib<4.0,>=3.5.0
Requires-Dist: tqdm>=4.62.0
Requires-Dist: pyyaml<7.0,>=6.0
Provides-Extra: viz
Requires-Dist: seaborn>=0.12.0; extra == "viz"
Requires-Dist: streamlit>=1.28.0; extra == "viz"
Provides-Extra: notebook
Requires-Dist: ipykernel>=6.0.0; extra == "notebook"
Requires-Dist: notebook>=6.5.0; extra == "notebook"
Requires-Dist: jupyterlab>=3.6.0; extra == "notebook"
Provides-Extra: doc
Requires-Dist: jupyter>=1.0.0; extra == "doc"
Requires-Dist: nbsphinx>=0.9.0; extra == "doc"
Requires-Dist: nbsphinx_link>=1.3.0; extra == "doc"
Requires-Dist: numpydoc>=1.5.0; extra == "doc"
Requires-Dist: sphinx>=5.0.0; extra == "doc"
Requires-Dist: sphinx_gallery>=0.13.0; extra == "doc"
Requires-Dist: pydata-sphinx-theme>=0.13.0; extra == "doc"
Requires-Dist: myst_parser>=1.0.0; extra == "doc"
Provides-Extra: lint
Requires-Dist: pre-commit>=3.0.0; extra == "lint"
Requires-Dist: ruff>=0.1.0; extra == "lint"
Provides-Extra: test
Requires-Dist: pytest>=7.0.0; extra == "test"
Requires-Dist: pytest-cov>=4.0.0; extra == "test"
Requires-Dist: coverage>=7.0.0; extra == "test"
Requires-Dist: pytest-mock>=3.10.0; extra == "test"
Provides-Extra: dev
Requires-Dist: pytest>=7.0.0; extra == "dev"
Requires-Dist: pytest-cov>=4.0.0; extra == "dev"
Requires-Dist: coverage>=7.0.0; extra == "dev"
Requires-Dist: pytest-mock>=3.10.0; extra == "dev"
Requires-Dist: pre-commit>=3.0.0; extra == "dev"
Requires-Dist: ruff>=0.1.0; extra == "dev"
Requires-Dist: seaborn>=0.12.0; extra == "dev"
Requires-Dist: streamlit>=1.28.0; extra == "dev"
Requires-Dist: ipykernel>=6.0.0; extra == "dev"
Requires-Dist: notebook>=6.5.0; extra == "dev"
Requires-Dist: jupyterlab>=3.6.0; extra == "dev"
Provides-Extra: all
Requires-Dist: pytest>=7.0.0; extra == "all"
Requires-Dist: pytest-cov>=4.0.0; extra == "all"
Requires-Dist: coverage>=7.0.0; extra == "all"
Requires-Dist: pytest-mock>=3.10.0; extra == "all"
Requires-Dist: pre-commit>=3.0.0; extra == "all"
Requires-Dist: ruff>=0.1.0; extra == "all"
Requires-Dist: seaborn>=0.12.0; extra == "all"
Requires-Dist: streamlit>=1.28.0; extra == "all"
Requires-Dist: ipykernel>=6.0.0; extra == "all"
Requires-Dist: notebook>=6.5.0; extra == "all"
Requires-Dist: jupyterlab>=3.6.0; extra == "all"
Requires-Dist: jupyter>=1.0.0; extra == "all"
Requires-Dist: nbsphinx>=0.9.0; extra == "all"
Requires-Dist: nbsphinx_link>=1.3.0; extra == "all"
Requires-Dist: numpydoc>=1.5.0; extra == "all"
Requires-Dist: sphinx>=5.0.0; extra == "all"
Requires-Dist: sphinx_gallery>=0.13.0; extra == "all"
Requires-Dist: pydata-sphinx-theme>=0.13.0; extra == "all"
Requires-Dist: myst_parser>=1.0.0; extra == "all"
Dynamic: license-file

# GraphUniverse: Enabling Systematic Evaluation of Inductive Generalization

[![PyPI](https://img.shields.io/pypi/v/graph-universe)](https://pypi.org/project/graph-universe/)
[![Python](https://img.shields.io/pypi/pyversions/graph-universe)](https://pypi.org/project/graph-universe/)
[![License](https://img.shields.io/pypi/l/graph-universe)](https://github.com/LouisVanLangendonck/GraphUniverse/blob/main/LICENSE)
[![ICLR 2026](https://img.shields.io/badge/ICLR-2026-blue)]()

**Generate families of graphs with finely controllable properties for systematic evaluation of inductive graph learning models.**

[Quick Start](#quick-start) | [Interactive UI](#interactive-ui) | [Validation](#validation--analysis) | [Paper Experiments](#for-researchers--contributors)

![Example Graph Family][graphplot]

[graphplot]: https://raw.githubusercontent.com/LouisVanLangendonck/GraphUniverse/main/assets/ExampleGraphFamily.png "Example Graph Family Visualization"

## Key Features

Synthetic graph learning benchmarks are limited to **single-graph, transductive settings**. GraphUniverse enables the first systematic evaluation of **inductive generalization** by generating entire families of graphs with:

- **Consistent Semantics**: Communities maintain stable identities across graphs
- **Fine-grained Control**: Tune homophily, degree distributions, community structure
- **Scalable Generation**: Linear scaling, thousands of graphs per minute  
- **Validated Framework**: Comprehensive parameter sensitivity analysis
- **Interactive Tool**: Web-based exploration and visualization and Downloadable Pyg-dataset object ready to train!

![GraphUniverse Methodology Graphical Overview][logo]

[logo]: https://raw.githubusercontent.com/LouisVanLangendonck/GraphUniverse/main/assets/GraphUniverseMethodologyClean.png "Methodology Overview"

---

## Installation

Install from PyPI:
```bash
pip install graph-universe
```

**For the interactive UI (streamlit) and visualization tools:**
```bash
pip install graph-universe[viz]
```

**Optional extras:**
- `[viz]` - Streamlit UI + seaborn visualization tools
- `[dev]` - Development dependencies (testing, linting)
- `[all]` - Everything (includes documentation tools)

**Install from source:**
```bash
git clone https://github.com/LouisVanLangendonck/GraphUniverse.git
cd GraphUniverse
pip install -e ".[dev]"
```

---

## Interactive UI

After installing with `[viz]`, launch the interactive dashboard:
```bash
graph-universe-ui
```

**Hosted demo:** Try it online at [graphuniverse.streamlit.app](https://graphuniverse.streamlit.app/)

**Launch from Python:**
```python
from graph_universe import launch_ui
launch_ui()  # Opens browser, press Ctrl+C to stop
```

---

## Quick Start

### Option 1: Python API with Individual Classes
```python
from graph_universe import GraphUniverse, GraphFamilyGenerator

# Create universe with 8 communities and 10-dimensional features
universe = GraphUniverse(K=8, edge_propensity_variance=0.3, feature_dim=10)

# Generate family with full parameter control
family = GraphFamilyGenerator(
    universe=universe,
    n_nodes_range=(35, 50),
    n_communities_range=(2, 6),
    homophily_range=(0.2, 0.8),
    avg_degree_range=(2.0, 10.0),
    power_law_exponent_range=(2.0, 5.0),
    degree_separation_range=(0.1, 0.7),
    seed=42
)

# Generate 30 graphs
family.generate_family(n_graphs=30, show_progress=True)

print(f"Generated {len(family.graphs)} graphs!")

# Convert to PyTorch Geometric format for training
pyg_graphs = family.to_pyg_graphs(task="community_detection")
```

### Option 2: Config-Driven Workflow

Create `config.yaml`:
```yaml
universe_parameters:
  K: 10
  edge_propensity_variance: 0.5
  feature_dim: 16
  center_variance: 1.0
  cluster_variance: 0.3
  seed: 42

family_parameters:
  n_graphs: 100
  n_nodes_range: [25, 200]
  n_communities_range: [3, 7]
  homophily_range: [0.1, 0.9]
  avg_degree_range: [2.0, 8.0]
  power_law_exponent_range: [2.0, 3.0]
  degree_separation_range: [0.4, 0.8]
  seed: 42

task: "community_detection"
```

Then load and generate:
```python
import yaml
from graph_universe import GraphUniverseDataset

with open("config.yaml") as f:
    config = yaml.safe_load(f)

dataset = GraphUniverseDataset(root="./data", parameters=config)
print(f"Generated dataset with {len(dataset)} graphs!")
```

---

## Validation & Analysis

GraphUniverse includes built-in validation to ensure generated graphs match target properties:
```python
# Validate standard graph properties
family_properties = family.analyze_graph_family_properties()
for property_name in ['node_counts', 'avg_degrees', 'homophily_levels']:
    values = family_properties[property_name]
    print(f"{property_name}: mean={np.mean(values):.3f}")

# Analyze within-graph community signals (fits Random Forest per graph)
family_signals = family.analyze_graph_family_signals()
for signal in ['structure_signal', 'feature_signal', 'degree_signal']:
    values = family_signals[signal]
    print(f"{signal}: mean={np.mean(values):.3f}")

# Measure between-graph consistency
family_consistency = family.analyze_graph_family_consistency()
for metric in ['structure_consistency', 'feature_consistency', 'degree_consistency']:
    value = family_consistency[metric]
    print(f"{metric}: {value:.3f}")
```

---

## Documentation & Support

- **GitHub Repository**: https://github.com/LouisVanLangendonck/GraphUniverse
- **PyPI Package**: https://pypi.org/project/graph-universe/
- **Issue Tracker**: https://github.com/LouisVanLangendonck/GraphUniverse/issues
- **Changelog**: https://github.com/LouisVanLangendonck/GraphUniverse/blob/main/CHANGELOG.md

---

## Citation

If you use GraphUniverse in your research, please cite:
```bibtex
@article{van2025graphuniverse,
  title={GraphUniverse: Enabling Systematic Evaluation of Inductive Generalization},
  author={Van Langendonck, Louis and Bern{\'a}rdez, Guillermo and Miolane, Nina and Barlet-Ros, Pere},
  journal={arXiv preprint arXiv:2509.21097},
  year={2025}
}
```

---

## For Researchers & Contributors

The sections below contain resources for reproducing paper experiments and contributing to development.

### Reproducing Paper Experiments

Clone the repository to access validation and experiment scripts:
```bash
git clone https://github.com/LouisVanLangendonck/GraphUniverse.git
cd GraphUniverse
pip install -e ".[dev]"
```

**Run parameter sensitivity validation (reproduces paper results):**
```bash
python experiments/validate_parameter_sensitivity.py --n-random-samples 100 --n-graphs 30
```

**Run scalability experiments:**
```bash
python experiments/scalability_experiment.py
```

---

## License

MIT License - see [LICENSE](https://github.com/LouisVanLangendonck/GraphUniverse/blob/main/LICENSE) for details.

Copyright (c) 2025 Louis Van Langendonck and Guillermo Bernardez
