Skip to main content

MiniGraph

Struct MiniGraph 

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

The mini-graph (Java MiniGraph): an in-memory property graph designed to handle a small number of nodes very efficiently (default cap 750).

Implementations§

Source§

impl MiniGraph

Source

pub fn new() -> Self

Create a mini-graph with the default maximum of 750 nodes.

Source

pub fn with_max_nodes(max_nodes: usize) -> Self

Create a mini-graph with an explicit node cap — be conservative: everything lives in memory and performance decreases as nodes grow.

Source

pub fn get_id(&self) -> &str

The unique id of this mini-graph.

Source

pub fn get_node_count(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn create_root_node(&self) -> Result<Arc<SimpleNode>, AppError>

Source

pub fn create_end_node(&self) -> Result<Arc<SimpleNode>, AppError>

Source

pub fn get_root_node(&self) -> Option<Arc<SimpleNode>>

Source

pub fn get_end_node(&self) -> Option<Arc<SimpleNode>>

Source

pub fn create_node( &self, alias: &str, node_type: &str, ) -> Result<Arc<SimpleNode>, AppError>

Create a node with a unique alias and an initial type.

Source

pub fn remove_node(&self, alias: &str) -> Result<(), AppError>

Remove a node and every connection touching it.

Source

pub fn get_nodes(&self) -> Vec<Arc<SimpleNode>>

Source

pub fn get_connections(&self) -> Vec<Arc<SimpleConnection>>

Source

pub fn reset(&self)

Clear the graph, de-referencing all nodes and connections.

Source

pub fn connect( &self, source_alias: &str, target_alias: &str, ) -> Result<Arc<SimpleConnection>, AppError>

Connect two nodes (idempotent: an existing connection is returned).

Source

pub fn remove_connection( &self, source_alias: &str, target_alias: &str, ) -> Result<(), AppError>

Remove the connection between two nodes (with its relations).

Source

pub fn find_node_by_alias( &self, alias: &str, ) -> Result<Option<Arc<SimpleNode>>, AppError>

Case-insensitive alias lookup. Errors on an empty alias (Java: null).

Source

pub fn find_node_by_id( &self, id: &str, ) -> Result<Option<Arc<SimpleNode>>, AppError>

Source

pub fn find_nodes_by_type( &self, node_type: &str, ) -> Result<Vec<Arc<SimpleNode>>, AppError>

All nodes carrying the given type (case-insensitive).

Source

pub fn find_relation_by_type( &self, relation_type: &str, ) -> Result<Vec<Arc<SimpleRelationship>>, AppError>

All relations of the given type across every connection.

Source

pub fn find_nodes_by_property( &self, key: &str, value: &Value, ) -> Result<Vec<Arc<SimpleNode>>, AppError>

All nodes with a property whose key matches case-insensitively and whose value equals the given one.

Source

pub fn find_connection( &self, source_alias: &str, target_alias: &str, ) -> Result<Option<Arc<SimpleConnection>>, AppError>

Source

pub fn find_bi_directional_connection( &self, source_alias: &str, target_alias: &str, ) -> Result<Vec<Arc<SimpleConnection>>, AppError>

Both directions between two nodes: 0 to 2 connections, forward first.

Source

pub fn get_neighbors( &self, alias: &str, ) -> Result<Vec<Arc<SimpleNode>>, AppError>

Nodes connected in either direction.

Source

pub fn find_paths(&self, alias: &str) -> Result<Vec<Vec<String>>, AppError>

BFS level discovery from a node (direction-agnostic): one list of aliases per distance level; unreachable nodes are skipped.

Source

pub fn export_graph(&self) -> Value

Export the graph as a map value: nodes sorted by alias, connections by source:target, relations by type — deterministic for round-tripping.

Source

pub fn import_graph(&self, map: &Value) -> Result<(), AppError>

Import a graph map (the export shape). The graph resets first; an invalid payload leaves it empty (Java parity).

Source

pub fn same_as(&self, that: &MiniGraph) -> bool

Structural equality with another graph: same nodes (aliases, types, deep-equal properties) and same connections/relations.

Source

pub fn to_json(&self) -> String

Export as a JSON string (deterministic ordering).

Trait Implementations§

Source§

impl Default for MiniGraph

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<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
where ST: ?Sized, DT: ?Sized,

Source§

impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
where ST: ?Sized, DT: ?Sized,

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> Pointable for T

Source§

const ALIGN: usize

The alignment of pointer.
Source§

type Init = T

The type for initializers.
Source§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
Source§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
Source§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
Source§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
Source§

impl<T> Read<Exclusive, BecauseExclusive> for T
where T: ?Sized,

Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = !

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, !>

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.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V