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 moreSource§impl<T: Debug> Debug for AddWinsGraph<T>
impl<T: Debug> Debug for AddWinsGraph<T>
Source§impl<'de, T> Deserialize<'de> for AddWinsGraph<T>where
T: Deserialize<'de>,
impl<'de, T> Deserialize<'de> for AddWinsGraph<T>where
T: Deserialize<'de>,
Source§fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>where
__D: Deserializer<'de>,
Source§impl<T: PartialEq> PartialEq for AddWinsGraph<T>
impl<T: PartialEq> PartialEq for AddWinsGraph<T>
Source§impl<T> Serialize for AddWinsGraph<T>where
T: Serialize,
impl<T> Serialize for AddWinsGraph<T>where
T: Serialize,
impl<T> StructuralPartialEq for AddWinsGraph<T>
Auto Trait Implementations§
impl<T> Freeze for AddWinsGraph<T>
impl<T> RefUnwindSafe for AddWinsGraph<T>where
T: RefUnwindSafe,
impl<T> Send for AddWinsGraph<T>where
T: Send,
impl<T> Sync for AddWinsGraph<T>where
T: Sync,
impl<T> Unpin for AddWinsGraph<T>where
T: Unpin,
impl<T> UnwindSafe for AddWinsGraph<T>where
T: UnwindSafe,
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> FromFormData for Twhere
T: DeserializeOwned,
impl<T> FromFormData for Twhere
T: DeserializeOwned,
Source§fn from_event(ev: &Event) -> Result<T, FromFormDataError>
fn from_event(ev: &Event) -> Result<T, FromFormDataError>
submit
event.Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more