Skip to main content

Graph

Struct Graph 

Source
pub struct Graph {
    pub nodes: NodeStorage,
    pub csr: CsrGraph,
    pub edge_plasticity: EdgePlasticity,
    pub strings: StringInterner,
    pub id_to_node: HashMap<InternedStr, NodeId>,
    pub generation: Generation,
    pub pagerank_computed: bool,
    pub finalized: bool,
}
Expand description

The complete property graph. Owns all storage. Mutation methods increment generation for desync detection (FM-PL-006).

Fields§

§nodes: NodeStorage§csr: CsrGraph§edge_plasticity: EdgePlasticity§strings: StringInterner§id_to_node: HashMap<InternedStr, NodeId>

Maps interned external ID -> internal NodeId.

§generation: Generation

Monotonic counter incremented on every structural mutation.

§pagerank_computed: bool§finalized: bool

Implementations§

Source§

impl Graph

Source

pub fn new() -> Self

Source

pub fn with_capacity(node_cap: usize, edge_cap: usize) -> Self

Source

pub fn add_node( &mut self, external_id: &str, label: &str, node_type: NodeType, tags: &[&str], last_modified: f64, change_frequency: f32, ) -> M1ndResult<NodeId>

Add a node. Returns its NodeId. Increments generation. Replaces: engine_v2.py PropertyGraph.add_node()

Source

pub fn add_edge( &mut self, source: NodeId, target: NodeId, relation: &str, weight: FiniteF32, direction: EdgeDirection, inhibitory: bool, causal_strength: FiniteF32, ) -> M1ndResult<EdgeIdx>

Add an edge. Validates source/target existence (FM-ACT-011). Increments generation. Replaces: engine_v2.py PropertyGraph.add_edge()

Source

pub fn finalize(&mut self) -> M1ndResult<()>

Build CSR forward + reverse adjacency. Compute PageRank. Must be called before any query. Sets finalized = true. Replaces: engine_fast.py FastPropertyGraph.finalize()

Source

pub fn num_nodes(&self) -> u32

Number of nodes.

Source

pub fn num_edges(&self) -> usize

Number of edges (forward CSR).

Source

pub fn resolve_id(&self, external_id: &str) -> Option<NodeId>

Resolve external string ID to NodeId.

Source

pub fn set_node_provenance( &mut self, node: NodeId, provenance: NodeProvenanceInput<'_>, )

Source

pub fn merge_node_provenance( &mut self, node: NodeId, incoming: NodeProvenanceInput<'_>, )

Source

pub fn resolve_node_provenance(&self, node: NodeId) -> ResolvedNodeProvenance

Source

pub fn avg_degree(&self) -> f32

Average out-degree.

Auto Trait Implementations§

§

impl Freeze for Graph

§

impl RefUnwindSafe for Graph

§

impl Send for Graph

§

impl Sync for Graph

§

impl Unpin for Graph

§

impl UnsafeUnpin for Graph

§

impl UnwindSafe for Graph

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.