Skip to main content

CsrGraph

Struct CsrGraph 

Source
pub struct CsrGraph {
    pub offsets: Vec<u64>,
    pub targets: Vec<NodeId>,
    pub weights: Vec<AtomicU32>,
    pub inhibitory: Vec<bool>,
    pub relations: Vec<InternedStr>,
    pub directions: Vec<EdgeDirection>,
    pub causal_strengths: Vec<FiniteF32>,
    pub rev_offsets: Vec<u64>,
    pub rev_sources: Vec<NodeId>,
    pub rev_edge_idx: Vec<EdgeIdx>,
    pub pending_edges: Vec<PendingEdge>,
}
Expand description

Compressed Sparse Row graph with forward and reverse adjacency. For node i, outgoing edges span offsets[i]..offsets[i+1] into targets, weights, inhibitory, relations, directions, causal_strengths.

Fields§

§offsets: Vec<u64>

Length: num_nodes + 1. offsets[num_nodes] == total_edges.

§targets: Vec<NodeId>

Length: total_edges. Target node for each edge.

§weights: Vec<AtomicU32>

Length: total_edges. Edge weight — atomic for lock-free plasticity updates (FM-ACT-021).

§inhibitory: Vec<bool>

Length: total_edges. true = inhibitory edge.

§relations: Vec<InternedStr>

Length: total_edges. Relation type (interned).

§directions: Vec<EdgeDirection>

Length: total_edges. Forward or Bidirectional.

§causal_strengths: Vec<FiniteF32>

Length: total_edges. Causal strength in [0.0, 1.0].

§rev_offsets: Vec<u64>

Length: num_nodes + 1.

§rev_sources: Vec<NodeId>

Length: total_edges. Source node for each reverse edge.

§rev_edge_idx: Vec<EdgeIdx>

Length: total_edges. Index into forward arrays for this reverse edge.

§pending_edges: Vec<PendingEdge>

Pre-finalize edge staging area.

Implementations§

Source§

impl CsrGraph

Source

pub fn empty() -> Self

Create an empty CSR with no nodes/edges.

Source

pub fn num_edges(&self) -> usize

Number of edges in the forward CSR.

Source

pub fn out_range(&self, node: NodeId) -> Range<usize>

Outgoing edge range for node.

Source

pub fn in_range(&self, node: NodeId) -> Range<usize>

Incoming edge range for node (reverse CSR).

Source

pub fn read_weight(&self, edge: EdgeIdx) -> FiniteF32

Read weight atomically as FiniteF32 (FM-ACT-021).

Source

pub fn atomic_max_weight( &self, edge: EdgeIdx, new_val: FiniteF32, max_retries: u32, ) -> M1ndResult<()>

Atomic CAS max on edge weight. Returns Ok on success, Err after retry limit (FM-ACT-019). Replaces: engine_fast.py direct weight assignment (now lock-free).

Source

pub fn atomic_write_weight( &self, edge: EdgeIdx, new_val: FiniteF32, max_retries: u32, ) -> M1ndResult<()>

Atomic CAS write on edge weight (for plasticity). Returns Ok on success, Err after retry limit.

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> 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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.