Skip to main content

CsrGraph

Struct CsrGraph 

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

Bidirectional graph with CSR (outgoing) and CSC (incoming) plus a delta log.

Implementations§

Source§

impl CsrGraph

Source

pub fn new() -> Self

Source

pub fn add_node(&mut self, id: MemoryId) -> u32

Register a node. Returns its internal index.

Source

pub fn remove_node(&mut self, id: MemoryId)

Remove a node and all its edges.

Source

pub fn add_edge(&mut self, edge: &MemoryEdge)

Add an edge to the delta log.

Source

pub fn remove_edge(&mut self, source: MemoryId, target: MemoryId)

Mark an edge for removal.

Source

pub fn outgoing(&self, id: MemoryId) -> Vec<(MemoryId, StoredEdge)>

Get all outgoing edges from a node (CSR + delta, minus removed).

Source

pub fn incoming(&self, id: MemoryId) -> Vec<(MemoryId, StoredEdge)>

Get all incoming edges to a node (CSC + delta, minus removed).

Source

pub fn contains_node(&self, id: MemoryId) -> bool

Check if a node exists in the graph.

Source

pub fn node_count(&self) -> usize

Number of registered nodes.

Source

pub fn node_ids(&self) -> &[MemoryId]

All registered node IDs.

Source

pub fn compact(&mut self)

Merge all delta edges and removals into the compressed CSR/CSC storage.

Source

pub fn save(&self, path: &Path) -> MenteResult<()>

Save the graph to a JSON file.

Source

pub fn load(path: &Path) -> MenteResult<Self>

Load the graph from a JSON file.

Trait Implementations§

Source§

impl Clone for CsrGraph

Source§

fn clone(&self) -> CsrGraph

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for CsrGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for CsrGraph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for CsrGraph

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for CsrGraph

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,