Skip to main content

MemGraph

Struct MemGraph 

Source
pub struct MemGraph { /* private fields */ }
Expand description

A simple in-memory temporal graph.

Stores edges as (source, label, target, interval) tuples. Queries are linear scans — fine for testing, not for production.

Implementations§

Source§

impl MemGraph

Source

pub fn new() -> Self

Create a new empty graph.

Source

pub fn set_time(&mut self, t: i64)

Set the current time.

Source

pub fn add_edge( &mut self, source: &str, label: &str, target: MemValue, start: i64, )

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

Source

pub fn add_edge_bounded( &mut self, source: &str, label: &str, target: MemValue, start: i64, end: i64, )

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

Source

pub fn add_ref( &mut self, source: &str, label: &str, target_node: &str, start: i64, )

Convenience: add a node-to-node edge.

Source

pub fn add_str(&mut self, source: &str, label: &str, value: &str, start: i64)

Convenience: add a node-to-string edge.

Source

pub fn add_num(&mut self, source: &str, label: &str, value: f64, start: i64)

Convenience: add a node-to-number edge.

Source

pub fn end_edge(&mut self, source: &str, label: &str, at: i64) -> bool

Close an open-ended interval on the first matching edge.

Finds the most recent open-ended edge from source with the given label and sets its end to at. Returns true if an edge was closed, false if no open-ended match was found.

Source

pub fn upsert_edge( &mut self, source: &str, label: &str, value: MemValue, at: i64, )

End the current open-ended edge (if any) and insert a new one.

Equivalent to end_edge(source, label, at) followed by add_edge(source, label, value, at). Useful for updating state: close the old value and record the new one at the same timestamp.

Source

pub fn edge_count(&self) -> usize

Total number of edges.

Trait Implementations§

Source§

impl Clone for MemGraph

Source§

fn clone(&self) -> MemGraph

Returns a duplicate of the value. Read more
1.0.0 · Source§

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

Performs copy-assignment from source. Read more
Source§

impl DataSource for MemGraph

Source§

type N = String

Node identifier type.
Source§

type L = String

Edge label type.
Source§

type V = MemValue

Value type (edge targets — can be nodes, strings, numbers, booleans).
Source§

type T = i64

Time type.
Source§

fn edges_from( &self, node: &String, label: &String, at: &i64, ) -> Vec<Edge<String, MemValue, i64>>

Follow edges from node with label, active at time at. Read more
Source§

fn scan( &self, label: &String, constraint: &ValueConstraint<MemValue>, at: &i64, ) -> Vec<Edge<String, MemValue, i64>>

Find all source nodes that have an edge with label matching constraint, active at time at. Read more
Source§

fn edges_from_any_time( &self, node: &String, label: &String, ) -> Vec<Edge<String, MemValue, i64>>

Find all edges from node with label that were ever valid (regardless of time). Used for temporal constraint checking.
Source§

fn scan_any_time( &self, label: &String, constraint: &ValueConstraint<MemValue>, ) -> Vec<Edge<String, MemValue, i64>>

Scan for edges with label matching constraint at any time.
Source§

fn now(&self) -> i64

The current time in the graph’s time model.
Source§

fn value_as_node(&self, value: &MemValue) -> Option<String>

Check if a value represents a node reference (for traversal) vs. a literal (for comparison). This lets the pattern matcher know whether to follow a value as a node or compare it as data.
Source§

impl Default for MemGraph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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> 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> 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 = 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.