pub struct LineageGraph {
pub nodes: Vec<LineageNode>,
pub edges: Vec<LineageEdgeRecord>,
}Expand description
A lineage graph showing model derivation history.
Fields§
§nodes: Vec<LineageNode>Nodes in the graph.
edges: Vec<LineageEdgeRecord>Edges representing derivation relationships.
Implementations§
Source§impl LineageGraph
impl LineageGraph
Sourcepub fn add_node(&mut self, node: LineageNode) -> usize
pub fn add_node(&mut self, node: LineageNode) -> usize
Add a node to the graph.
Sourcepub fn add_edge(
&mut self,
from_idx: usize,
to_idx: usize,
edge: ModelLineageEdge,
)
pub fn add_edge( &mut self, from_idx: usize, to_idx: usize, edge: ModelLineageEdge, )
Add an edge to the graph.
Sourcepub fn node_count(&self) -> usize
pub fn node_count(&self) -> usize
Get the number of nodes.
Sourcepub fn edge_count(&self) -> usize
pub fn edge_count(&self) -> usize
Get the number of edges.
Sourcepub fn ancestors(&self, node_idx: usize) -> Vec<usize>
pub fn ancestors(&self, node_idx: usize) -> Vec<usize>
Get ancestors of a node (models it was derived from).
Sourcepub fn descendants(&self, node_idx: usize) -> Vec<usize>
pub fn descendants(&self, node_idx: usize) -> Vec<usize>
Get descendants of a node (models derived from it).
Sourcepub fn all_ancestors(&self, node_idx: usize) -> Vec<usize>
pub fn all_ancestors(&self, node_idx: usize) -> Vec<usize>
Get all ancestors of a node (full transitive closure).
Returns all nodes from which this model was derived, recursively.
Sourcepub fn all_descendants(&self, node_idx: usize) -> Vec<usize>
pub fn all_descendants(&self, node_idx: usize) -> Vec<usize>
Get all descendants of a node (full transitive closure).
Returns all nodes derived from this model, recursively.
Sourcepub fn root_nodes(&self) -> Vec<usize>
pub fn root_nodes(&self) -> Vec<usize>
Get root models (models with no parents).
Sourcepub fn leaf_nodes(&self) -> Vec<usize>
pub fn leaf_nodes(&self) -> Vec<usize>
Get leaf models (models with no children).
Sourcepub fn path_between(&self, from_idx: usize, to_idx: usize) -> Option<Vec<usize>>
pub fn path_between(&self, from_idx: usize, to_idx: usize) -> Option<Vec<usize>>
Find path between two nodes (returns node indices from source to target).
Uses BFS to find shortest path. Returns None if no path exists.
Sourcepub fn topological_sort(&self) -> Option<Vec<usize>>
pub fn topological_sort(&self) -> Option<Vec<usize>>
Perform topological sort of the graph.
Returns nodes in order such that parents come before children.
Returns None if the graph has a cycle.
Sourcepub fn depth(&self, node_idx: usize) -> usize
pub fn depth(&self, node_idx: usize) -> usize
Get depth of a node (longest path from any root).
Sourcepub fn edges_between(
&self,
from_idx: usize,
to_idx: usize,
) -> Vec<&LineageEdgeRecord>
pub fn edges_between( &self, from_idx: usize, to_idx: usize, ) -> Vec<&LineageEdgeRecord>
Get the edges connecting two specific nodes.
Trait Implementations§
Source§impl Clone for LineageGraph
impl Clone for LineageGraph
Source§fn clone(&self) -> LineageGraph
fn clone(&self) -> LineageGraph
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more