Skip to main content

Adapter: Memory

fabula_memory -- a simple in-memory temporal graph. Linear-scan queries. Suitable for testing and small graphs.

Crate: fabula-memory

MemGraph

An in-memory temporal graph storing edges as (source, label, target, interval) tuples.

use fabula_memory::{MemGraph, MemValue};

let mut g = MemGraph::new();
g.add_str("ev1", "type", "arrival", 1);
g.add_ref("ev1", "actor", "alice", 1);
g.add_num("ev1", "severity", 3.5, 1);
g.set_time(10);

DataSource type mapping

Associated typeConcrete type
NString
LString
VMemValue
Ti64

Methods

MemGraph::new

Creates a new empty graph with current_time = 0.

pub fn new() -> Self

Returns: MemGraph


set_time

Sets the current time.

pub fn set_time(&mut self, t: i64)
ParameterTypeRequiredDefaultDescription
ti64yes--The new current time.

add_edge

Adds an edge with an open-ended interval starting at start.

pub fn add_edge(&mut self, source: &str, label: &str, target: MemValue, start: i64)
ParameterTypeRequiredDefaultDescription
source&stryes--Source node ID.
label&stryes--Edge label.
targetMemValueyes--Target value.
starti64yes--Interval start time.

add_edge_bounded

Adds an edge with a bounded interval [start, end).

pub fn add_edge_bounded(
&mut self,
source: &str,
label: &str,
target: MemValue,
start: i64,
end: i64,
)
ParameterTypeRequiredDefaultDescription
source&stryes--Source node ID.
label&stryes--Edge label.
targetMemValueyes--Target value.
starti64yes--Interval start time.
endi64yes--Interval end time (exclusive).

add_ref

Convenience: adds a node-to-node edge with an open-ended interval.

pub fn add_ref(&mut self, source: &str, label: &str, target_node: &str, start: i64)
ParameterTypeRequiredDefaultDescription
source&stryes--Source node ID.
label&stryes--Edge label.
target_node&stryes--Target node ID. Stored as MemValue::Node.
starti64yes--Interval start time.

add_str

Convenience: adds a node-to-string edge with an open-ended interval.

pub fn add_str(&mut self, source: &str, label: &str, value: &str, start: i64)
ParameterTypeRequiredDefaultDescription
source&stryes--Source node ID.
label&stryes--Edge label.
value&stryes--String value. Stored as MemValue::Str.
starti64yes--Interval start time.

add_num

Convenience: adds a node-to-number edge with an open-ended interval.

pub fn add_num(&mut self, source: &str, label: &str, value: f64, start: i64)
ParameterTypeRequiredDefaultDescription
source&stryes--Source node ID.
label&stryes--Edge label.
valuef64yes--Numeric value. Stored as MemValue::Num.
starti64yes--Interval start time.

edge_count

Returns the total number of edges in the graph.

pub fn edge_count(&self) -> usize

Returns: usize


Trait implementations

TraitNotes
DefaultEquivalent to MemGraph::new().
DataSourceLinear scan over all edges for all query methods.

MemValue

A value in the in-memory graph.

pub enum MemValue {
Node(String),
Str(String),
Num(f64),
Bool(bool),
}
VariantDescription
Node(String)Reference to another node. value_as_node returns Some.
Str(String)String literal.
Num(f64)Numeric value.
Bool(bool)Boolean value.

Trait implementations

TraitNotes
DebugDerived.
CloneDerived.
PartialEqDerived.
PartialOrdDerived.
DisplayNode formats as @id, Str as "value", Num and Bool as their values.