pub struct SynapticGraph { /* private fields */ }Expand description
Adjacency structure for a spiking neural network with delay and polarity metadata.
Stores connections in Compressed Sparse Row (CSR) format, augmented with per-synapse delay and polarity vectors aligned to the same index space.
§Layout
row_ptr: [0, 3, 7, 10, ...] — start index per source neuron
targets: [5, 12, 0, 1, 3, ...] — target neuron IDs
weights: [0.9, -0.15, 0.3, ...] — effective signed weights
delays: [2, 5, 1, ...] — axonal delay in ticks
polarities: [Exc, Inh, Exc, ...] — Dale's law polarityImplementations§
Source§impl SynapticGraph
impl SynapticGraph
Sourcepub fn topology_digest(&self) -> TopologyDigest
pub fn topology_digest(&self) -> TopologyDigest
Deterministic, versioned digest of this graph’s logical topology.
See TopologyDigest for the schema, domain separator, and float
bit-pattern rules. Equivalent graphs built through different insertion
orders produce the same value.
use synaptic_wiring::topology::SynapticGraph;
use synaptic_wiring::types::{Polarity, SynapseDescriptor};
let a = [
SynapseDescriptor {
source: 0,
target: 1,
weight: 0.5,
delay: 2,
polarity: Polarity::Excitatory,
},
SynapseDescriptor {
source: 1,
target: 0,
weight: 0.25,
delay: 1,
polarity: Polarity::Inhibitory,
},
];
let mut b = a;
b.swap(0, 1);
let ga = SynapticGraph::from_descriptors(2, &a).unwrap();
let gb = SynapticGraph::from_descriptors(2, &b).unwrap();
assert_eq!(ga.topology_digest(), gb.topology_digest());Source§impl SynapticGraph
impl SynapticGraph
Sourcepub fn from_descriptors(
neuron_count: usize,
descriptors: &[SynapseDescriptor],
) -> Result<Self>
pub fn from_descriptors( neuron_count: usize, descriptors: &[SynapseDescriptor], ) -> Result<Self>
Build from a list of synapse descriptors.
Descriptors need not be sorted; they will be grouped by source neuron.
Each descriptor weight must be a finite non-negative magnitude
(IEEE signed zero is accepted). Negative, NaN, and infinite
magnitudes are rejected — they are not abs()-normalized.
Sourcepub fn neuron_count(&self) -> usize
pub fn neuron_count(&self) -> usize
Number of neurons in the graph.
Sourcepub fn synapse_count(&self) -> usize
pub fn synapse_count(&self) -> usize
Total number of synapses (non-zero entries).
Sourcepub fn outgoing(
&self,
source: usize,
) -> impl Iterator<Item = (NeuronId, f32, DelayTicks, Polarity)> + '_
pub fn outgoing( &self, source: usize, ) -> impl Iterator<Item = (NeuronId, f32, DelayTicks, Polarity)> + '_
Iterate over all outgoing synapses from source.
Returns (target, weight, delay, polarity) tuples.
Sourcepub fn out_degree(&self, neuron: usize) -> usize
pub fn out_degree(&self, neuron: usize) -> usize
Get the out-degree of a neuron.
Sourcepub fn max_delay(&self) -> DelayTicks
pub fn max_delay(&self) -> DelayTicks
Maximum delay present in the graph.
Sourcepub fn mean_degree(&self) -> f32
pub fn mean_degree(&self) -> f32
Mean out-degree across all neurons.
Sourcepub fn to_gpu_arrays(&self) -> (Vec<u32>, Vec<u32>, Vec<f32>, Vec<u16>)
pub fn to_gpu_arrays(&self) -> (Vec<u32>, Vec<u32>, Vec<f32>, Vec<u16>)
Raw access to CSR arrays for GPU upload.
Sourcepub fn delays_slice(&self) -> &[DelayTicks] ⓘ
pub fn delays_slice(&self) -> &[DelayTicks] ⓘ
Delay slice.
Trait Implementations§
Source§impl Clone for SynapticGraph
impl Clone for SynapticGraph
Source§fn clone(&self) -> SynapticGraph
fn clone(&self) -> SynapticGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more