DepGraph

Struct DepGraph 

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

A dependency graph over one program and the infrastructure its effects imply.

Implementations§

Source§

impl DepGraph

Source

pub fn len(&self) -> usize

Source

pub fn is_empty(&self) -> bool

Source

pub fn edge_count(&self) -> usize

Source

pub fn nodes(&self) -> impl Iterator<Item = (NodeId, &GraphNode)>

Source

pub fn node(&self, id: NodeId) -> &GraphNode

Source

pub fn id(&self, name: &str) -> Option<NodeId>

Source

pub fn dependencies(&self, id: NodeId) -> &[Edge]

What this node depends on.

Source

pub fn dependents(&self, id: NodeId) -> &[Edge]

What depends on this node — the direction that answers “what breaks if I change this”.

Source

pub fn cycle_of(&self, id: NodeId) -> &[NodeId]

The strongly connected component this node is in. A single-element slice when the node is not in a cycle, which is the common case.

Source

pub fn scc_index(&self, id: NodeId) -> u32

Component index, in topological order of the condensation.

Source

pub fn cycles(&self) -> impl Iterator<Item = &[NodeId]>

The cycles: components with more than one member. Empty for an acyclic program; the todo example has exactly one, and it is the point of the architecture rather than a mistake.

Source

pub fn topological(&self) -> &[NodeId]

Dependencies before dependents, with cycle members adjacent.

Source

pub fn layers(&self) -> Vec<u32>

A layer per node: 0 for something that depends on nothing, otherwise one more than the deepest thing it depends on. Cycle members share a layer, because within a cycle there is no “deeper”.

This is the x-coordinate of a layered drawing — the shape Aspire’s graph view has, and the reason it is computed here rather than in the browser: the condensation is already in topological order, so one pass over it in that order gives every layer. O(V + E), against the iterative force-directed relaxation a client-side layout would need.

Source

pub fn impacted_by(&self, id: NodeId) -> Vec<NodeId>

Everything that transitively depends on id, including id. Breadth-first over the reverse edges, so it costs the size of the affected region rather than the size of the program.

Source

pub fn impact(&self, id: NodeId) -> Vec<(NodeId, u32)>

The same, with each node’s distance in hops from id, and nearest first.

The distance is what makes the answer usable rather than merely correct: “37 things depend on this” is a number, and “4 things depend on it directly, and the rest through them” is an answer. Breadth-first, so the first time a node is reached is by a shortest path.

Trait Implementations§

Source§

impl Clone for DepGraph

Source§

fn clone(&self) -> DepGraph

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for DepGraph

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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.