initial commit
This commit is contained in:
43
src/main.rs
Normal file
43
src/main.rs
Normal file
@@ -0,0 +1,43 @@
|
||||
use eframe::{run_native, App, CreationContext, NativeOptions, Frame};
|
||||
use egui::{CentralPanel, SidePanel, Context};
|
||||
use egui_graphs::{GraphView, Graph, SettingsStyle};
|
||||
//use petgraph::stable_graph::StableGraph;
|
||||
|
||||
mod random_generator;
|
||||
|
||||
pub struct MaxflowApp {
|
||||
g: Graph<(), u64>,
|
||||
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 }
|
||||
}
|
||||
}
|
||||
|
||||
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)));
|
||||
});
|
||||
SidePanel::right("right_panel")
|
||||
.min_width(200.)
|
||||
.show(ctx, |ui| {
|
||||
ui.label("node count");
|
||||
ui.add(egui::DragValue::new(&mut self.node_count).range(1..=1000));
|
||||
ui.label("maximum capacity");
|
||||
ui.add(egui::DragValue::new(&mut self.max_capacity).range(1..=10));
|
||||
if ui.button("generate graph").clicked() {
|
||||
let problem = random_generator::MaxflowProblem::new(self.node_count, self.max_capacity);
|
||||
self.g = problem.g;
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
fn main() {
|
||||
run_native("Maxflow.rs", NativeOptions::default(), Box::new(|cc| Ok(Box::new(MaxflowApp::new(cc)))),).unwrap();
|
||||
}
|
||||
Reference in New Issue
Block a user