pub struct DependencyGraph { /* private fields */ }Expand description
The dependency graph structure.
Implementations§
Source§impl DependencyGraph
impl DependencyGraph
Sourcepub fn add_node(&mut self, node: DependencyNode) -> NodeIndex
pub fn add_node(&mut self, node: DependencyNode) -> NodeIndex
Adds a node to the graph.
Sourcepub fn add_edge(&mut self, from: NodeIndex, to: NodeIndex, edge: DependencyEdge)
pub fn add_edge(&mut self, from: NodeIndex, to: NodeIndex, edge: DependencyEdge)
Adds an edge between two nodes.
Sourcepub fn get_node_by_name(&self, name: &str) -> Option<&DependencyNode>
pub fn get_node_by_name(&self, name: &str) -> Option<&DependencyNode>
Gets a node by name.
Sourcepub fn get_node_by_key(&self, key: &str) -> Option<&DependencyNode>
pub fn get_node_by_key(&self, key: &str) -> Option<&DependencyNode>
Gets a node by key (name@version).
Sourcepub fn get_node(&self, idx: NodeIndex) -> Option<&DependencyNode>
pub fn get_node(&self, idx: NodeIndex) -> Option<&DependencyNode>
Gets a node by its index.
Sourcepub fn nodes(&self) -> impl Iterator<Item = &DependencyNode>
pub fn nodes(&self) -> impl Iterator<Item = &DependencyNode>
Returns all nodes in the graph.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Returns the number of nodes.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Returns the number of edges.
Sourcepub fn detect_cycle(&self) -> Option<Vec<String>>
pub fn detect_cycle(&self) -> Option<Vec<String>>
Detects cycles and returns the cycle path if found.
Sourcepub fn topological_sort(&self) -> Result<Vec<DependencyNode>>
pub fn topological_sort(&self) -> Result<Vec<DependencyNode>>
Performs topological sort and returns nodes in order.
Sourcepub fn dependencies_of(
&self,
node_idx: NodeIndex,
) -> Vec<(&DependencyNode, &DependencyEdge)>
pub fn dependencies_of( &self, node_idx: NodeIndex, ) -> Vec<(&DependencyNode, &DependencyEdge)>
Returns all dependencies of a node.
Sourcepub fn dependents_of(
&self,
node_idx: NodeIndex,
) -> Vec<(&DependencyNode, &DependencyEdge)>
pub fn dependents_of( &self, node_idx: NodeIndex, ) -> Vec<(&DependencyNode, &DependencyEdge)>
Returns all dependents of a node (reverse dependencies).
Sourcepub fn node_index(&self, name: &str) -> Option<NodeIndex>
pub fn node_index(&self, name: &str) -> Option<NodeIndex>
Returns the node index for a given name.
Trait Implementations§
Source§impl Clone for DependencyGraph
impl Clone for DependencyGraph
Source§fn clone(&self) -> DependencyGraph
fn clone(&self) -> DependencyGraph
Returns a duplicate of the value. Read more
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for DependencyGraph
impl Debug for DependencyGraph
Source§impl Default for DependencyGraph
impl Default for DependencyGraph
Source§fn default() -> DependencyGraph
fn default() -> DependencyGraph
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for DependencyGraph
impl RefUnwindSafe for DependencyGraph
impl Send for DependencyGraph
impl Sync for DependencyGraph
impl Unpin for DependencyGraph
impl UnsafeUnpin for DependencyGraph
impl UnwindSafe for DependencyGraph
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