Skip to main content

GraphBackend

Trait GraphBackend 

Source
pub trait GraphBackend:
    Debug
    + Send
    + Sync {
    // Required methods
    fn edit_ops(
        &self,
        g: &Graph,
        z: &[f64],
        policy: MatchPolicy,
        target: Option<&Graph>,
        t: u64,
    ) -> Vec<GraphOp>;
    fn ok(&self, g: &Graph) -> bool;

    // Provided methods
    fn commit_ops(&self, _ops: &[GraphOp], _g: &Graph) { ... }
    fn revert_ops(&self, _journal: &[UndoOp], _g: &Graph) { ... }
}
Expand description

Graph backend trait — PRD §5.3

§Ops, not graphs (plan WS3)

v0.1.0 returned a whole new Graph, which cost two clones of G per Match and made every run O(T²) in graph size. A backend now proposes the atomic ops of ED(G ⊕ z, G*) and the engine applies them transactionally against a snapshot journal (𝕃6), so a step costs the size of its edit, not the size of memory.

Required Methods§

Source

fn edit_ops( &self, g: &Graph, z: &[f64], policy: MatchPolicy, target: Option<&Graph>, t: u64, ) -> Vec<GraphOp>

Propose the ops realizing G' = ED(G ⊕ z, policy, G*) at clock t.

Absorbing z is part of Match, so the ops include it: a policy that merges z into an existing node emits MergeNodes, one that appends emits AddNode. Allocate new ids from Graph::next_id.

Source

fn ok(&self, g: &Graph) -> bool

GraphOK check

Provided Methods§

Source

fn commit_ops(&self, _ops: &[GraphOp], _g: &Graph)

Mirror committed ops into auxiliary structures (e.g. a vector index).

g is the post-state, so a merge’s EMA-updated embedding is readable. Default: nothing to mirror.

Source

fn revert_ops(&self, _journal: &[UndoOp], _g: &Graph)

Mirror a rollback, so auxiliary structures never diverge from G.

journal is the undo record that was just replayed; g is the restored graph. Default: nothing to mirror.

Dyn Compatibility§

This trait is dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§