pub struct MultiDiGraph<N: Node, E: EdgeWeight, Ix: IndexType = u32> { /* private fields */ }
Expand description
A directed multi-graph structure that supports parallel edges
Implementations§
Source§impl<N: Node, E: EdgeWeight, Ix: IndexType> MultiDiGraph<N, E, Ix>
impl<N: Node, E: EdgeWeight, Ix: IndexType> MultiDiGraph<N, E, Ix>
Sourcepub fn add_edge(&mut self, source: N, target: N, weight: E) -> usize
pub fn add_edge(&mut self, source: N, target: N, weight: E) -> usize
Add an edge from source to target with given weight Returns the edge ID for reference
Sourcepub fn get_edges_between(&self, source: &N, target: &N) -> Vec<(usize, &E)>
pub fn get_edges_between(&self, source: &N, target: &N) -> Vec<(usize, &E)>
Get all parallel edges between two nodes
Sourcepub fn remove_edge(&mut self, edge_id: usize) -> Result<Edge<N, E>>
pub fn remove_edge(&mut self, edge_id: usize) -> Result<Edge<N, E>>
Remove an edge by its ID
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes in the graph
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of edges in the graph
Sourcepub fn successors_with_edges(&self, node: &N) -> Option<&Vec<(N, E, usize)>>
pub fn successors_with_edges(&self, node: &N) -> Option<&Vec<(N, E, usize)>>
Get outgoing neighbors of a node with edge weights and IDs
Sourcepub fn predecessors_with_edges(&self, node: &N) -> Option<&Vec<(N, E, usize)>>
pub fn predecessors_with_edges(&self, node: &N) -> Option<&Vec<(N, E, usize)>>
Get incoming neighbors of a node with edge weights and IDs
Sourcepub fn successors(&self, node: &N) -> Vec<&N>
pub fn successors(&self, node: &N) -> Vec<&N>
Get simple successors (without edge information)
Sourcepub fn predecessors(&self, node: &N) -> Vec<&N>
pub fn predecessors(&self, node: &N) -> Vec<&N>
Get simple predecessors (without edge information)
Sourcepub fn out_degree(&self, node: &N) -> usize
pub fn out_degree(&self, node: &N) -> usize
Get the out-degree of a node
Trait Implementations§
Auto Trait Implementations§
impl<N, E, Ix> Freeze for MultiDiGraph<N, E, Ix>
impl<N, E, Ix> RefUnwindSafe for MultiDiGraph<N, E, Ix>
impl<N, E, Ix> Send for MultiDiGraph<N, E, Ix>where
Ix: Send,
impl<N, E, Ix> Sync for MultiDiGraph<N, E, Ix>where
Ix: Sync,
impl<N, E, Ix> Unpin for MultiDiGraph<N, E, Ix>
impl<N, E, Ix> UnwindSafe for MultiDiGraph<N, E, Ix>
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
Mutably borrows from an owned value. Read more
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>
Converts
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>
Converts
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