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
impl MemGraph
Sourcepub fn add_edge(
&mut self,
source: &str,
label: &str,
target: MemValue,
start: i64,
)
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.
Sourcepub fn add_edge_bounded(
&mut self,
source: &str,
label: &str,
target: MemValue,
start: i64,
end: i64,
)
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).
Sourcepub fn add_ref(
&mut self,
source: &str,
label: &str,
target_node: &str,
start: i64,
)
pub fn add_ref( &mut self, source: &str, label: &str, target_node: &str, start: i64, )
Convenience: add a node-to-node edge.
Sourcepub fn add_str(&mut self, source: &str, label: &str, value: &str, start: i64)
pub fn add_str(&mut self, source: &str, label: &str, value: &str, start: i64)
Convenience: add a node-to-string edge.
Sourcepub fn add_num(&mut self, source: &str, label: &str, value: f64, start: i64)
pub fn add_num(&mut self, source: &str, label: &str, value: f64, start: i64)
Convenience: add a node-to-number edge.
Sourcepub fn end_edge(&mut self, source: &str, label: &str, at: i64) -> bool
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.
Sourcepub fn upsert_edge(
&mut self,
source: &str,
label: &str,
value: MemValue,
at: i64,
)
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.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Total number of edges.
Trait Implementations§
Source§impl DataSource for MemGraph
impl DataSource for MemGraph
Source§fn edges_from(
&self,
node: &String,
label: &String,
at: &i64,
) -> Vec<Edge<String, MemValue, i64>>
fn edges_from( &self, node: &String, label: &String, at: &i64, ) -> Vec<Edge<String, MemValue, i64>>
Source§fn scan(
&self,
label: &String,
constraint: &ValueConstraint<MemValue>,
at: &i64,
) -> Vec<Edge<String, MemValue, i64>>
fn scan( &self, label: &String, constraint: &ValueConstraint<MemValue>, at: &i64, ) -> Vec<Edge<String, MemValue, i64>>
label matching constraint,
active at time at. Read moreSource§fn edges_from_any_time(
&self,
node: &String,
label: &String,
) -> Vec<Edge<String, MemValue, i64>>
fn edges_from_any_time( &self, node: &String, label: &String, ) -> Vec<Edge<String, MemValue, i64>>
node with label that were ever valid
(regardless of time). Used for temporal constraint checking.