Imported from agourakis82/hyperbolic-semantic-networks (
AGENTS.md). Install upstream withnpx skills add agourakis82/hyperbolic-semantic-networks. Copyright stays with the author.
AGENTS.md - AI Coding Agent Guide
Project: Hyperbolic Geometry of Semantic Networks
Version: v2.0 (Phase Transition Discovery)
Languages: Julia, Rust, Python, Sounio
Primary Language (Documentation): English (with some Portuguese/Spanish code comments)
Project Overview
This is a research codebase for analyzing hyperbolic geometry in semantic networks using Ollivier-Ricci curvature. The project implements a multi-language computational pipeline:
- Julia (v1.9+): Reference scientific computing implementation
- Rust (stable): Performance-critical curvature computation kernels
- Python (3.10+): Data processing, analysis scripts, and baseline validation
- Sounio: Type-safe experiments with epistemic computing and effect tracking
Key Discovery: Universal phase transition at โจkโฉยฒ/N โ 2.5 that determines network geometry:
โจkโฉยฒ/N < 2.0โ Hyperbolic (negative curvature, tree-like)โจkโฉยฒ/N โ 2.5โ Euclidean (critical point/phase transition)โจkโฉยฒ/N > 3.5โ Spherical (positive curvature, clique-like)
Technology Stack
Core Dependencies
Julia (julia/Project.toml):
- Graphs.jl (graph library, replaces LightGraphs)
- DataFrames.jl, CSV.jl, JSON.jl (data handling)
- Statistics.jl, LinearAlgebra.jl, Optim.jl (numerical computation)
- Plots.jl, StatsPlots.jl (visualization)
- ProgressMeter.jl, Logging.jl (utilities)
Rust (rust/Cargo.toml):
- ndarray 0.16 (numerical arrays)
- rayon 1.8 (parallel processing)
- petgraph 0.6 (graph library)
- libc 0.2 (FFI)
- criterion 0.5 (benchmarking)
Python (implicit dependencies):
- networkx, GraphRicciCurvature (curvature computation)
- numpy, scipy, pandas (numerical/data)
- matplotlib, seaborn (visualization)
- pytest (testing)
External Tools
- Sounio Compiler: Effect-tracked programming language for experiments (
souccommand) - Docker: Reproducible environment (Julia 1.9 base + Rust)
- Kubernetes: Distributed job execution (Ricci flow, null models)
- Lean 4: Mathematical formalization for proof verification
Lean 4 Formalization
The lean/ directory contains machine-checked proofs for key mathematical claims:
Status: 76% complete (~2,070 lines)
Formalized Theorems:
- โ Curvature bounds: ฮบ โ [-1, 1]
- โ Clustering bounds: C โ [0, 1]
- โ Probability measure normalization
- โ Cross-implementation equivalence (Julia/Rust/Sounio)
- โ ๏ธ Phase transition (empirical conjecture structure)
Build:
cd lean/HyperbolicSemanticNetworks
lake update
lake build
lake test
See lean/HyperbolicSemanticNetworks/doc/FORMALIZATION_REPORT.md for details.
Repository Structure
hyperbolic-semantic-networks/
โโโ README.md # Main project documentation
โโโ CHANGELOG.md # Version history
โโโ DEVELOPMENT.md # Comprehensive development guide
โโโ RUNME.md # Quick reproduction guide
โโโ CITATION.cff # Citation metadata
โโโ LICENSE # MIT license
โโโ .zenodo.json # Zenodo publication config
โโโ ZENODO_DOI.txt # DOI reference
โ
โโโ julia/ # Julia implementation (reference)
โ โโโ Project.toml # Julia dependencies
โ โโโ src/
โ โ โโโ HyperbolicSemanticNetworks.jl # Main module
โ โ โโโ Preprocessing/ # SWOW, ConceptNet, Taxonomies
โ โ โโโ Curvature/ # Ollivier-Ricci + FFI to Rust
โ โ โโโ Analysis/ # Null models, bootstrap, Ricci flow
โ โ โโโ Visualization/ # Figures, phase diagrams
โ โ โโโ Utils/ # Metrics, IO, validation
โ โโโ test/ # Test suite
โ โโโ scripts/ # Pipeline scripts
โ
โโโ lean/ # Lean 4 mathematical formalization
โ โโโ lakefile.lean # Lean build configuration
โ โโโ HyperbolicSemanticNetworks/
โ โ โโโ src/ # Formalization source
โ โ โ โโโ Basic.lean # Graph definitions
โ โ โ โโโ Curvature.lean # Ollivier-Ricci
โ โ โ โโโ PhaseTransition.lean # Critical point theory
โ โ โ โโโ ...
โ โ โโโ test/ # Unit tests
โ โ โโโ doc/ # Documentation
โ
โโโ rust/ # Rust implementation (performance)
โ โโโ Cargo.toml # Workspace config
โ โโโ curvature/ # Wasserstein distance, Sinkhorn
โ โโโ null_models/ # Configuration model, triadic-rewire
โ
โโโ code/ # Python analysis scripts
โ โโโ analysis/ # Full analysis pipeline (75+ scripts)
โ โ โโโ tests/ # pytest test suite
โ โ โโโ compute_curvature_FINAL.py
โ โ โโโ *_v6.4.py # Versioned analysis scripts
โ โโโ fmri/ # fMRI analysis extensions
โ
โโโ experiments/ # Sounio experiments
โ โโโ 01_epistemic_uncertainty/ # Phase transition sweep
โ โโโ 02_null_model/ # Configuration null ensemble
โ โโโ 03_forman_ricci/ # Forman vs Ollivier
โ โโโ 04_uncertainty_scaling/ # Entropy at phase transition
โ โโโ 05_hypercomplex/ # Sยณ, Sโท, Sยนโต embeddings
โ โโโ 06_spectral_geometry/ # Eigenvalue validation
โ โโโ 07_scale_n500/ # N=100/200 scaling
โ โโโ 08_epsilon_diagnostic/ # Epsilon parameter validation
โ
โโโ stdlib/ # Sounio standard library extensions
โ โโโ math/ # clifford.sio, homology_curvature.sio, etc.
โ
โโโ data/ # Data directory
โ โโโ raw/ # Original SWOW data (not in git)
โ โโโ processed/ # Processed networks
โ โโโ external/ # External datasets
โ
โโโ results/ # Computed results
โ โโโ experiments/ # Phase transition data
โ โโโ sounio/ # Sounio experiment outputs
โ โโโ figures/ # Generated figures
โ
โโโ manuscript/ # Academic manuscript
โ โโโ main.md # Complete manuscript
โ โโโ figures/ # Publication figures
โ
โโโ docs/ # Documentation
โ โโโ INDEX.md # Master documentation index
โ โโโ REPRODUCIBILITY.md # Reproduction guide
โ โโโ session_reports/ # Work session reports
โ โโโ planning/ # Checklists, roadmaps
โ โโโ research_reports/ # Scientific findings
โ
โโโ scripts/ # Utility scripts
โ โโโ build_rust_libs.sh
โ โโโ zenodo_publish.py # Zenodo integration
โ โโโ cleanup_repository.py # Repository maintenance
โ
โโโ tools/ # Development tools
โ โโโ zenodo_new_version.py
โ
โโโ k8s/ # Kubernetes deployments
โ โโโ ricci-flow-deployment.yaml
โ โโโ structural-nulls-job.yaml
โ
โโโ config/ # Configuration files
โโโ babelnet_conf.yml
Build Commands
Julia Setup
# Install dependencies
julia --project=julia -e 'using Pkg; Pkg.instantiate()'
# Run tests
julia --project=julia -e 'using Pkg; Pkg.test()'
# OR
julia --project=julia julia/test/runtests.jl
# Run phase transition experiment (validated reference)
julia phase_transition_pure_julia.jl
Rust Setup
cd rust
# Build all workspace members
cargo build --release
# Run tests
cargo test --workspace
# Run benchmarks
cargo bench --workspace
# Format and lint
cargo fmt --all
cargo clippy --workspace -- -D warnings
Python Setup
# Install dependencies (typically via requirements.txt or manually)
pip install networkx numpy scipy pandas matplotlib seaborn GraphRicciCurvature pytest
# Run tests
cd code/analysis
python -m pytest tests/ -v
# Run analysis pipeline
python run_analysis_pipeline.py
Sounio Experiments
# Each experiment has its own run.sh script
cd experiments/01_epistemic_uncertainty
bash run.sh
# Or compile and run manually (requires Sounio compiler)
souc run phase_transition.sio
Docker (Full Environment)
# Build image
docker build -t hyperbolic-semantic-networks .
# Run container
docker run -it -v $(pwd):/workspace hyperbolic-semantic-networks
Code Style Guidelines
Julia
- Indentation: 4 spaces
- Naming: CamelCase for types, snake_case for functions
- Documentation: Comprehensive docstrings for all public functions
- Module organization:
src/ModuleName/SubModule.jl, included in main module - Testing: Use
@testsetfor grouping, tests intest/test_*.jl
Rust
- Formatting: Use
cargo fmt --all - Linting: Use
cargo clippy --workspace -- -D warnings - Safety: All FFI functions must validate inputs
- Testing: Use
#[cfg(test)]for unit tests - Benchmarking: Use criterion for performance-critical code
Python
- Style: Follow PEP 8
- Formatting: Use
black(see Makefile targetmake format) - Type hints: Add where possible
- Testing: Use
pytestwith fixtures for common setup - Scripts: Many legacy scripts use v6.4 versioning scheme
Sounio
- Effects: Explicitly track with
with IO, Mut, Div, Panic - Types: Use fixed-size arrays
[T; N]for performance - Comments: Heavy documentation of mathematical formulas
- Structure: Clear separation of LCG, Graph, BFS, Measure, Sinkhorn, curvature
Testing Instructions
Test Organization
Julia Tests (julia/test/):
runtests.jl- Main test runnertest_preprocessing.jl- Data loading teststest_curvature.jl- Curvature computation teststest_analysis.jl- Analysis pipeline teststest_integration.jl- End-to-end teststest_regression.jl- Regression teststest_properties.jl- Property-based teststest_performance.jl- Benchmarks (optional, requires BenchmarkTools)
Rust Tests:
- Unit tests in each crate (
src/*.rswith#[cfg(test)]) - Benchmarks in
benches/directory
Python Tests (code/analysis/tests/):
test_curvature.py- Curvature computation validationtest_network_building.py- Network construction testsconftest.py- pytest fixtures
Running Tests
# Julia
julia --project=julia -e 'using Pkg; Pkg.test()'
# Rust
cd rust && cargo test --workspace
# Python
cd code/analysis && python -m pytest tests/ -v
# All (via CI)
# See .github/workflows/ci.yml for full CI pipeline
Validation
The project validates against:
- Q1 Literature: Ollivier 2009, Ni et al. 2015, 2019
- Python Baseline: GraphRicciCurvature library
- Julia Reference: Validated phase transition at N=200
- Cross-language: Numerical agreement between Julia/Rust/Sounio
Deployment & Distribution
GitHub Releases
- Use semantic versioning (current: v2.0.0)
- Tag format:
v{major}.{minor}.{patch} - See
scripts/prepare_release.shandscripts/push_release.sh
Zenodo Integration
- Config in
.zenodo.json - DOI tracked in
ZENODO_DOI.txt - Publish with:
python scripts/zenodo_publish.py - Requires
ZENODO_ACCESS_TOKENenvironment variable
Kubernetes Deployment
- Job definitions in
k8s/ - Used for distributed Ricci flow and null model generation
- Requires cluster with node labels for GPU/CPU workloads
Docker
Dockerfileprovides complete reproducible environment- Based on
julia:1.9with Rust toolchain - Pre-installs Julia and Rust dependencies
Security Considerations
Input Validation
- Rust FFI: All exported functions validate inputs before processing
- Julia: Graph validation in
Utils/Validation.jl - Python: Input sanitization in preprocessing scripts
Data Handling
- Large data files (>100MB) excluded from git (see
.gitignore) - Sensitive data should be placed in
data/external/(gitignored) - SWOW data requires separate download (see data documentation)
Dependencies
- Regular updates via
cargo updateandPkg.update() - Check for security advisories:
cargo audit(if installed) - Python: Use
pip-auditfor vulnerability scanning
Environment Secrets
ZENODO_ACCESS_TOKENfor publication- Kubernetes configs may contain cluster-specific paths
- Never commit API keys or credentials
Key Conventions
Version Numbering
- Major: Significant architectural changes
- Minor: New features, analyses, or experiments
- Patch: Bug fixes, documentation updates
File Naming
- Julia scripts:
snake_case.jl - Python scripts:
snake_case.pyorSCREAMING_SNAKE_CASE_v6.4.py(legacy) - Sounio:
snake_case.sio - Results:
{experiment_name}_{language}.csv/json
Documentation
- All modules have module-level docstrings/comments
- Complex algorithms reference academic papers
- Session reports track work progress in
docs/session_reports/
Quick Reference
Most Common Tasks
# Run validated phase transition experiment
julia phase_transition_pure_julia.jl
# Build Rust libraries
cd rust && cargo build --release
# Run Sounio experiment
bash experiments/01_epistemic_uncertainty/run.sh
# Clean repository
python scripts/cleanup_repository.py
# Generate all figures
cd code/analysis && python generate_final_figures.py
Important File Locations
- Main module:
julia/src/HyperbolicSemanticNetworks.jl - Curvature computation:
julia/src/Curvature/OllivierRicci.jl - Rust FFI:
julia/src/Curvature/FFI.jl - Core Sounio experiment:
experiments/01_epistemic_uncertainty/phase_transition.sio - Manuscript:
manuscript/main.md
Contact & Citation
Author: Dr. Demetrios Chiuratto Agourakis
Email: demetrios@agourakis.med.br
ORCID: 0000-0002-8596-5097
Repository: https://github.com/agourakis82/hyperbolic-semantic-networks
DOI: 10.5281/zenodo.17655231
Citation
@software{hyperbolic_semantic_networks,
title = {Hyperbolic Geometry of Semantic Networks: Cross-Linguistic Evidence},
author = {Agourakis, Demetrios C.},
year = {2025},
doi = {10.5281/zenodo.17655231},
url = {https://github.com/agourakis82/hyperbolic-semantic-networks}
}
Last updated: 2025-02-22
For the latest information, see README.md and docs/INDEX.md