Skip to content

SuperInstance/conservation-art

Repository files navigation

Conservation-Aware Generative Art

Beautiful visual art generated from the spectral properties of graphs — eigenvectors, eigenvalues, Laplacians, and conservation ratios.

The Concept

Every graph has a spectral fingerprint: the eigenvalues and eigenvectors of its Laplacian matrix encode deep structural information. This project transforms those mathematical properties into stunning visual art.

Conservation ratio — how smoothly attributes flow across a graph's structure — drives color harmony, layer coherence, and visual tension.

Gallery

1. Spectral Mandalas 🌀

Eigenvectors define angles and radii; eigenvalues control mandala layers. Conservation ratio governs color harmony.

  • Erdős-Rényi Constellation
  • Barabási-Albert Nebula
  • Small World Chakra
  • Grid Lattice Bloom
  • Western / Gamelan / Indian / Jazz / African Tradition Mandalas

2. Eigenvalue Landscapes 🏔️

Eigenvector 2 × Eigenvector 3 coordinates form the terrain. Attribute values become elevation. Conservation ratio maps to color.

  • Scale-Free Topology
  • Small-World Terrain
  • Lattice Prairie
  • Gamelan / Jazz Spectral Terrain

3. Laplacian Flow Fields 🌊

Graph nodes become attractors. Laplacian eigenvectors define flow direction. Conservation equals flow coherence.

  • Laplacian Vortex
  • Scale-Free Currents
  • Random Walk Dreams
  • Western / Gamelan Tradition Flows

4. Tradition Portraits 🎭

Each musical tradition's Laplacian eigenvalues define a unique abstract shape.

  • Western — Structured geometric polygons
  • Gamelan — Layered organic curves
  • Indian — Spiral raga complexity
  • Jazz — Improvisational chaos
  • African — Polyrhythmic bold patterns

5. Conservation Heat Maps 🌡️

Multi-scale conservation ratio mapped to color gradients. Shows the transition from well-conserved (smooth) to anomalous (rough).

  • Scale-Free / Small-World / Random / Lattice Conservation

Installation

pip install -r requirements.txt

or manually:

pip install numpy scipy matplotlib pillow

Usage

python generate.py

All output saved to output/ as PNG files.

Reproducibility

  • Tradition graphs (western, gamelan, indian, jazz, african) are derived deterministically from the tradition name, so a given tradition always yields the same underlying graph across runs and machines.
  • Generic random-graph galleries (Erdős-Rényi, Barabási-Albert, small-world, grid) draw from numpy's global RNG without a fixed seed, so re-running generate.py produces different art each time. Seed numpy yourself (numpy.random.seed(...)) before calling the generators if you need bit-reproducible generic pieces.

Mathematical Foundation

  • Normalized Laplacian: L = I − D^{−1/2} A D^{−1/2}
  • Conservation Ratio: σ(x) = 1 / (1 + x^T L x / x^T x)
  • Rayleigh Quotient: Measures smoothness of attribute x on graph structure
  • Spectral Embedding: Eigenvectors map graph to visual space

The conservation ratio takes values in [1/3, 1] for the normalized Laplacian (whose spectrum lies in [0, 2]); σ = 1 for a perfectly smooth signal and σ → 1/3 for the most oscillatory one. This bound is covered by tests/test_math.py.

Testing

The test suite covers the spectral math (closed-form spot-checks against known graphs), graph invariants, color logic, and end-to-end rendering of every generator (each rendered PNG is opened and checked to be a valid, non-blank image).

pip install -r requirements.txt   # includes pytest
pytest -v

License

MIT

Part of the SuperInstance OpenConstruct ecosystem.

About

Conservation-aware generative art from spectral graph theory

Topics

Resources

License

Code of conduct

Contributing

Security policy

Stars

1 star

Watchers

0 watching

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages