Skip to main content

SynapticGraph

Struct SynapticGraph 

Source
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 polarity

Implementations§

Source§

impl SynapticGraph

Source

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

Source

pub fn new(n: usize) -> Self

Create an empty graph with n neurons and no connections.

Source

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.

Source

pub fn neuron_count(&self) -> usize

Number of neurons in the graph.

Source

pub fn synapse_count(&self) -> usize

Total number of synapses (non-zero entries).

Source

pub fn sparsity(&self) -> f32

Sparsity: fraction of the N×N matrix that is zero.

Source

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.

Source

pub fn out_degree(&self, neuron: usize) -> usize

Get the out-degree of a neuron.

Source

pub fn max_delay(&self) -> DelayTicks

Maximum delay present in the graph.

Source

pub fn mean_degree(&self) -> f32

Mean out-degree across all neurons.

Source

pub fn to_gpu_arrays(&self) -> (Vec<u32>, Vec<u32>, Vec<f32>, Vec<u16>)

Raw access to CSR arrays for GPU upload.

Source

pub fn row_ptr(&self) -> &[usize]

Row pointer slice (for external iteration).

Source

pub fn targets(&self) -> &[NeuronId] ⓘ

Target neuron slice.

Source

pub fn weights(&self) -> &[f32]

Weight slice.

Source

pub fn delays_slice(&self) -> &[DelayTicks] ⓘ

Delay slice.

Trait Implementations§

Source§

impl Clone for SynapticGraph

Source§

fn clone(&self) -> SynapticGraph

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for SynapticGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<'de> Deserialize<'de> for SynapticGraph

Source§

fn deserialize<D>(deserializer: D) -> Result<Self, D::Error>
where D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl PartialEq for SynapticGraph

Source§

fn eq(&self, other: &SynapticGraph) -> bool

Equality operator ==. Read more
1.0.0 (const: unstable) · Source§

fn ne(&self, other: &Rhs) -> bool

Inequality operator !=. Read more
Source§

impl Serialize for SynapticGraph

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. Read more
Source§

impl StructuralPartialEq for SynapticGraph

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,

Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.