From b54ac113ddd9e26016ed4eeae622e91e9e7f9f36 Mon Sep 17 00:00:00 2001 From: Antonio De Lucreziis Date: Sat, 25 May 2024 12:58:21 +0200 Subject: [PATCH] uao funge veramente in a4 --- examples/graphs-1/src/main.rs | 32 +++++++++++++++++++------------- 1 file changed, 19 insertions(+), 13 deletions(-) diff --git a/examples/graphs-1/src/main.rs b/examples/graphs-1/src/main.rs index dd51f00..7987d8c 100644 --- a/examples/graphs-1/src/main.rs +++ b/examples/graphs-1/src/main.rs @@ -45,7 +45,7 @@ async fn main() { // println!("correction: {:?}", correction); if distance > 0.0 && dist > 1e-6 { - 0.001 * delta.normalize() * correction.clamp(-10.0, 10.0) + 0.01 * delta.normalize() * correction.atan() } else { SVector::::zeros() } @@ -107,6 +107,8 @@ async fn main() { } fn load_graph() -> StableGraph<(String, Point2), ()> { + println!("Loading graph"); + let mut graph = StableGraph::new(); let file = std::fs::File::open(env::args().nth(1).expect("missing gfa file argument")).unwrap(); @@ -114,15 +116,17 @@ fn load_graph() -> StableGraph<(String, Point2), ()> { let mut index_map = HashMap::new(); - // let node_count = entries - // .iter() - // .filter_map(|entry| match entry { - // Entry::Segment { id, .. } => Some(id), - // _ => None, - // }) - // .count(); + let node_count = entries + .iter() + .filter_map(|entry| match entry { + Entry::Segment { id, .. } => Some(id), + _ => None, + }) + .count(); + + println!("Node count: {}", node_count); - // let radius = (node_count as f32).sqrt(); + let radius = (node_count as f32).sqrt(); let mut i = -10.0; @@ -148,8 +152,8 @@ fn load_graph() -> StableGraph<(String, Point2), ()> { graph.add_node(( format!("{}{}", from, from_orient), - // Point2::new(rand::gen_range(0.0, radius), rand::gen_range(0.0, radius)), - Point2::new(i, 50.0 + rand::gen_range(0.0, 100.0)), + Point2::new(rand::gen_range(0.0, radius), rand::gen_range(0.0, radius)), + // Point2::new(i, 50.0 + rand::gen_range(0.0, 100.0)), )) }) .to_owned(); @@ -162,8 +166,8 @@ fn load_graph() -> StableGraph<(String, Point2), ()> { graph.add_node(( format!("{}{}", from, to_orient), - // Point2::new(rand::gen_range(0.0, radius), rand::gen_range(0.0, radius)), - Point2::new(i, 50.0 + rand::gen_range(0.0, 100.0)), + Point2::new(rand::gen_range(0.0, radius), rand::gen_range(0.0, radius)), + // Point2::new(i, 50.0 + rand::gen_range(0.0, 100.0)), )) }) .to_owned(); @@ -173,6 +177,8 @@ fn load_graph() -> StableGraph<(String, Point2), ()> { } } + println!("Loading completed"); + graph }