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
impl MiniGraph
Sourcepub fn with_max_nodes(max_nodes: usize) -> Self
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.
pub fn get_node_count(&self) -> usize
pub fn is_empty(&self) -> bool
pub fn create_root_node(&self) -> Result<Arc<SimpleNode>, AppError>
pub fn create_end_node(&self) -> Result<Arc<SimpleNode>, AppError>
pub fn get_root_node(&self) -> Option<Arc<SimpleNode>>
pub fn get_end_node(&self) -> Option<Arc<SimpleNode>>
Sourcepub fn create_node(
&self,
alias: &str,
node_type: &str,
) -> Result<Arc<SimpleNode>, AppError>
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.
Sourcepub fn remove_node(&self, alias: &str) -> Result<(), AppError>
pub fn remove_node(&self, alias: &str) -> Result<(), AppError>
Remove a node and every connection touching it.
pub fn get_nodes(&self) -> Vec<Arc<SimpleNode>>
pub fn get_connections(&self) -> Vec<Arc<SimpleConnection>>
Sourcepub fn connect(
&self,
source_alias: &str,
target_alias: &str,
) -> Result<Arc<SimpleConnection>, AppError>
pub fn connect( &self, source_alias: &str, target_alias: &str, ) -> Result<Arc<SimpleConnection>, AppError>
Connect two nodes (idempotent: an existing connection is returned).
Sourcepub fn remove_connection(
&self,
source_alias: &str,
target_alias: &str,
) -> Result<(), AppError>
pub fn remove_connection( &self, source_alias: &str, target_alias: &str, ) -> Result<(), AppError>
Remove the connection between two nodes (with its relations).
Sourcepub fn find_node_by_alias(
&self,
alias: &str,
) -> Result<Option<Arc<SimpleNode>>, AppError>
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).
pub fn find_node_by_id( &self, id: &str, ) -> Result<Option<Arc<SimpleNode>>, AppError>
Sourcepub fn find_nodes_by_type(
&self,
node_type: &str,
) -> Result<Vec<Arc<SimpleNode>>, AppError>
pub fn find_nodes_by_type( &self, node_type: &str, ) -> Result<Vec<Arc<SimpleNode>>, AppError>
All nodes carrying the given type (case-insensitive).
Sourcepub fn find_relation_by_type(
&self,
relation_type: &str,
) -> Result<Vec<Arc<SimpleRelationship>>, AppError>
pub fn find_relation_by_type( &self, relation_type: &str, ) -> Result<Vec<Arc<SimpleRelationship>>, AppError>
All relations of the given type across every connection.
Sourcepub fn find_nodes_by_property(
&self,
key: &str,
value: &Value,
) -> Result<Vec<Arc<SimpleNode>>, AppError>
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.
pub fn find_connection( &self, source_alias: &str, target_alias: &str, ) -> Result<Option<Arc<SimpleConnection>>, AppError>
Sourcepub fn find_bi_directional_connection(
&self,
source_alias: &str,
target_alias: &str,
) -> Result<Vec<Arc<SimpleConnection>>, AppError>
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.
Sourcepub fn get_neighbors(
&self,
alias: &str,
) -> Result<Vec<Arc<SimpleNode>>, AppError>
pub fn get_neighbors( &self, alias: &str, ) -> Result<Vec<Arc<SimpleNode>>, AppError>
Nodes connected in either direction.
pub fn get_forward_links( &self, alias: &str, ) -> Result<Vec<Arc<SimpleNode>>, AppError>
pub fn get_backward_links( &self, alias: &str, ) -> Result<Vec<Arc<SimpleNode>>, AppError>
Sourcepub fn find_paths(&self, alias: &str) -> Result<Vec<Vec<String>>, AppError>
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.
Sourcepub fn export_graph(&self) -> Value
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.
Sourcepub fn import_graph(&self, map: &Value) -> Result<(), AppError>
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).