Update egui_graphs, make maxflow problem generator work

This commit is contained in:
2025-03-17 10:21:35 +01:00
parent 818bfd569e
commit dcefeaa8c0
4 changed files with 819 additions and 467 deletions

View File

@@ -1,27 +1,32 @@
use eframe::{run_native, App, CreationContext, NativeOptions, Frame};
use egui::{CentralPanel, SidePanel, Context};
use egui_graphs::{GraphView, Graph, SettingsStyle};
use egui_graphs::{GraphView, Graph, SettingsStyle, LayoutRandom, LayoutStateRandom};
use random_generator::MaxflowProblem;
use algorithms::{ford_fulk
//use petgraph::stable_graph::StableGraph;
mod random_generator;
mod algorithms;
pub struct MaxflowApp {
g: Graph<(), u64>,
p: MaxflowProblem,
node_count: u64,
max_capacity: u64,
}
impl MaxflowApp {
fn new(_: &CreationContext<'_>) -> Self {
let problem = random_generator::MaxflowProblem::new(10, 10);
Self { g: problem.g, node_count: 10, max_capacity: 5 }
let problem = MaxflowProblem::new(10, 10);
Self { g: problem.g.clone(), p: problem, node_count: 10, max_capacity: 5 }
}
}
impl App for MaxflowApp {
fn update(&mut self, ctx: &Context, _: &mut Frame) {
CentralPanel::default().show(ctx, |ui| {
ui.add(&mut GraphView::new(&mut self.g).with_styles(&SettingsStyle::default().with_labels_always(true)));
ui.add(&mut GraphView::<_, _, _, _, _, _, LayoutStateRandom, LayoutRandom>::new(&mut self.g).with_styles(&SettingsStyle::default().with_labels_always(true)));
});
SidePanel::right("right_panel")
.min_width(200.)
@@ -34,6 +39,8 @@ impl App for MaxflowApp {
let problem = random_generator::MaxflowProblem::new(self.node_count, self.max_capacity);
self.g = problem.g;
}
if ui.button("run algorithm").clicked() {
}
});
}
}