|
|
@ -5,11 +5,13 @@ use asd::{
|
|
|
|
parser,
|
|
|
|
parser,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
use fdg::{
|
|
|
|
use fdg::{
|
|
|
|
fruchterman_reingold::{FruchtermanReingold, FruchtermanReingoldConfiguration},
|
|
|
|
fruchterman_reingold::{
|
|
|
|
nalgebra::Rotation2,
|
|
|
|
FruchtermanReingold, FruchtermanReingoldConfiguration, FruchtermanReingoldParallel,
|
|
|
|
|
|
|
|
},
|
|
|
|
petgraph::Graph,
|
|
|
|
petgraph::Graph,
|
|
|
|
simple::Center,
|
|
|
|
// simple::Center,
|
|
|
|
Force, ForceGraph,
|
|
|
|
Force,
|
|
|
|
|
|
|
|
ForceGraph,
|
|
|
|
};
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
|
|
use macroquad::prelude::*;
|
|
|
|
use macroquad::prelude::*;
|
|
|
@ -50,7 +52,7 @@ async fn main() {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let mut force_graph: ForceGraph<f32, 2, (String, Orientation), ()> =
|
|
|
|
let mut force_graph: ForceGraph<f32, 2, (String, Orientation), ()> =
|
|
|
|
fdg::init_force_graph_uniform(graph, 200.0);
|
|
|
|
fdg::init_force_graph_uniform(graph, 1000.0);
|
|
|
|
|
|
|
|
|
|
|
|
// custom closure force which rotates each node
|
|
|
|
// custom closure force which rotates each node
|
|
|
|
// let mut rotate = |graph: &mut ForceGraph<f32, 2, (String, Orientation), ()>| {
|
|
|
|
// let mut rotate = |graph: &mut ForceGraph<f32, 2, (String, Orientation), ()>| {
|
|
|
@ -58,9 +60,9 @@ async fn main() {
|
|
|
|
// .node_weights_mut()
|
|
|
|
// .node_weights_mut()
|
|
|
|
// .for_each(|(_, p)| *p = Rotation2::new(0.005).transform_point(p))
|
|
|
|
// .for_each(|(_, p)| *p = Rotation2::new(0.005).transform_point(p))
|
|
|
|
// };
|
|
|
|
// };
|
|
|
|
let mut force = FruchtermanReingold {
|
|
|
|
let mut force = FruchtermanReingoldParallel {
|
|
|
|
conf: FruchtermanReingoldConfiguration {
|
|
|
|
conf: FruchtermanReingoldConfiguration {
|
|
|
|
scale: 400.0,
|
|
|
|
scale: 100.0,
|
|
|
|
..Default::default()
|
|
|
|
..Default::default()
|
|
|
|
},
|
|
|
|
},
|
|
|
|
..Default::default()
|
|
|
|
..Default::default()
|
|
|
@ -68,9 +70,9 @@ async fn main() {
|
|
|
|
|
|
|
|
|
|
|
|
loop {
|
|
|
|
loop {
|
|
|
|
println!("frame");
|
|
|
|
println!("frame");
|
|
|
|
force.apply_many(&mut force_graph, 1);
|
|
|
|
force.apply_many(&mut force_graph, 2);
|
|
|
|
|
|
|
|
|
|
|
|
Center::default().apply(&mut force_graph);
|
|
|
|
// Center::default().apply(&mut force_graph);
|
|
|
|
// rotate.apply(&mut force_graph);
|
|
|
|
// rotate.apply(&mut force_graph);
|
|
|
|
|
|
|
|
|
|
|
|
let scale = calculate_scale(&force_graph);
|
|
|
|
let scale = calculate_scale(&force_graph);
|
|
|
@ -93,23 +95,23 @@ async fn main() {
|
|
|
|
translate_y(source.coords.column(0)[1], scale),
|
|
|
|
translate_y(source.coords.column(0)[1], scale),
|
|
|
|
translate_x(target.coords.column(0)[0], scale),
|
|
|
|
translate_x(target.coords.column(0)[0], scale),
|
|
|
|
translate_y(target.coords.column(0)[1], scale),
|
|
|
|
translate_y(target.coords.column(0)[1], scale),
|
|
|
|
4.0,
|
|
|
|
1.0,
|
|
|
|
BLACK,
|
|
|
|
BLACK,
|
|
|
|
);
|
|
|
|
);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
for ((name, orient), pos) in force_graph.node_weights() {
|
|
|
|
for ((_name, _orient), pos) in force_graph.node_weights() {
|
|
|
|
let x = translate_x(pos.coords.column(0)[0], scale);
|
|
|
|
let x = translate_x(pos.coords.column(0)[0], scale);
|
|
|
|
let y = translate_y(pos.coords.column(0)[1], scale);
|
|
|
|
let y = translate_y(pos.coords.column(0)[1], scale);
|
|
|
|
|
|
|
|
|
|
|
|
draw_circle(x, y, 20.0 * scale, RED);
|
|
|
|
draw_circle(x, y, 2.0, RED);
|
|
|
|
draw_text(
|
|
|
|
// draw_text(
|
|
|
|
format!("{}{}", name, orient).as_str(),
|
|
|
|
// format!("{}{}", name, orient).as_str(),
|
|
|
|
x - 30.0 * scale,
|
|
|
|
// x - 30.0 * scale,
|
|
|
|
y - 30.0 * scale,
|
|
|
|
// y - 30.0 * scale,
|
|
|
|
40.0 * scale,
|
|
|
|
// 40.0 * scale,
|
|
|
|
BLACK,
|
|
|
|
// BLACK,
|
|
|
|
);
|
|
|
|
// );
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
next_frame().await
|
|
|
|
next_frame().await
|
|
|
|