MutableGraph

Struct MutableGraph 

Source
pub struct MutableGraph<'id, T: Eq + Hash + Clone> { /* private fields */ }
Expand description

Mutable version of Graph which you can use inside the callback given to Graph::modify.

This is implemented using the branding mechanism from the GhostCell Paper.

Implementations§

Source§

impl<'id, T: Eq + Hash + Clone> MutableGraph<'id, T>

Source

pub fn new<F, R>(graph: &'id mut Graph<T>, callback: F) -> R
where for<'new_id> F: FnOnce(MutableGraph<'new_id, T>) -> R,

Creates a new MutableGraph for a given Graph that can be used inside the callback.

Prefer using the Graph::modify method.

Source

pub fn fetch_id_for_data(&mut self, data: &T) -> BrandedNodeId<'id>

Fetch an identifier for a given data structure.

If this instance of data (as determined by the Hash and Eq traits) already exists in the graph the resulting id will refer to the same node in the graph.

If the argument is an instance of data that is not already in the graph it will automatically be added.

Source

pub fn get_node_data_for_id(&self, id: BrandedNodeId<'id>) -> Option<&T>

Given a node id this returns a borrow of the data behind that node.

Source

pub fn add_edge(&mut self, from: BrandedNodeId<'id>, to: BrandedNodeId<'id>)

Add a directional vertex (connection) between two nodes with a weight of 1.0.

Source

pub fn add_edge_weighted( &mut self, from: BrandedNodeId<'id>, to: BrandedNodeId<'id>, weight: f32, )

Add a directional vertex (connection) between two nodes with a custom weight.

Methods from Deref<Target = Graph<T>>§

Source

pub fn run_pagerank(&self, config: &PageRankConfiguration) -> RankedNodes<'_, T>

Runs the textrank algorithm on the graph and returns a HashMap mapping node values to the resulting scores.

Trait Implementations§

Source§

impl<'id, T: Eq + Hash + Clone> Deref for MutableGraph<'id, T>

Source§

type Target = Graph<T>

The resulting type after dereferencing.
Source§

fn deref(&self) -> &Self::Target

Dereferences the value.

Auto Trait Implementations§

§

impl<'id, T> Freeze for MutableGraph<'id, T>

§

impl<'id, T> RefUnwindSafe for MutableGraph<'id, T>
where T: RefUnwindSafe,

§

impl<'id, T> !Send for MutableGraph<'id, T>

§

impl<'id, T> !Sync for MutableGraph<'id, T>

§

impl<'id, T> Unpin for MutableGraph<'id, T>

§

impl<'id, T> !UnwindSafe for MutableGraph<'id, T>

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<P, T> Receiver for P
where P: Deref<Target = T> + ?Sized, T: ?Sized,

Source§

type Target = T

🔬This is a nightly-only experimental API. (arbitrary_self_types)
The target type on which the method may be called.
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.