Skip to main content

SharedGraph

Struct SharedGraph 

Source
pub struct SharedGraph<N: Copy + Default + 'static, E: Copy + Default + 'static> { /* private fields */ }

Implementations§

Source§

impl<N: Copy + Default + 'static, E: Copy + Default + 'static> SharedGraph<N, E>

Source

pub fn create( base_path: impl AsRef<Path>, max_nodes: usize, max_edges: usize, ) -> Result<Self, GraphError>

Source

pub fn open( base_path: impl AsRef<Path>, max_nodes: usize, max_edges: usize, ) -> Result<Self, GraphError>

Source

pub fn node_count(&self) -> usize

Source

pub fn edge_count(&self) -> usize

Source

pub fn max_nodes(&self) -> usize

Source

pub fn max_edges(&self) -> usize

Source

pub fn add_node(&self, value: N) -> Result<NodeIndex<N>, GraphError>

Add a new node with value. Returns its index.

Source

pub fn add_edge( &self, src: NodeIndex<N>, dst: NodeIndex<N>, value: E, ) -> Result<EdgeIndex<E>, GraphError>

Add an edge from src to dst carrying value. Returns its index. Single-writer per src node (the linked-list head update isn’t synchronised internally).

Source

pub fn node_value(&self, idx: NodeIndex<N>) -> Option<N>

Read the value at a node index.

Source

pub fn edge_endpoints(&self, idx: EdgeIndex<E>) -> Option<(E, NodeIndex<N>)>

Read the (value, dst) for an edge index.

Source

pub fn out_degree(&self, src: NodeIndex<N>) -> Option<u32>

Out-degree of a node.

Source

pub fn neighbors( &self, src: NodeIndex<N>, ) -> Vec<(EdgeIndex<E>, NodeIndex<N>, E)>

Enumerate outgoing edges from src as (EdgeIndex, dst, edge_value). Snapshot at call time; not stable under concurrent writes to src.

Source

pub fn remove_edge( &self, src: NodeIndex<N>, edge_idx: EdgeIndex<E>, ) -> Option<E>

Remove an edge from src’s out-list. Returns the removed edge’s value if found.

Source

pub fn flush(&self) -> Result<(), GraphError>

Source

pub fn flush_async(&self) -> Result<(), GraphError>

Trait Implementations§

Source§

impl<N: Copy + Default + Send + Sync + 'static, E: Copy + Default + Send + Sync + 'static> AdaptiveInstance for SharedGraph<N, E>

Source§

fn header(&self) -> &HandshakeHeader

Source§

fn ring(&self) -> &ObservationRing

Source§

fn make_policy(&self) -> Box<dyn Policy>

Source§

fn apply_migration(&self, new_tag: u32)

Called by the sidecar when the policy returns a new strategy tag. Default implementation: just set the tag on the header. Primitives that need heavier migration (data-layout swap) override this to perform the swap before (or after) updating the tag.

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<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, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

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

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

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.