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 petgraph::{stable_graph::{EdgeReference, NodeIndex, StableGraph}, visit::{EdgeRef, VisitMap, Visitable}, Direction};
|
||||||
|
|
||||||
use crate::random_generator::MaxflowProblem;
|
//use crate::random_generator::MaxflowProblem;
|
||||||
//mod random_generator;
|
//mod random_generator;
|
||||||
|
|
||||||
fn available_capacity(edge: EdgeReference<'_, (u64, u64)>) -> u64 {
|
fn available_capacity(edge: EdgeReference<'_, (u64, u64)>) -> u64 {
|
||||||
|
|||||||
@@ -1,8 +1,7 @@
|
|||||||
use std::f32::consts::PI;
|
use std::f32::consts::PI;
|
||||||
|
|
||||||
use egui::{
|
use egui::{
|
||||||
epaint::{CubicBezierShape, QuadraticBezierShape},
|
epaint::{CubicBezierShape, QuadraticBezierShape, TextShape}, text::LayoutJob, Color32, FontFamily, FontId, Pos2, Shape, Stroke, TextFormat, Vec2
|
||||||
Color32, Pos2, Stroke, Vec2, Shape, FontId, FontFamily, epaint::{TextShape}
|
|
||||||
};
|
};
|
||||||
|
|
||||||
use petgraph::{matrix_graph::Nullable, stable_graph::IndexType, EdgeType};
|
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,
|
ctx: &DrawContext,
|
||||||
) -> Vec<egui::Shape> {
|
) -> Vec<egui::Shape> {
|
||||||
// fixed properties
|
// 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_color = Color32::DARK_GRAY;
|
||||||
//let label_visible = true;
|
//let label_visible = true;
|
||||||
//let style = ctx.ctx.style().visuals.widgets.inactive;
|
//let style = ctx.ctx.style().visuals.widgets.inactive;
|
||||||
|
|||||||
@@ -113,6 +113,9 @@ impl MaxflowProblem {
|
|||||||
let (flow, capacity): (u64, u64) = *e.payload();
|
let (flow, capacity): (u64, u64) = *e.payload();
|
||||||
default_edge_transform(e);
|
default_edge_transform(e);
|
||||||
e.set_label(format!("{flow}:{capacity}"));
|
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"));
|
graph.node_mut(self.s).expect("node index not found").set_label(String::from("s"));
|
||||||
|
|||||||
Reference in New Issue
Block a user