From 3fa06496f603b1f3b2293736fcb5ba666fac3f4e Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Mon, 7 Oct 2024 12:45:38 +0200 Subject: [PATCH] fix: added allow dead_code --- .../fdg-example/src/stress_majorization.rs | 180 +++++++++--------- examples/graphs-1/src/gd.rs | 6 +- examples/graphs-1/src/main.rs | 9 +- src/gfa.rs | 1 + src/graph.rs | 2 +- src/parser.rs | 5 +- 6 files changed, 99 insertions(+), 104 deletions(-) diff --git a/examples/fdg-example/src/stress_majorization.rs b/examples/fdg-example/src/stress_majorization.rs index 17a5412..97dbb5e 100644 --- a/examples/fdg-example/src/stress_majorization.rs +++ b/examples/fdg-example/src/stress_majorization.rs @@ -1,99 +1,99 @@ -use std::{ - collections::HashMap, - hash::{BuildHasherDefault, Hash}, - iter::Sum, - ops::AddAssign, -}; +// use std::{ +// collections::HashMap, +// hash::{BuildHasherDefault, Hash}, +// iter::Sum, +// ops::AddAssign, +// }; // use nalgebra::{Point, SVector}; // use petgraph::stable_graph::NodeIndex; // type HashFn = BuildHasherDefault; -use fdg::Field; -use nalgebra::Point; - -#[derive(Debug, Clone)] -pub struct StressMajorizationConfiguration { - pub dt: F, -} - -use petgraph::{ - algo::{dijkstra, Measure}, - graph::NodeIndex, - stable_graph::StableGraph, -}; -use StressMajorizationConfiguration as Config; - -impl Default for Config { - fn default() -> Self { - Self { - dt: F::from(0.035).unwrap(), - } - } -} - -/// A basic implementation -#[derive(Debug)] -pub struct StressMajorization { - pub conf: Config, - pub shortest_path_matrix: HashMap>, -} - -impl StressMajorization { - pub fn new(conf: Config) -> Self { - Self { - conf, - shortest_path_matrix: HashMap::new(), - } - } - - fn apply(&mut self, graph: &mut StableGraph<(N, Point), E>) { - // if self.shortest_path_matrix.is_empty() { - // self.shortest_path_matrix = graph - // .node_indices() - // .map(|idx| { - // (idx, ) - // }) - // .collect(); - // } - - // let borrowed_graph: &StableGraph<(N, Point), E> = graph; - - self.shortest_path_matrix.extend( - graph - .node_indices() - .map(|idx| (idx, dijkstra(graph as &_, idx, None, |_| F::one()))), - ) - } - - fn calc_stress( - &mut self, - graph: &mut StableGraph<(N, Point), E>, - ) -> F { - // graph - // .node_indices() - // .flat_map(|v| { - // graph.node_indices().skip(v.index() + 1).map(move |w| { - // let dist = nalgebra::distance( - // &graph.node_weight(v).unwrap().1, - // &graph.node_weight(w).unwrap().1, - // ); - - // if dist != F::zero() { - // let dij = self.shortest_path_matrix[&v][&w]; - - // let sp_diff = self.shortest_path_matrix[&v][&w] - dist; - // dij.simd_sqrt().abs() * sp_diff * sp_diff - // } else { - // F::zero() - // } - // }) - // }) - // .sum() - F::default() - } -} +// use fdg::Field; +// use nalgebra::Point; + +// #[derive(Debug, Clone)] +// pub struct StressMajorizationConfiguration { +// pub dt: F, +// } + +// use petgraph::{ +// algo::{dijkstra, Measure}, +// graph::NodeIndex, +// stable_graph::StableGraph, +// }; +// use StressMajorizationConfiguration as Config; + +// impl Default for Config { +// fn default() -> Self { +// Self { +// dt: F::from(0.035).unwrap(), +// } +// } +// } + +// /// A basic implementation +// #[derive(Debug)] +// pub struct StressMajorization { +// pub conf: Config, +// pub shortest_path_matrix: HashMap>, +// } + +// impl StressMajorization { +// pub fn new(conf: Config) -> Self { +// Self { +// conf, +// shortest_path_matrix: HashMap::new(), +// } +// } + +// fn apply(&mut self, graph: &mut StableGraph<(N, Point), E>) { +// // if self.shortest_path_matrix.is_empty() { +// // self.shortest_path_matrix = graph +// // .node_indices() +// // .map(|idx| { +// // (idx, ) +// // }) +// // .collect(); +// // } + +// // let borrowed_graph: &StableGraph<(N, Point), E> = graph; + +// self.shortest_path_matrix.extend( +// graph +// .node_indices() +// .map(|idx| (idx, dijkstra(graph as &_, idx, None, |_| F::one()))), +// ) +// } + +// fn calc_stress( +// &mut self, +// graph: &mut StableGraph<(N, Point), E>, +// ) -> F { +// // graph +// // .node_indices() +// // .flat_map(|v| { +// // graph.node_indices().skip(v.index() + 1).map(move |w| { +// // let dist = nalgebra::distance( +// // &graph.node_weight(v).unwrap().1, +// // &graph.node_weight(w).unwrap().1, +// // ); + +// // if dist != F::zero() { +// // let dij = self.shortest_path_matrix[&v][&w]; + +// // let sp_diff = self.shortest_path_matrix[&v][&w] - dist; +// // dij.simd_sqrt().abs() * sp_diff * sp_diff +// // } else { +// // F::zero() +// // } +// // }) +// // }) +// // .sum() +// F::default() +// } +// } // impl Force for StressMajorization { // fn apply(&mut self, graph: &mut ForceGraph) { diff --git a/examples/graphs-1/src/gd.rs b/examples/graphs-1/src/gd.rs index f72f061..59f9080 100644 --- a/examples/graphs-1/src/gd.rs +++ b/examples/graphs-1/src/gd.rs @@ -1,6 +1,8 @@ +#![allow(dead_code)] + use std::collections::HashMap; -struct Graph { +pub struct Graph { edges_from: Vec, edges_to: Vec, } @@ -27,7 +29,7 @@ impl Graph { } pub fn update( - graph: &Graph, + _graph: &Graph, xs: &Vec, ys: &Vec, desired_distance_matrix: &HashMap>, diff --git a/examples/graphs-1/src/main.rs b/examples/graphs-1/src/main.rs index b24829f..ddd5e5b 100644 --- a/examples/graphs-1/src/main.rs +++ b/examples/graphs-1/src/main.rs @@ -1,13 +1,6 @@ -use std::{ - collections::HashMap, - env, - io::{BufRead, BufReader}, - ops::AddAssign, - time::Instant, -}; +use std::{collections::HashMap, env, ops::AddAssign, time::Instant}; use asd::{gfa::Entry, parser}; -use indicatif::ProgressIterator; use macroquad::{prelude::*, rand, ui::root_ui}; use nalgebra::{Point2, SVector}; use petgraph::{algo::dijkstra, graph::NodeIndex, stable_graph::StableGraph}; diff --git a/src/gfa.rs b/src/gfa.rs index 81c2813..f48f376 100644 --- a/src/gfa.rs +++ b/src/gfa.rs @@ -15,6 +15,7 @@ impl Display for Orientation { } } +#[allow(dead_code)] #[derive(Debug)] pub enum Entry { Header { diff --git a/src/graph.rs b/src/graph.rs index 43c60f6..346fcd7 100644 --- a/src/graph.rs +++ b/src/graph.rs @@ -6,7 +6,7 @@ use std::{ rc::Rc, }; -use indicatif::{ProgressIterator, ProgressStyle}; +use indicatif::ProgressIterator; #[derive(Debug)] pub struct AdjacencyGraph diff --git a/src/parser.rs b/src/parser.rs index a89b96f..6a93672 100644 --- a/src/parser.rs +++ b/src/parser.rs @@ -1,9 +1,8 @@ +#![allow(dead_code)] + use std::{ - borrow::Cow, io::{self, BufRead, BufReader, Read}, str::FromStr, - thread, - time::Duration, }; use indicatif::ProgressIterator;