Files
maxflow-rs/README.md
2025-08-27 00:06:12 +02:00

101 lines
4.8 KiB
Markdown

# Maxflow-rs
## Idea
- Generate StableGraph (petgraph)
- run algo on that
- Create a custom to_graph method which displays a maxflow graph
TODOs
- [x] Implementation of Algos:
- [x] Ford-Fulkersson (DFS zur Berechnung des flusserhöhenden/augmentierenden Pfads)
- [x] Edmonds-Karp (BFS zur Berechnung des flusserhöhenden/augmnetierenden Pfads)
- [x] Dinic
- [x] Goldberg-Tarjan/Preflow-Push
- [x] Step-by-step implementation for all algos
- [x] Ford-Fulkerson
- [x] Edmonds-Karp
- [x] Dinic
- [x] Goldberg-Tarjan/Preflow-Push
- [x] Mark edges which have active flows with a color
- [x] Move GUI Graph conversion to a trait of StableGraph
- [ ] Add graph positioning strategy which looks "nicer"
- [x] Only insert nodes which are at least a distance of 40 away (default)
- [ ] Pseudo-random node positioning strategy
- [x] Handle residual edges properly
- [x] Add display option for residual edges
- [x] Only show active flows (filter all edges with f=0)
- [x] Show normal vs residual graph -> not needed, residual graph is shown by default
- [x] When increasing flows, handle residual path
- [x] Add unit tests
- [x] With small problems to prove correctness
- [x] For Benchmarking the algos
- [x] Check validity of the generated flows (incoming flows = outgoing flows; flow <= capacity)
- [x] Add info display pane
- [x] is valid flow? (add trait to graph)
- [x] current total flow (add trait to calculate)
- [x] number of steps (is implemented for stepwise)
- [x] implement PartialEq for StableGraph (not really possible -> how do you compare graphs?) -> implemented a prune_zero trait & compare node/edge weights for same index
- [x] Step-by-step vizualisation with choosable time delay
- [ ] Dinic: add GUI options to show Layer Graph and Blocking flow
- [ ] Goldberg-Tarjan: show distance labels at nodes
- [x] change GUI colors to accomodate color-blindness (blue-yellow rather than red-green)
- [x] remove display option for residual graph -> this should be the default
DFS: Stack
BFS: Queue
Bugs:
- [x] if I generate a new graph, the algo runs on the old graph
- [x] if I click reset & then step, the algo runs in one step
- [x] when using edmonds karp the updated flow isn't displayed correctly
- [ ] the capacity on residual edges also gets displayed when using
Residual Graph:
- parallel arcs in the same direction can be summarized into a single arc by summing up the capcities
-
TODOs:
- [x] gui colors in yellow blue (should be easy)
- [x] no residual graph option, residual graph is default (medium, bit of effort)
- [ ] do we need to delete the graph field in algos & use residual_graph instead?
- [ ] check correctness of all algos by testing a small sample#
- [ ] gui display options (medium)
- [ ] layer graph (done - TODO: check if correct) & blocking flow (for Dinic)
- [ ] goldberg-tarjan: push-relabel step - current pre-flow, flow change in every step
- [x] add time delay for algorithm (hard due to multithreading)
- [ ] fix glitchy graph display (somewhere in update_graph function)
- [ ] implement goldberg tarjan (hard)
- [x] fix residual edges: algo pushes flows back but increases flow on the residual edge instead of decreasing the reverse edge
- [ ] fix loops: somehow the algo produces loops towards the source node (not critical for calculating the total flow, but should be fixed)
- [ ] big tests sometimes fail for goldberg-tarjan (panic when reading node from distance labelling)
- [x] make MaxflowAlgorithm object-safe (remove from_problem & implement it per struct, then create a generic wrapper which creates new instances for each specific algorithm)
- [ ] add unit test environment (hard)
- [x] callable from gui
- [x] several test tuples [number of problems, node count, max capacity]
- [x] split MaxflowProblem:new into two functions (one for display, one for test environment)
- [x] apply to every algo
- [x] große testumgebung
- [x] testfunktion in seperatem thread ausführen, damit programm nicht hängt
- [ ] check for:
- [x] flusserhaltung
- [x] kapazitätsbedingungen
- [ ] saturierter schritt
- [ ] testumgebung durch änderungen der lösung automatisch überprüfen (korrektheit, optimalität)
- [x] reduce warnings
thread '<unnamed>' panicked at src/graph.rs:191:31
attempt to subtract with overflow
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
thread '<unnamed>' panicked at src/algorithms/goldberg_tarjan.rs:109:238:
No distance label found
note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace
# Code erklären
- Graph generieren (random_generator.rs)
- GUI, Custom Layout (main.rs, layout.rs)
- Graph Hilfsfunktionen (graph.rs)
- Algorithmen (ford_fulkerson.rs, edmonds_karp.rs, dinic.rs, goldberg_tarjan.rs)