How arlav/graphtope works
Purpose and Entry Points
Graphtope is a Python library for generating, rewriting, validating, and reversing building space-adjacency graphs before attaching geometry. The Dom Narkomfin grammar is the primary reference domain. Main programmatic entry points are StateGraph and grammar-production modules; exploration is demonstrated through notebooks/01_graphtope.ipynb.
Paths: graphtope/__init__.py, graphtope/model.py, graphtope/grammar_dnf.py.
Typed Graph State and Invariants
The core state represents architectural spaces as typed, attributed nodes and horizontal/vertical adjacencies as directed, weighted edges. It owns graph construction, axiom creation, and well-formedness checks, making it the primary consistency boundary for every rewrite. Label vocabularies and lower-level topology support are separated from the state model.
Paths: graphtope/model.py, graphtope/alphabet.py, graphtope/_topo.py.
Reversible Rewrite Foundation
Graph evolution is built from reversible atomic edits, then elevated into split/merge and broader composition verbs. This layer is the mutation boundary: named grammar productions should operate through these primitives rather than directly changing graph internals.
Paths: graphtope/atomic.py, graphtope/composite.py, graphtope/bridge.py.
Production Rules and Derivation Execution
Typed subgraph matching and DPO-style rule definitions provide the generic production mechanism. The Narkomfin module encodes domain-specific productions over that mechanism, while the engine applies, replays, and inverts derivations. Parameters and reusable grammar-unit definitions support controlled variation.
Paths: graphtope/rules.py, graphtope/engine.py, graphtope/grammar_dnf.py.
Hierarchical and Modular Building Assembly
The system supports refinement of higher-level nodes into sub-grammars and abstraction back upward. Separate graph blocks can be composed and connected through bridges; cross-level relations address dependencies across hierarchical levels. This creates a boundary between local unit grammars and whole-building assembly.
Paths: graphtope/hierarchy.py, graphtope/compose.py, graphtope/crosslevel.py.
Generation, Steering, and Analysis
Generation creates candidate graph variants; steering constrains or directs those variants. Validity, comparison, metrics, reference matching, and topological views evaluate generated states and support selecting or diagnosing alternatives.
Paths: graphtope/generate.py, graphtope/steer.py, graphtope/metrics.py.
Geometry, Exchange, and Runtime Boundary
Graph-first results are serialized as JSON and can be realized into geometry through a shape-interface boundary and TopologicPy-oriented modules. OBJ assets and exported graph sidecars demonstrate interchange outputs. Blender scripts import generated geometry, create .blend variants, and validate them; Blender is an external batch/runtime integration, not the core grammar runtime. Python 3.10+ and NetworkX are stated requirements.
Paths: graphtope/serialize.py, graphtope/realise.py, graphtope/shape_iface.py; blender/import_graphtope.py, notebooks/exports/variants_3d/.
Main entry points: model.py StateGraph · atomic.py Atomic edits · rules.py Rule definitions · realise.py Geometry realization
Components 20
Graph State
Typed architectural graph and invariant boundary.
- StateGraph · Owns axioms, construction, and well-formedness checks.
graphtope/model.py - Label vocabularies
graphtope/alphabet.py - Topology support
graphtope/_topo.py
Rewrite System
Reversible edits and grammar execution.
- Atomic edits
graphtope/atomic.py - Composite verbs
graphtope/composite.py - Bridging edits
graphtope/bridge.py - Rule definitions · Defines typed subgraph matches and productions.
graphtope/rules.py - Derivation engine · Applies, replays, and inverts derivations.
graphtope/engine.py - Dom Narkomfin grammar
graphtope/grammar_dnf.py
Assembly & Search
Hierarchical composition and candidate exploration.
- Hierarchy refinement · Refines nodes into subgrammars and abstracts them back.
graphtope/hierarchy.py - Block composition
graphtope/compose.py - Cross-level relations
graphtope/crosslevel.py - Generation & steering · Creates candidates and directs their evolution.
graphtope/generate.py - Analysis & validation · Compares, measures, validates, and diagnoses states.
graphtope/metrics.py
Geometry & Exchange
Serialization and external geometry realization.
- JSON exchange
graphtope/serialize.py - Geometry realization · Converts graph-first results through a shape interface.
graphtope/realise.py - Shape interface · Decouples grammar runtime from TopologicPy-oriented geometry.
graphtope/shape_iface.py - Blender batch integration · Imports generated geometry and validates .blend variants.
blender/import_graphtope.py
Other components
- Library API
graphtope/__init__.py - Exploration notebook
notebooks/01_graphtope.ipynb
Connections 21
- Library API → StateGraph: exports
- Exploration notebook → Library API: uses
- Label vocabularies → StateGraph: types nodes
- Topology support → StateGraph: supports
- StateGraph → Atomic edits: mutation target
- Atomic edits → Composite verbs: builds
- Atomic edits → Bridging edits: builds
- Composite verbs → Rule definitions: used by productions
- Bridging edits → Block composition: connects blocks
- Rule definitions → Dom Narkomfin grammar: generic mechanism for
- Rule definitions → Derivation engine: executed by
- Derivation engine → StateGraph: applies derivations
- Hierarchy refinement → Block composition: assembles refined blocks
- Cross-level relations → Hierarchy refinement: links levels
- Generation & steering → Derivation engine: explores derivations
- Generation & steering → Analysis & validation: evaluates candidates
- StateGraph → Analysis & validation: evaluated as
- StateGraph → JSON exchange: serializes
- JSON exchange → Geometry realization: supplies graph results
- Geometry realization → Shape interface: uses
- Geometry realization → Blender batch integration: exports geometry to