pub struct DiGraph<N: Node, E: EdgeWeight, Ix: IndexType = u32> { /* private fields */ }
Expand description
A directed graph structure
Implementations§
Source§impl<N: Node, E: EdgeWeight, Ix: IndexType> DiGraph<N, E, Ix>
impl<N: Node, E: EdgeWeight, Ix: IndexType> DiGraph<N, E, Ix>
Sourcepub fn add_edge(&mut self, source: N, target: N, weight: E) -> Result<()>
pub fn add_edge(&mut self, source: N, target: N, weight: E) -> Result<()>
Add a directed edge from source to target with a given weight
Sourcepub fn adjacency_matrix(&self) -> Array2<E>
pub fn adjacency_matrix(&self) -> Array2<E>
Get the adjacency matrix representation of the graph
Sourcepub fn in_degree_vector(&self) -> Array1<usize>
pub fn in_degree_vector(&self) -> Array1<usize>
Get the in-degree vector of the graph
Sourcepub fn out_degree_vector(&self) -> Array1<usize>
pub fn out_degree_vector(&self) -> Array1<usize>
Get the out-degree vector of the graph
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(&self, node: &N) -> Result<Vec<N>>where
N: Clone,
pub fn successors(&self, node: &N) -> Result<Vec<N>>where
N: Clone,
Get successors (outgoing neighbors) of a node
Sourcepub fn predecessors(&self, node: &N) -> Result<Vec<N>>where
N: Clone,
pub fn predecessors(&self, node: &N) -> Result<Vec<N>>where
N: Clone,
Get predecessors (incoming neighbors) of a node
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 edge_weight(&self, source: &N, target: &N) -> Result<E>where
E: Clone,
pub fn edge_weight(&self, source: &N, target: &N) -> Result<E>where
E: Clone,
Get the weight of an edge between two nodes
Sourcepub fn contains_node(&self, node: &N) -> bool
pub fn contains_node(&self, node: &N) -> bool
Check if the graph contains a specific node
Trait Implementations§
Source§impl<N, E, Ix: IndexType> WeightedOps<N, E> for DiGraph<N, E, Ix>
impl<N, E, Ix: IndexType> WeightedOps<N, E> for DiGraph<N, E, Ix>
Source§fn weight_statistics(&self) -> Result<WeightStatistics<E>>
fn weight_statistics(&self) -> Result<WeightStatistics<E>>
Calculate weight statistics for the graph
Source§fn filter_by_weight(
&self,
min_weight: Option<E>,
max_weight: Option<E>,
) -> Result<Self>
fn filter_by_weight( &self, min_weight: Option<E>, max_weight: Option<E>, ) -> Result<Self>
Filter edges by weight threshold
Source§fn edges_by_weight(&self, ascending: bool) -> Result<Vec<(N, N, E)>>
fn edges_by_weight(&self, ascending: bool) -> Result<Vec<(N, N, E)>>
Get edges sorted by weight
Source§fn subgraph_by_weight_range(&self, min_weight: E, max_weight: E) -> Result<Self>
fn subgraph_by_weight_range(&self, min_weight: E, max_weight: E) -> Result<Self>
Extract subgraph with edges in weight range
Source§fn normalize_weights(&self, method: NormalizationMethod) -> Result<Self>
fn normalize_weights(&self, method: NormalizationMethod) -> Result<Self>
Normalize edge weights using specified method
Source§fn transform_weights(&self, transform: WeightTransform) -> Result<Self>
fn transform_weights(&self, transform: WeightTransform) -> Result<Self>
Transform edge weights using specified transformation
Source§fn weight_distribution(&self, bins: usize) -> Result<Vec<(E, usize)>>
fn weight_distribution(&self, bins: usize) -> Result<Vec<(E, usize)>>
Get weight distribution as histogram
Source§fn weighted_degree_centrality(&self) -> Result<HashMap<N, f64>>
fn weighted_degree_centrality(&self) -> Result<HashMap<N, f64>>
Calculate weight-based centrality measures
Source§fn total_weight(&self) -> Result<E>
fn total_weight(&self) -> Result<E>
Get total weight of the graph
Source§fn average_weight(&self) -> Result<f64>
fn average_weight(&self) -> Result<f64>
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> 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