pub struct AddWinsGraph<T> { /* private fields */ }Expand description
Add-Wins Graph CRDT implementation
This implementation ensures that vertices and edges are never completely lost. Deleted elements are marked as deleted but preserved for potential recovery.
Implementations§
Source§impl<T: Clone + PartialEq + Eq + Send + Sync> AddWinsGraph<T>
impl<T: Clone + PartialEq + Eq + Send + Sync> AddWinsGraph<T>
Sourcepub fn with_config(replica: ReplicaId, config: GraphConfig) -> Self
pub fn with_config(replica: ReplicaId, config: GraphConfig) -> Self
Create with custom configuration
Sourcepub fn add_vertex(&mut self, value: T, timestamp: u64) -> VertexId
pub fn add_vertex(&mut self, value: T, timestamp: u64) -> VertexId
Add a vertex to the graph
Sourcepub fn add_edge(
&mut self,
source: &VertexId,
target: &VertexId,
timestamp: u64,
weight: Option<f64>,
) -> Result<EdgeId, GraphError>
pub fn add_edge( &mut self, source: &VertexId, target: &VertexId, timestamp: u64, weight: Option<f64>, ) -> Result<EdgeId, GraphError>
Add an edge between two vertices
Sourcepub fn update_vertex(
&mut self,
id: &VertexId,
value: T,
timestamp: u64,
) -> Result<(), GraphError>
pub fn update_vertex( &mut self, id: &VertexId, value: T, timestamp: u64, ) -> Result<(), GraphError>
Update an existing vertex
Sourcepub fn update_edge(
&mut self,
id: &EdgeId,
weight: f64,
timestamp: u64,
) -> Result<(), GraphError>
pub fn update_edge( &mut self, id: &EdgeId, weight: f64, timestamp: u64, ) -> Result<(), GraphError>
Update an existing edge
Sourcepub fn remove_vertex(
&mut self,
id: &VertexId,
timestamp: u64,
) -> Result<(), GraphError>
pub fn remove_vertex( &mut self, id: &VertexId, timestamp: u64, ) -> Result<(), GraphError>
Mark a vertex as deleted
Sourcepub fn remove_edge(
&mut self,
id: &EdgeId,
timestamp: u64,
) -> Result<(), GraphError>
pub fn remove_edge( &mut self, id: &EdgeId, timestamp: u64, ) -> Result<(), GraphError>
Mark an edge as deleted
Sourcepub fn get_vertex(&self, id: &VertexId) -> Option<&Vertex<T>>
pub fn get_vertex(&self, id: &VertexId) -> Option<&Vertex<T>>
Get a vertex by ID
Sourcepub fn visible_vertices(&self) -> Vec<&Vertex<T>>
pub fn visible_vertices(&self) -> Vec<&Vertex<T>>
Get all visible vertices (not deleted)
Sourcepub fn visible_edges(&self) -> Vec<&Edge>
pub fn visible_edges(&self) -> Vec<&Edge>
Get all visible edges (not deleted)
Sourcepub fn all_vertices(&self) -> Vec<&Vertex<T>>
pub fn all_vertices(&self) -> Vec<&Vertex<T>>
Get all vertices including deleted ones
Sourcepub fn incoming_edges(&self, id: &VertexId) -> Vec<&Edge>
pub fn incoming_edges(&self, id: &VertexId) -> Vec<&Edge>
Get incoming edges to a vertex
Sourcepub fn outgoing_edges(&self, id: &VertexId) -> Vec<&Edge>
pub fn outgoing_edges(&self, id: &VertexId) -> Vec<&Edge>
Get outgoing edges from a vertex
Sourcepub fn shortest_path(
&self,
source: &VertexId,
target: &VertexId,
) -> Option<Vec<VertexId>>
pub fn shortest_path( &self, source: &VertexId, target: &VertexId, ) -> Option<Vec<VertexId>>
Find shortest path between two vertices using BFS
Sourcepub fn contains_vertex(&self, id: &VertexId) -> bool
pub fn contains_vertex(&self, id: &VertexId) -> bool
Check if the graph contains a vertex
Sourcepub fn contains_edge(&self, id: &EdgeId) -> bool
pub fn contains_edge(&self, id: &EdgeId) -> bool
Check if the graph contains an edge
Sourcepub fn vertex_count(&self) -> usize
pub fn vertex_count(&self) -> usize
Get the number of visible vertices
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Get the number of visible edges
Trait Implementations§
Source§impl<T: Clone + PartialEq + Eq + Send + Sync> CRDT for AddWinsGraph<T>
impl<T: Clone + PartialEq + Eq + Send + Sync> CRDT for AddWinsGraph<T>
fn replica_id(&self) -> &ReplicaId
Source§impl<T: Clone> Clone for AddWinsGraph<T>
impl<T: Clone> Clone for AddWinsGraph<T>
Source§fn clone(&self) -> AddWinsGraph<T>
fn clone(&self) -> AddWinsGraph<T>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more