OpenTTD: src/linkgraph/mcf.h Source File

OpenTTD

- Main Page
- Related Pages
- Modules
- Namespaces
- Data Structures
- Files

- File List
- Globals

mcf.h
Go to the documentation of this file.
1
3 #ifndef MCF_H
4 #define MCF_H
5
6 #include "linkgraphjob_base.h"
7 #include <vector>
8
9 typedef std::vector<Path *> PathVector;
10
14 class MultiCommodityFlow {
15 protected:
20 MultiCommodityFlow(LinkGraphJob &job) : job(job),
21 max_saturation(job.Settings().short_path_saturation)
22 {}
23
24 template<class Tannotation, class Tedge_iterator>
25 void Dijkstra(NodeID from, PathVector &paths);
26
27 uint PushFlow(Edge &edge, Path *path, uint accuracy, uint max_saturation);
28
29 void CleanupPaths(NodeID source, PathVector &paths);
30
31 LinkGraphJob &job;
32 uint max_saturation;
33 };
34
50 class MCF1stPass : public MultiCommodityFlow {
51 private:
52 bool EliminateCycles();
53 bool EliminateCycles(PathVector &path, NodeID origin_id, NodeID next_id);
54 void EliminateCycle(PathVector &path, Path *cycle_begin, uint flow);
55 uint FindCycleFlow(const PathVector &path, const Path *cycle_begin);
56 public:
57 MCF1stPass(LinkGraphJob &job);
58 };
59
67 class MCF2ndPass : public MultiCommodityFlow {
68 public:
69 MCF2ndPass(LinkGraphJob &job);
70 };
71
76 template<class Tpass>
77 class MCFHandler : public ComponentHandler {
78 public:
79
84 virtual void Run(LinkGraphJob &job) const { Tpass pass(job); }
85
89 virtual ~MCFHandler() {}
90 };
91
92 #endif /* MCF_H */