fix: added allow dead_code

main
Antonio De Lucreziis 2 months ago
parent 6209477a3f
commit 3fa06496f6

@ -1,99 +1,99 @@
use std::{ // use std::{
collections::HashMap, // collections::HashMap,
hash::{BuildHasherDefault, Hash}, // hash::{BuildHasherDefault, Hash},
iter::Sum, // iter::Sum,
ops::AddAssign, // ops::AddAssign,
}; // };
// use nalgebra::{Point, SVector}; // use nalgebra::{Point, SVector};
// use petgraph::stable_graph::NodeIndex; // use petgraph::stable_graph::NodeIndex;
// type HashFn = BuildHasherDefault<rustc_hash::FxHasher>; // type HashFn = BuildHasherDefault<rustc_hash::FxHasher>;
use fdg::Field; // use fdg::Field;
use nalgebra::Point; // use nalgebra::Point;
#[derive(Debug, Clone)] // #[derive(Debug, Clone)]
pub struct StressMajorizationConfiguration<F: Field> { // pub struct StressMajorizationConfiguration<F: Field> {
pub dt: F, // pub dt: F,
} // }
use petgraph::{ // use petgraph::{
algo::{dijkstra, Measure}, // algo::{dijkstra, Measure},
graph::NodeIndex, // graph::NodeIndex,
stable_graph::StableGraph, // stable_graph::StableGraph,
}; // };
use StressMajorizationConfiguration as Config; // use StressMajorizationConfiguration as Config;
impl<F: Field> Default for Config<F> { // impl<F: Field> Default for Config<F> {
fn default() -> Self { // fn default() -> Self {
Self { // Self {
dt: F::from(0.035).unwrap(), // dt: F::from(0.035).unwrap(),
} // }
} // }
} // }
/// A basic implementation // /// A basic implementation
#[derive(Debug)] // #[derive(Debug)]
pub struct StressMajorization<F: Field, const D: usize> { // pub struct StressMajorization<F: Field, const D: usize> {
pub conf: Config<F>, // pub conf: Config<F>,
pub shortest_path_matrix: HashMap<NodeIndex, HashMap<NodeIndex, F>>, // pub shortest_path_matrix: HashMap<NodeIndex, HashMap<NodeIndex, F>>,
} // }
impl<F: Field + Measure + Sum, const D: usize> StressMajorization<F, D> { // impl<F: Field + Measure + Sum, const D: usize> StressMajorization<F, D> {
pub fn new(conf: Config<F>) -> Self { // pub fn new(conf: Config<F>) -> Self {
Self { // Self {
conf, // conf,
shortest_path_matrix: HashMap::new(), // shortest_path_matrix: HashMap::new(),
} // }
} // }
fn apply<N: Clone, E: Clone>(&mut self, graph: &mut StableGraph<(N, Point<F, D>), E>) { // fn apply<N: Clone, E: Clone>(&mut self, graph: &mut StableGraph<(N, Point<F, D>), E>) {
// if self.shortest_path_matrix.is_empty() { // // if self.shortest_path_matrix.is_empty() {
// self.shortest_path_matrix = graph // // self.shortest_path_matrix = graph
// .node_indices() // // .node_indices()
// .map(|idx| { // // .map(|idx| {
// (idx, ) // // (idx, )
// }) // // })
// .collect(); // // .collect();
// } // // }
// let borrowed_graph: &StableGraph<(N, Point<F, D>), E> = graph; // // let borrowed_graph: &StableGraph<(N, Point<F, D>), E> = graph;
self.shortest_path_matrix.extend( // self.shortest_path_matrix.extend(
graph // graph
.node_indices() // .node_indices()
.map(|idx| (idx, dijkstra(graph as &_, idx, None, |_| F::one()))), // .map(|idx| (idx, dijkstra(graph as &_, idx, None, |_| F::one()))),
) // )
} // }
fn calc_stress<N: Clone, E: Clone>( // fn calc_stress<N: Clone, E: Clone>(
&mut self, // &mut self,
graph: &mut StableGraph<(N, Point<F, D>), E>, // graph: &mut StableGraph<(N, Point<F, D>), E>,
) -> F { // ) -> F {
// graph // // graph
// .node_indices() // // .node_indices()
// .flat_map(|v| { // // .flat_map(|v| {
// graph.node_indices().skip(v.index() + 1).map(move |w| { // // graph.node_indices().skip(v.index() + 1).map(move |w| {
// let dist = nalgebra::distance( // // let dist = nalgebra::distance(
// &graph.node_weight(v).unwrap().1, // // &graph.node_weight(v).unwrap().1,
// &graph.node_weight(w).unwrap().1, // // &graph.node_weight(w).unwrap().1,
// ); // // );
// if dist != F::zero() { // // if dist != F::zero() {
// let dij = self.shortest_path_matrix[&v][&w]; // // let dij = self.shortest_path_matrix[&v][&w];
// let sp_diff = self.shortest_path_matrix[&v][&w] - dist; // // let sp_diff = self.shortest_path_matrix[&v][&w] - dist;
// dij.simd_sqrt().abs() * sp_diff * sp_diff // // dij.simd_sqrt().abs() * sp_diff * sp_diff
// } else { // // } else {
// F::zero() // // F::zero()
// } // // }
// }) // // })
// }) // // })
// .sum() // // .sum()
F::default() // F::default()
} // }
} // }
// impl<const D: usize, N, E> Force<f32, D, N, E> for StressMajorization<D> { // impl<const D: usize, N, E> Force<f32, D, N, E> for StressMajorization<D> {
// fn apply(&mut self, graph: &mut ForceGraph<f32, D, N, E>) { // fn apply(&mut self, graph: &mut ForceGraph<f32, D, N, E>) {

@ -1,6 +1,8 @@
#![allow(dead_code)]
use std::collections::HashMap; use std::collections::HashMap;
struct Graph { pub struct Graph {
edges_from: Vec<u32>, edges_from: Vec<u32>,
edges_to: Vec<u32>, edges_to: Vec<u32>,
} }
@ -27,7 +29,7 @@ impl Graph {
} }
pub fn update( pub fn update(
graph: &Graph, _graph: &Graph,
xs: &Vec<f32>, xs: &Vec<f32>,
ys: &Vec<f32>, ys: &Vec<f32>,
desired_distance_matrix: &HashMap<usize, HashMap<usize, f32>>, desired_distance_matrix: &HashMap<usize, HashMap<usize, f32>>,

@ -1,13 +1,6 @@
use std::{ use std::{collections::HashMap, env, ops::AddAssign, time::Instant};
collections::HashMap,
env,
io::{BufRead, BufReader},
ops::AddAssign,
time::Instant,
};
use asd::{gfa::Entry, parser}; use asd::{gfa::Entry, parser};
use indicatif::ProgressIterator;
use macroquad::{prelude::*, rand, ui::root_ui}; use macroquad::{prelude::*, rand, ui::root_ui};
use nalgebra::{Point2, SVector}; use nalgebra::{Point2, SVector};
use petgraph::{algo::dijkstra, graph::NodeIndex, stable_graph::StableGraph}; use petgraph::{algo::dijkstra, graph::NodeIndex, stable_graph::StableGraph};

@ -15,6 +15,7 @@ impl Display for Orientation {
} }
} }
#[allow(dead_code)]
#[derive(Debug)] #[derive(Debug)]
pub enum Entry { pub enum Entry {
Header { Header {

@ -6,7 +6,7 @@ use std::{
rc::Rc, rc::Rc,
}; };
use indicatif::{ProgressIterator, ProgressStyle}; use indicatif::ProgressIterator;
#[derive(Debug)] #[derive(Debug)]
pub struct AdjacencyGraph<V> pub struct AdjacencyGraph<V>

@ -1,9 +1,8 @@
#![allow(dead_code)]
use std::{ use std::{
borrow::Cow,
io::{self, BufRead, BufReader, Read}, io::{self, BufRead, BufReader, Read},
str::FromStr, str::FromStr,
thread,
time::Duration,
}; };
use indicatif::ProgressIterator; use indicatif::ProgressIterator;

Loading…
Cancel
Save