From 18d7955b7d84c00467ede38baae53f4ce1fb6908 Mon Sep 17 00:00:00 2001 From: JSDurand Date: Fri, 20 Jan 2023 13:48:26 +0800 Subject: chain: a prototype is added. I have an ostensibly working prototype now. Further tests are needed to make sure that the algorithm meets the time complexity requirement, though. --- graph/src/lib.rs | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) (limited to 'graph/src/lib.rs') diff --git a/graph/src/lib.rs b/graph/src/lib.rs index 6af7889..2a0c50d 100644 --- a/graph/src/lib.rs +++ b/graph/src/lib.rs @@ -251,10 +251,14 @@ pub trait ParentsGraph: Graph { /// Return an iterator of parents for a node. fn parents_of(&self, node_id: usize) -> Result<::Iter<'_>, Error>; -} -// TODO: Design a trait of graphs which can "replace" a certain child -// by another child. To re-direct children, so to speak. + /// We need to be able to retrieve the `n`-the child, for the edge + /// index to be of any use. + fn nth_child(&self, node_id: usize, n: usize) -> Result; + + /// Convert an edge to a `Parent` construct. + fn edge_to_parent(&self, source: usize, target: usize) -> Result, Error>; +} /// An /exended/ graph in the sense that it offers the ability to /// "redirect" children of a node to another node. -- cgit v1.2.3-18-g5258