Highlight edges with active flows
This commit is contained in:
@@ -7,7 +7,7 @@ use std::collections::VecDeque;
|
||||
|
||||
use petgraph::{stable_graph::{EdgeReference, NodeIndex, StableGraph}, visit::{EdgeRef, VisitMap, Visitable}, Direction};
|
||||
|
||||
use crate::random_generator::MaxflowProblem;
|
||||
//use crate::random_generator::MaxflowProblem;
|
||||
//mod random_generator;
|
||||
|
||||
fn available_capacity(edge: EdgeReference<'_, (u64, u64)>) -> u64 {
|
||||
|
||||
@@ -1,8 +1,7 @@
|
||||
use std::f32::consts::PI;
|
||||
|
||||
use egui::{
|
||||
epaint::{CubicBezierShape, QuadraticBezierShape},
|
||||
Color32, Pos2, Stroke, Vec2, Shape, FontId, FontFamily, epaint::{TextShape}
|
||||
epaint::{CubicBezierShape, QuadraticBezierShape, TextShape}, text::LayoutJob, Color32, FontFamily, FontId, Pos2, Shape, Stroke, TextFormat, Vec2
|
||||
};
|
||||
|
||||
use petgraph::{matrix_graph::Nullable, stable_graph::IndexType, EdgeType};
|
||||
@@ -75,7 +74,10 @@ impl<N: Clone, E: Clone, Ty: EdgeType, Ix: IndexType, D: DisplayNode<N, E, Ty, I
|
||||
ctx: &DrawContext,
|
||||
) -> Vec<egui::Shape> {
|
||||
// fixed properties
|
||||
let edge_color = Color32::LIGHT_GRAY;
|
||||
let edge_color = match self.selected {
|
||||
true => Color32::LIGHT_BLUE,
|
||||
false => Color32::LIGHT_GRAY
|
||||
};
|
||||
let label_color = Color32::DARK_GRAY;
|
||||
//let label_visible = true;
|
||||
//let style = ctx.ctx.style().visuals.widgets.inactive;
|
||||
|
||||
@@ -113,6 +113,9 @@ impl MaxflowProblem {
|
||||
let (flow, capacity): (u64, u64) = *e.payload();
|
||||
default_edge_transform(e);
|
||||
e.set_label(format!("{flow}:{capacity}"));
|
||||
if flow > 0 {
|
||||
e.set_selected(true);
|
||||
}
|
||||
}
|
||||
);
|
||||
graph.node_mut(self.s).expect("node index not found").set_label(String::from("s"));
|
||||
|
||||
Reference in New Issue
Block a user