Added various comments to the project.
This commit is contained in:
parent
e6570cf4b7
commit
dd282236fd
3 changed files with 14 additions and 1 deletions
|
@ -8,9 +8,12 @@ use uuid::Uuid;
|
|||
// directory: String
|
||||
// }
|
||||
|
||||
/// Constructs a tree with a given height while simultaneously running a simulation on each node.
|
||||
fn build_tree(h: u32) -> Option<Box<tree::Tree>> {
|
||||
let mut result: Option<Box<tree::Tree>> = None;
|
||||
|
||||
// Recursively building a tree and running the simulation after wards to ensure a bottom-up
|
||||
// execution order.
|
||||
if h != 0 {
|
||||
result = Some(Box::new(tree::combine_trees(Uuid::new_v4(), build_tree(h - 1), build_tree(h - 1))));
|
||||
match &result {
|
||||
|
@ -22,10 +25,14 @@ fn build_tree(h: u32) -> Option<Box<tree::Tree>> {
|
|||
result
|
||||
}
|
||||
|
||||
/// Generates a bracket tree and runs simulation against each node.
|
||||
///
|
||||
/// TODO: Explain reasoning for bracket system against genetic algorithm.
|
||||
pub fn run_bracket() {
|
||||
let mut height = 1;
|
||||
let mut tree: tree::Tree = *build_tree(height).expect("Error getting result from build_tree.");
|
||||
|
||||
// Building tree one node at a time, appending to the top.
|
||||
loop {
|
||||
println!("=========================================");
|
||||
println!("Running bracket...");
|
||||
|
|
|
@ -1 +1,2 @@
|
|||
/// Corresponds to the DIRECTORY command line argument used in accordance with the clap crate.
|
||||
pub const DIRECTORY: &str = "DIRECTORY";
|
|
@ -6,13 +6,18 @@ extern crate clap;
|
|||
use clap::App;
|
||||
use std::fs::metadata;
|
||||
|
||||
/// Runs a simluation of a genetic algorithm against a dataset.
|
||||
///
|
||||
/// Use the -h, --h, or --help flag to see usage syntax.
|
||||
fn main() {
|
||||
// Command line arguments are parsed with the clap crate. And this program uses
|
||||
// the yaml method with clap.
|
||||
let yaml = load_yaml!("../cli.yml");
|
||||
let matches = App::from_yaml(yaml).get_matches();
|
||||
|
||||
// Checking that the first argument <DIRECTORY> is a valid directory
|
||||
let directory = matches.value_of(constants::args::DIRECTORY).unwrap();
|
||||
let metadata = metadata(directory);
|
||||
|
||||
match &metadata {
|
||||
Ok(m) if m.is_dir() == true => {
|
||||
println!("{} is a valid directory!", directory);
|
||||
|
|
Loading…
Add table
Reference in a new issue