-
Notifications
You must be signed in to change notification settings - Fork 2
3.2 Topology Generators
Relevant source files
The following files were used as context for generating this wiki page:
The topology generation subsystem provides deterministic, index-based pseudo-random network constructors for synaptic-wiring. By avoiding external random number generators (RNGs) and relying instead on golden-ratio fractional hashing of neuron coordinate pairs, the generators ensure complete reproducibility across platforms and runs.
This page covers the core hashing infrastructure, random graph generation (generate_random), small-world network generation (generate_small_world), and parameter bounds enforced by the validation layer.
Sources: src/topology/generators.rs:3-16, README.md:39-42
To achieve cross-platform determinism without stateful RNG seeds, the subsystem uses fractional hashing based on the golden ratio (
Key hashing functions defined in src/topology/generators.rs:
-
hash_pair(a: usize, b: usize) -> f32: Combines two integer indices using golden and silver ratios, extracting the fractional part to produce a value in$[0, 1)$ src/topology/generators.rs:23-30. -
hash_weight(src: usize, tgt: usize, base: f32, spread: f32) -> f32: Derives a deterministic synaptic weight from source and target indices src/topology/generators.rs:33-35. -
hash_delay(src: usize, tgt: usize, max_delay: u16) -> u16: Computes a deterministic axonal delay bound bymax_delaysrc/topology/generators.rs:37-47.
graph TD
subgraph "Natural Language Space"
A["NeuronIndices"]
B["GoldenRatioHashing"]
end
subgraph "Code Entity Space"
C["hash_pair(a:usize,b:usize)"] --> D["hash_weight(src,tgt,base,spread)"]
C --> E["hash_delay(src,tgt,max_delay)"]
end
A --> C
B --> C
classDef default fill:none,stroke:#000,stroke-width:1px;
Figure 1: Deterministic hashing architecture bridging index inputs to graph attributes.
Sources: src/topology/generators.rs:21-48
The generate_random function builds a directed Erdős–Rényi random graph where every directed edge
-
Validation: Checks that
$p \in [0, 1]$ ,inhibitory_fraction$\in [0, 1]$ , and$n \ge 1$ . ReturnsMeshError::InvalidConfigotherwise src/topology/generators.rs:63-75. -
Polarity Assignment: Splits the neuron population at
inhibitory_cutoff = (n as f32 * inhibitory_fraction) as usize. Neurons below the cutoff are assignedPolarity::Inhibitory; the rest arePolarity::Excitatorysrc/topology/generators.rs:77-85. -
Edge Generation: Iterates over all directed pairs
$(src, tgt)$ , skipping self-loops. Ifhash_pair(src, tgt) < p, aSynapseDescriptoris emitted src/topology/generators.rs:87-101. -
Graph Construction: Finalizes the graph via
SynapticGraph::from_descriptorssrc/topology/generators.rs:103-103.
graph TD
A["generate_random(n,p,max_delay,inh_frac)"] --> B["ValidateParameters"]
B --> C["ComputeInhibitoryCutoff"]
C --> D["IterateSourceAndTargetPairs"]
D --> E{"hash_pair < p?"}
E -- Yes --> F["EmitSynapseDescriptor"]
E -- No --> D
F --> G["SynapticGraph::from_descriptors"]
classDef default fill:none,stroke:#000,stroke-width:1px;
Figure 2: Erdős–Rényi generation data flow.
Sources: src/topology/generators.rs:51-104
The generate_small_world constructor implements a directed ring lattice augmented with probabilistic rewiring src/topology/generators.rs:106-127.
-
Validation: Requires
$n \ge 3$ , even$k \in [2, n-1]$ ,$\beta \in [0, 1]$ , and valid inhibitory fraction src/topology/generators.rs:135-154. -
Lattice Initialization: Each neuron connects to
$k$ nearest neighbors ($k/2$ clockwise,$k/2$ counterclockwise) src/topology/generators.rs:157-171. -
Rewiring: Each outgoing synapse is evaluated against probability
$\beta$ usinghash_pairwith salt. If rewired,rewire_small_world_targetselects a valid non-self, non-duplicate target src/topology/generators.rs:173-178. -
Descriptor Collection: Generates
SynapseDescriptorinstances with deterministic weights and delays src/topology/generators.rs:180-190.
| Parameter | Type | Valid Range | Description |
|---|---|---|---|
n |
usize |
Total neuron count | |
k |
usize |
Even, |
Initial mean degree |
beta |
f32 |
Rewiring probability | |
max_delay |
u16 |
Maximum axonal delay ticks | |
inhibitory_fraction |
f32 |
Proportion of inhibitory neurons |
Sources: src/topology/generators.rs:106-195
- 1. Overview
- 1.1. Getting Started & Public API
- 1.2. Release History and Versioning
- 2. Core Runtime: SynapticMesh
- 2.1. Propagation APIs and Tick Semantics
- 2.2. Spike Delay Buffer (Ring Buffer)
- 2.3. Core Types and Error Model
- 2.4. Checkpointing and Serde State Restoration
- 3. Topology Subsystem
- 3.1. SynapticGraph and CSR Representation
- 3.2. Topology Generators
- 3.3. Wiring Rules, Dale's Law and Delay Assignment
- 3.4. Topology Digest
- 4. Sparse Maps and Channel Routing
- 4.1. ChannelRouter and RouterConfig
- 4.2. Neuromodulation and Plasticity
- 4.3. SparseSynapticMap (CSR)
- 5. Testing, Benchmarks and Quality Gates
- 5.1. Propagation Contract Tests
- 5.2. Checkpoint Resume Property Suite
- 5.3. Benchmarks and Unit Test Module
- 6. Build, CI and Project Tooling
- 6.1. Cargo Manifest, Profiles and Dependencies
- 6.2. CI Workflows and Packaging Validation
- 6.3. Code Quality, Licensing and Review Gates
- 7. Glossary