pub struct DependencyGraph { /* private fields */ }Expand description
Directed dependency graph with one node per source file.
Nodes carry the file path (relative to the repository root). Edges are directed from the importing file to the imported file.
§Examples
use sdivi_graph::dependency_graph::{DependencyGraph, build_dependency_graph_from_edges};
let dg = build_dependency_graph_from_edges(
&["src/lib.rs".to_string(), "src/models.rs".to_string()],
&[(0, 1)],
);
assert_eq!(dg.node_count(), 2);
assert_eq!(dg.edge_count(), 1);Implementations§
Source§impl DependencyGraph
impl DependencyGraph
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Number of nodes (source files) in the graph.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Number of directed edges in the graph.
Sourcepub fn node_for_path(&self, path: &Path) -> Option<usize>
pub fn node_for_path(&self, path: &Path) -> Option<usize>
Returns the node index for path, or None if not present.
Sourcepub fn edges_as_pairs(&self) -> Vec<(usize, usize)>
pub fn edges_as_pairs(&self) -> Vec<(usize, usize)>
Returns all directed edges as (from_idx, to_idx) pairs.
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 moreAuto 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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
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