Started graph builder
This commit is contained in:
parent
06274cd5a5
commit
3491eb28d5
4 changed files with 28 additions and 3 deletions
24
src/formula/node/graph_builder.rs
Normal file
24
src/formula/node/graph_builder.rs
Normal file
|
|
@ -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>) -> f64) -> GraphBuilder {
|
||||
let mut node_lookup = self.0;
|
||||
for i in path.split("/").map(str::parse::<i64>) {
|
||||
if let Ok(index) = i {
|
||||
node_lookup = node_lookup.children[index];
|
||||
}
|
||||
}
|
||||
self
|
||||
}
|
||||
pub fn finish(self) -> Node {
|
||||
self.0
|
||||
}
|
||||
}
|
||||
|
|
@ -1 +0,0 @@
|
|||
pub struct GraphBuilder;
|
||||
1
src/formula/node/graph_modifier.rs
Normal file
1
src/formula/node/graph_modifier.rs
Normal file
|
|
@ -0,0 +1 @@
|
|||
struct GraphModifier;
|
||||
|
|
@ -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<Node>,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue