pub struct DiGraph<N, E, Ix = u32>{ /* private fields */ }Expand description
A directed graph structure
Implementations§
Source§impl<N, E, Ix> DiGraph<N, E, Ix>
impl<N, E, Ix> DiGraph<N, E, Ix>
Sourcepub fn add_edge(
&mut self,
source: N,
target: N,
weight: E,
) -> Result<(), GraphError>
pub fn add_edge( &mut self, source: N, target: N, weight: E, ) -> Result<(), GraphError>
Add a directed edge from source to target with a given weight
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 contains_node(&self, node: &N) -> bool
pub fn contains_node(&self, node: &N) -> bool
Check if the graph contains a specific node
Sourcepub fn has_node(&self, node: &N) -> bool
pub fn has_node(&self, node: &N) -> bool
Check if the graph has a specific node (alias for contains_node)
Sourcepub fn inner(&self) -> &Graph<N, E, Directed, Ix>
pub fn inner(&self) -> &Graph<N, E, Directed, Ix>
Get the internal petgraph structure for more advanced operations
Sourcepub fn neighbors(&self, node: &N) -> Result<Vec<N>, GraphError>where
N: Clone,
pub fn neighbors(&self, node: &N) -> Result<Vec<N>, GraphError>where
N: Clone,
Get neighbors of a node
Sourcepub fn successors(&self, node: &N) -> Result<Vec<N>, GraphError>where
N: Clone,
pub fn successors(&self, node: &N) -> Result<Vec<N>, GraphError>where
N: Clone,
Get successors (outgoing neighbors) of a node
Sourcepub fn predecessors(&self, node: &N) -> Result<Vec<N>, GraphError>where
N: Clone,
pub fn predecessors(&self, node: &N) -> Result<Vec<N>, GraphError>where
N: Clone,
Get predecessors (incoming neighbors) of a node
Sourcepub fn edge_weight(&self, source: &N, target: &N) -> Result<E, GraphError>where
E: Clone,
pub fn edge_weight(&self, source: &N, target: &N) -> Result<E, GraphError>where
E: Clone,
Get the weight of an edge between two nodes
Sourcepub fn has_edge(&self, source: &N, target: &N) -> bool
pub fn has_edge(&self, source: &N, target: &N) -> bool
Check if an edge exists between two nodes
Sourcepub fn degree(&self, node: &N) -> usize
pub fn degree(&self, node: &N) -> usize
Get the degree of a node (total number of incident edges)
Sourcepub fn node_index(&self, node: &N) -> Option<NodeIndex<Ix>>
pub fn node_index(&self, node: &N) -> Option<NodeIndex<Ix>>
Get the node index for a specific node
Sourcepub fn adjacency_matrix(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>
pub fn adjacency_matrix(&self) -> ArrayBase<OwnedRepr<f64>, Dim<[usize; 2]>>
Get the adjacency matrix of the graph
Trait Implementations§
Source§impl<N, E, Ix> WeightedOps<N, E> for DiGraph<N, E, Ix>
impl<N, E, Ix> WeightedOps<N, E> for DiGraph<N, E, Ix>
Source§fn weight_statistics(&self) -> Result<WeightStatistics<E>, GraphError>
fn weight_statistics(&self) -> Result<WeightStatistics<E>, GraphError>
Calculate weight statistics for the graph
Source§fn filter_by_weight(
&self,
min_weight: Option<E>,
maxweight: Option<E>,
) -> Result<DiGraph<N, E, Ix>, GraphError>
fn filter_by_weight( &self, min_weight: Option<E>, maxweight: Option<E>, ) -> Result<DiGraph<N, E, Ix>, GraphError>
Filter edges by weight threshold
Source§fn edges_by_weight(&self, ascending: bool) -> Result<Vec<(N, N, E)>, GraphError>
fn edges_by_weight(&self, ascending: bool) -> Result<Vec<(N, N, E)>, GraphError>
Get edges sorted by weight
Source§fn subgraph_by_weight_range(
&self,
min_weight: E,
maxweight: E,
) -> Result<DiGraph<N, E, Ix>, GraphError>
fn subgraph_by_weight_range( &self, min_weight: E, maxweight: E, ) -> Result<DiGraph<N, E, Ix>, GraphError>
Extract subgraph with edges in weight range
Source§fn normalize_weights(
&self,
method: NormalizationMethod,
) -> Result<DiGraph<N, E, Ix>, GraphError>
fn normalize_weights( &self, method: NormalizationMethod, ) -> Result<DiGraph<N, E, Ix>, GraphError>
Normalize edge weights using specified method
Source§fn transform_weights(
&self,
transform: WeightTransform,
) -> Result<DiGraph<N, E, Ix>, GraphError>
fn transform_weights( &self, transform: WeightTransform, ) -> Result<DiGraph<N, E, Ix>, GraphError>
Transform edge weights using specified transformation
Source§fn weight_distribution(
&self,
bins: usize,
) -> Result<Vec<(E, usize)>, GraphError>
fn weight_distribution( &self, bins: usize, ) -> Result<Vec<(E, usize)>, GraphError>
Get weight distribution as histogram
Source§fn weighted_degree_centrality(&self) -> Result<HashMap<N, f64>, GraphError>
fn weighted_degree_centrality(&self) -> Result<HashMap<N, f64>, GraphError>
Calculate weight-based centrality measures
Source§fn total_weight(&self) -> Result<E, GraphError>
fn total_weight(&self) -> Result<E, GraphError>
Get total weight of the graph
Source§fn average_weight(&self) -> Result<f64, GraphError>
fn average_weight(&self) -> Result<f64, GraphError>
Get average edge weight
Auto Trait Implementations§
impl<N, E, Ix> Freeze for DiGraph<N, E, Ix>
impl<N, E, Ix> RefUnwindSafe for DiGraph<N, E, Ix>
impl<N, E, Ix> Send for DiGraph<N, E, Ix>where
Ix: Send,
impl<N, E, Ix> Sync for DiGraph<N, E, Ix>where
Ix: Sync,
impl<N, E, Ix> Unpin for DiGraph<N, E, Ix>
impl<N, E, Ix> UnwindSafe for DiGraph<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> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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 moreSource§impl<T> Pointable for T
impl<T> Pointable for T
Source§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
Source§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self to the equivalent element of its superset.