mirror of
https://github.com/aziis98/asd-2024.git
synced 2026-10-06 14:44:59 +00:00
fix: added allow dead_code
This commit is contained in:
@@ -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<rustc_hash::FxHasher>;
|
||||
|
||||
use fdg::Field;
|
||||
use nalgebra::Point;
|
||||
// use fdg::Field;
|
||||
// use nalgebra::Point;
|
||||
|
||||
#[derive(Debug, Clone)]
|
||||
pub struct StressMajorizationConfiguration<F: Field> {
|
||||
pub dt: F,
|
||||
}
|
||||
// #[derive(Debug, Clone)]
|
||||
// pub struct StressMajorizationConfiguration<F: Field> {
|
||||
// pub dt: F,
|
||||
// }
|
||||
|
||||
use petgraph::{
|
||||
algo::{dijkstra, Measure},
|
||||
graph::NodeIndex,
|
||||
stable_graph::StableGraph,
|
||||
};
|
||||
use StressMajorizationConfiguration as Config;
|
||||
// use petgraph::{
|
||||
// algo::{dijkstra, Measure},
|
||||
// graph::NodeIndex,
|
||||
// stable_graph::StableGraph,
|
||||
// };
|
||||
// use StressMajorizationConfiguration as Config;
|
||||
|
||||
impl<F: Field> Default for Config<F> {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
dt: F::from(0.035).unwrap(),
|
||||
}
|
||||
}
|
||||
}
|
||||
// impl<F: Field> Default for Config<F> {
|
||||
// fn default() -> Self {
|
||||
// Self {
|
||||
// dt: F::from(0.035).unwrap(),
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
|
||||
/// A basic implementation
|
||||
#[derive(Debug)]
|
||||
pub struct StressMajorization<F: Field, const D: usize> {
|
||||
pub conf: Config<F>,
|
||||
pub shortest_path_matrix: HashMap<NodeIndex, HashMap<NodeIndex, F>>,
|
||||
}
|
||||
// /// A basic implementation
|
||||
// #[derive(Debug)]
|
||||
// pub struct StressMajorization<F: Field, const D: usize> {
|
||||
// pub conf: Config<F>,
|
||||
// pub shortest_path_matrix: HashMap<NodeIndex, HashMap<NodeIndex, F>>,
|
||||
// }
|
||||
|
||||
impl<F: Field + Measure + Sum, const D: usize> StressMajorization<F, D> {
|
||||
pub fn new(conf: Config<F>) -> Self {
|
||||
Self {
|
||||
conf,
|
||||
shortest_path_matrix: HashMap::new(),
|
||||
}
|
||||
}
|
||||
// impl<F: Field + Measure + Sum, const D: usize> StressMajorization<F, D> {
|
||||
// pub fn new(conf: Config<F>) -> Self {
|
||||
// Self {
|
||||
// conf,
|
||||
// shortest_path_matrix: HashMap::new(),
|
||||
// }
|
||||
// }
|
||||
|
||||
fn apply<N: Clone, E: Clone>(&mut self, graph: &mut StableGraph<(N, Point<F, D>), E>) {
|
||||
// if self.shortest_path_matrix.is_empty() {
|
||||
// self.shortest_path_matrix = graph
|
||||
// .node_indices()
|
||||
// .map(|idx| {
|
||||
// (idx, )
|
||||
// })
|
||||
// .collect();
|
||||
// }
|
||||
// fn apply<N: Clone, E: Clone>(&mut self, graph: &mut StableGraph<(N, Point<F, D>), 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<F, D>), E> = graph;
|
||||
// // let borrowed_graph: &StableGraph<(N, Point<F, D>), E> = graph;
|
||||
|
||||
self.shortest_path_matrix.extend(
|
||||
graph
|
||||
.node_indices()
|
||||
.map(|idx| (idx, dijkstra(graph as &_, idx, None, |_| F::one()))),
|
||||
)
|
||||
}
|
||||
// self.shortest_path_matrix.extend(
|
||||
// graph
|
||||
// .node_indices()
|
||||
// .map(|idx| (idx, dijkstra(graph as &_, idx, None, |_| F::one()))),
|
||||
// )
|
||||
// }
|
||||
|
||||
fn calc_stress<N: Clone, E: Clone>(
|
||||
&mut self,
|
||||
graph: &mut StableGraph<(N, Point<F, D>), 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,
|
||||
// );
|
||||
// fn calc_stress<N: Clone, E: Clone>(
|
||||
// &mut self,
|
||||
// graph: &mut StableGraph<(N, Point<F, D>), 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];
|
||||
// // 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()
|
||||
}
|
||||
}
|
||||
// // 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<const D: usize, N, E> Force<f32, D, N, E> for StressMajorization<D> {
|
||||
// fn apply(&mut self, graph: &mut ForceGraph<f32, D, N, E>) {
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::collections::HashMap;
|
||||
|
||||
struct Graph {
|
||||
pub struct Graph {
|
||||
edges_from: Vec<u32>,
|
||||
edges_to: Vec<u32>,
|
||||
}
|
||||
@@ -27,7 +29,7 @@ impl Graph {
|
||||
}
|
||||
|
||||
pub fn update(
|
||||
graph: &Graph,
|
||||
_graph: &Graph,
|
||||
xs: &Vec<f32>,
|
||||
ys: &Vec<f32>,
|
||||
desired_distance_matrix: &HashMap<usize, HashMap<usize, f32>>,
|
||||
|
||||
@@ -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};
|
||||
|
||||
@@ -15,6 +15,7 @@ impl Display for Orientation {
|
||||
}
|
||||
}
|
||||
|
||||
#[allow(dead_code)]
|
||||
#[derive(Debug)]
|
||||
pub enum Entry {
|
||||
Header {
|
||||
|
||||
+1
-1
@@ -6,7 +6,7 @@ use std::{
|
||||
rc::Rc,
|
||||
};
|
||||
|
||||
use indicatif::{ProgressIterator, ProgressStyle};
|
||||
use indicatif::ProgressIterator;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub struct AdjacencyGraph<V>
|
||||
|
||||
+2
-3
@@ -1,9 +1,8 @@
|
||||
#![allow(dead_code)]
|
||||
|
||||
use std::{
|
||||
borrow::Cow,
|
||||
io::{self, BufRead, BufReader, Read},
|
||||
str::FromStr,
|
||||
thread,
|
||||
time::Duration,
|
||||
};
|
||||
|
||||
use indicatif::ProgressIterator;
|
||||
|
||||
Reference in New Issue
Block a user