OpenTTD Source 20260109-master-g241b5fcdfe
mcf.h
Go to the documentation of this file.
1/*
2 * This file is part of OpenTTD.
3 * OpenTTD is free software; you can redistribute it and/or modify it under the terms of the GNU General Public License as published by the Free Software Foundation, version 2.
4 * OpenTTD is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
5 * See the GNU General Public License for more details. You should have received a copy of the GNU General Public License along with OpenTTD. If not, see <https://www.gnu.org/licenses/old-licenses/gpl-2.0>.
6 */
7
10#ifndef MCF_H
11#define MCF_H
12
13#include "linkgraphjob_base.h"
14
15typedef std::vector<Path *> PathVector;
16
21protected:
27 max_saturation(job.Settings().short_path_saturation)
28 {}
29
30 template <class Tannotation, class Tedge_iterator>
31 void Dijkstra(NodeID from, PathVector &paths);
32
33 uint PushFlow(Node &node, NodeID to, Path *path, uint accuracy, uint max_saturation);
34
35 void CleanupPaths(NodeID source, PathVector &paths);
36
39};
40
57private:
58 bool EliminateCycles();
59 bool EliminateCycles(PathVector &path, NodeID origin_id, NodeID next_id);
60 void EliminateCycle(PathVector &path, Path *cycle_begin, uint flow);
61 uint FindCycleFlow(const PathVector &path, const Path *cycle_begin);
62public:
64};
65
74public:
76};
77
82template <class Tpass>
84public:
85
90 void Run(LinkGraphJob &job) const override { Tpass pass(job); }
91};
92
93#endif /* MCF_H */
A handler doing "something" on a link graph component.
Class for calculation jobs to be run on link graphs.
First pass of the MCF calculation.
Definition mcf.h:56
bool EliminateCycles()
Eliminate all cycles in the graph.
Definition mcf.cpp:488
uint FindCycleFlow(const PathVector &path, const Path *cycle_begin)
Find the flow along a cycle including cycle_begin in path.
Definition mcf.cpp:367
void EliminateCycle(PathVector &path, Path *cycle_begin, uint flow)
Eliminate a cycle of the given flow in the given set of paths.
Definition mcf.cpp:384
Second pass of the MCF calculation.
Definition mcf.h:73
Link graph handler for MCF.
Definition mcf.h:83
void Run(LinkGraphJob &job) const override
Run the calculation.
Definition mcf.h:90
Multi-commodity flow calculating base class.
Definition mcf.h:20
MultiCommodityFlow(LinkGraphJob &job)
Constructor.
Definition mcf.h:26
void Dijkstra(NodeID from, PathVector &paths)
A slightly modified Dijkstra algorithm.
Definition mcf.cpp:264
LinkGraphJob & job
Job we're working with.
Definition mcf.h:37
uint max_saturation
Maximum saturation for edges.
Definition mcf.h:38
uint PushFlow(Node &node, NodeID to, Path *path, uint accuracy, uint max_saturation)
Push flow along a path and update the unsatisfied_demand of the associated edge.
Definition mcf.cpp:351
void CleanupPaths(NodeID source, PathVector &paths)
Clean up paths that lead nowhere and the root path.
Definition mcf.cpp:319
A leg of a path in the link graph.
Some typedefs for component handlers.
Node of the link graph.
Definition linkgraph.h:90