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>
impl<'id, T: Eq + Hash + Clone> MutableGraph<'id, T>
Sourcepub fn new<F, R>(graph: &'id mut Graph<T>, callback: F) -> Rwhere
for<'new_id> F: FnOnce(MutableGraph<'new_id, T>) -> R,
pub fn new<F, R>(graph: &'id mut Graph<T>, callback: F) -> Rwhere
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.
Sourcepub fn fetch_id_for_data(&mut self, data: &T) -> BrandedNodeId<'id>
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.
Sourcepub fn get_node_data_for_id(&self, id: BrandedNodeId<'id>) -> Option<&T>
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.
Sourcepub fn add_edge(&mut self, from: BrandedNodeId<'id>, to: BrandedNodeId<'id>)
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.
Sourcepub fn add_edge_weighted(
&mut self,
from: BrandedNodeId<'id>,
to: BrandedNodeId<'id>,
weight: f32,
)
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>>§
Sourcepub fn run_pagerank(&self, config: &PageRankConfiguration) -> RankedNodes<'_, T>
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.