Implement Ford-Fulkerson
This commit is contained in:
33
src/graph.rs
Normal file
33
src/graph.rs
Normal file
@@ -0,0 +1,33 @@
|
||||
//use egui_graphs::{Node, Edge};
|
||||
use petgraph::graph::{Node, Edge};
|
||||
|
||||
pub trait MaxflowNode {
|
||||
fn visited(&self) -> bool;
|
||||
fn set_visited(&mut self, b: bool);
|
||||
}
|
||||
|
||||
pub trait MaxflowEdge {
|
||||
fn remaining_capacity(&self) -> u64;
|
||||
fn set_capacity(&mut self, c: u64);
|
||||
}
|
||||
|
||||
/* impl MaxflowNode for Node<bool, (u64, u64)> {
|
||||
fn visited(&self) -> bool {
|
||||
*self.()
|
||||
}
|
||||
|
||||
fn set_visited(&mut self, b: bool) {
|
||||
let payload = self.payload_mut();
|
||||
*payload = b;
|
||||
}
|
||||
} */
|
||||
|
||||
impl MaxflowEdge for Edge<(u64, u64)> {
|
||||
fn remaining_capacity(&self) -> u64 {
|
||||
self.weight.1 - self.weight.0
|
||||
}
|
||||
|
||||
fn set_capacity(&mut self, c: u64) {
|
||||
self.weight.0 = c;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user