pub struct DiGraph<N: Node, E: EdgeWeight, Ix: IndexType = u32> { /* private fields */ }Expand description
A directed graph structure
Implementations§
Source§impl<N: Node + Debug, E: EdgeWeight, Ix: IndexType> DiGraph<N, E, Ix>
impl<N: Node + Debug, 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 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) -> &PetGraph<N, E, Directed, Ix>
pub fn inner(&self) -> &PetGraph<N, E, Directed, Ix>
Get the internal petgraph structure for more advanced operations
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 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 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) -> Array2<f64>
pub fn adjacency_matrix(&self) -> Array2<f64>
Get the adjacency matrix of the graph
Sourcepub fn out_degree_vector(&self) -> Array1<usize>
pub fn out_degree_vector(&self) -> Array1<usize>
Get the out-degree vector (number of outgoing edges for each node)
Sourcepub fn in_degree_vector(&self) -> Array1<usize>
pub fn in_degree_vector(&self) -> Array1<usize>
Get the in-degree vector (number of incoming edges for each 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>>
Source§fn filter_by_weight(
&self,
min_weight: Option<E>,
maxweight: Option<E>,
) -> Result<Self>
fn filter_by_weight( &self, min_weight: Option<E>, maxweight: Option<E>, ) -> Result<Self>
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)>>
Source§fn subgraph_by_weight_range(&self, min_weight: E, maxweight: E) -> Result<Self>
fn subgraph_by_weight_range(&self, min_weight: E, maxweight: E) -> Result<Self>
Source§fn normalize_weights(&self, method: NormalizationMethod) -> Result<Self>
fn normalize_weights(&self, method: NormalizationMethod) -> Result<Self>
Source§fn transform_weights(&self, transform: WeightTransform) -> Result<Self>
fn transform_weights(&self, transform: WeightTransform) -> Result<Self>
Source§fn weight_distribution(&self, bins: usize) -> Result<Vec<(E, usize)>>
fn weight_distribution(&self, bins: usize) -> Result<Vec<(E, usize)>>
Source§fn weighted_degree_centrality(&self) -> Result<HashMap<N, f64>>
fn weighted_degree_centrality(&self) -> Result<HashMap<N, f64>>
Source§fn total_weight(&self) -> Result<E>
fn total_weight(&self) -> Result<E>
Source§fn average_weight(&self) -> Result<f64>
fn average_weight(&self) -> Result<f64>
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
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>
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>
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