Started graph builder

This commit is contained in:
Rendo 2025-11-06 06:49:13 +05:00
commit 3491eb28d5
4 changed files with 28 additions and 3 deletions

View 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
}
}

View file

@ -1 +0,0 @@
pub struct GraphBuilder;

View file

@ -0,0 +1 @@
struct GraphModifier;

View file

@ -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>,