diff --git a/src/formula/node/graph_builder.rs b/src/formula/node/graph_builder.rs new file mode 100644 index 0000000..7b6ac61 --- /dev/null +++ b/src/formula/node/graph_builder.rs @@ -0,0 +1,24 @@ +use crate::formula::node::Node; + +pub struct GraphBuilder(Node); + +impl GraphBuilder { + pub fn from_hash_maps(mut self) -> GraphBuilder { + self + } + /// Path format: /index0/index1/index2/.../indexn + /// For example: /0/1/0/0/1 + /// The reason for unreadable format is because graph builder, as I ended up realising, doesn't need to be used. + pub fn add_at_path(mut self, path: String, func: fn(Vec) -> f64) -> GraphBuilder { + let mut node_lookup = self.0; + for i in path.split("/").map(str::parse::) { + if let Ok(index) = i { + node_lookup = node_lookup.children[index]; + } + } + self + } + pub fn finish(self) -> Node { + self.0 + } +} diff --git a/src/formula/node/graph_constructor.rs b/src/formula/node/graph_constructor.rs deleted file mode 100644 index 94c0fff..0000000 --- a/src/formula/node/graph_constructor.rs +++ /dev/null @@ -1 +0,0 @@ -pub struct GraphBuilder; diff --git a/src/formula/node/graph_modifier.rs b/src/formula/node/graph_modifier.rs new file mode 100644 index 0000000..4e779d7 --- /dev/null +++ b/src/formula/node/graph_modifier.rs @@ -0,0 +1 @@ +struct GraphModifier; diff --git a/src/formula/node/mod.rs b/src/formula/node/mod.rs index ea7f1d2..32a39bc 100644 --- a/src/formula/node/mod.rs +++ b/src/formula/node/mod.rs @@ -1,6 +1,7 @@ -use crate::formula::node::graph_constructor::GraphBuilder; +use crate::formula::node::graph_builder::GraphBuilder; -mod graph_constructor; +mod graph_builder; +mod graph_modifier; pub struct Node { children: Vec,