Skip to main content

DependencyGraph

Struct DependencyGraph 

Source
pub struct DependencyGraph { /* private fields */ }
Expand description

Dependency graph built from tasks.

Implementations§

Source§

impl DependencyGraph

Source

pub fn new() -> Self

Create an empty graph.

Source

pub fn from_collection(collection: &TaskCollection) -> Self

Build a graph from a task collection.

Source

pub fn from_tasks(tasks: Vec<&Task>) -> Self

Build a graph from a list of tasks.

Source

pub fn add_task(&mut self, id: TaskId)

Add a task to the graph.

Source

pub fn add_dependency(&mut self, from: &str, to: &str)

Add a dependency edge (from must complete before to).

Source

pub fn has_cycles(&self) -> bool

Check if the graph has cycles.

Source

pub fn find_cycles(&self) -> Vec<Vec<TaskId>>

Find all cycles in the graph. Returns a list of cycles, where each cycle is a list of task IDs.

Source

pub fn topological_order(&self) -> Option<Vec<TaskId>>

Get topological order of tasks. Returns None if there are cycles.

Source

pub fn dependencies(&self, task_id: &str) -> Vec<TaskId>

Get tasks that this task depends on (direct).

Source

pub fn dependents(&self, task_id: &str) -> Vec<TaskId>

Get tasks that depend on this task (direct).

Source

pub fn parallel_groups(&self) -> Vec<Vec<TaskId>>

Get parallel work groups (generations). Tasks in the same group have no dependencies on each other.

Source

pub fn critical_path(&self) -> Vec<TaskId>

Get critical path (longest path through graph). Returns the sequence of tasks on the critical path.

Source

pub fn weighted_critical_path<F>(&self, weight_fn: F) -> Vec<TaskId>
where F: Fn(&str) -> f64,

Get weighted critical path (path with highest cumulative weight). Takes a weight function that maps task IDs to their weight.

Source

pub fn bottlenecks(&self) -> Vec<(TaskId, usize)>

Get bottleneck tasks (high betweenness centrality). Returns tasks sorted by how many paths they’re on.

Source

pub fn to_dot(&self) -> String

Export graph in DOT format for visualization.

Trait Implementations§

Source§

impl Default for DependencyGraph

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.