summaryrefslogtreecommitdiff
path: root/graph/src/lib.rs
diff options
context:
space:
mode:
authorJSDurand <mmemmew@gmail.com>2023-01-13 14:26:28 +0800
committerJSDurand <mmemmew@gmail.com>2023-01-13 14:26:28 +0800
commit8f8d3d1a3c276be4be2e5d2e767ada564c47279a (patch)
treedaba317c8d381f7159f9a34d957291472bad2873 /graph/src/lib.rs
parent3c6511f69c7639abff60ac9999a08ce2daa24a7d (diff)
forest seems to be completed
I seem to have finished the implementation of forests. Now it remains the implementation of the chain-rule machine, of which I have a rough plan now.
Diffstat (limited to 'graph/src/lib.rs')
-rw-r--r--graph/src/lib.rs18
1 files changed, 18 insertions, 0 deletions
diff --git a/graph/src/lib.rs b/graph/src/lib.rs
index 6813df3..6af7889 100644
--- a/graph/src/lib.rs
+++ b/graph/src/lib.rs
@@ -23,6 +23,7 @@ pub use adlist::ALGraph;
pub mod labelled;
pub use labelled::DLGraph;
+pub use labelled::PLGraph;
pub mod builder;
@@ -252,6 +253,23 @@ pub trait ParentsGraph: Graph {
fn parents_of(&self, node_id: usize) -> Result<<Self as ParentsGraph>::Iter<'_>, Error>;
}
+// TODO: Design a trait of graphs which can "replace" a certain child
+// by another child. To re-direct children, so to speak.
+
+/// An /exended/ graph in the sense that it offers the ability to
+/// "redirect" children of a node to another node.
+pub trait RedirectGraph: Graph {
+ /// Replace the edge that points from `node_id` to the
+ /// `child_index`-th child by a new edge that points to
+ /// `new_child`.
+ fn redirect(
+ &mut self,
+ node_id: usize,
+ child_index: usize,
+ new_child: usize,
+ ) -> Result<(), Error>;
+}
+
/// A labelled graph is just a graph with labels associated to
/// vertices and / or edges.
///