47template<
typename TCost>
78 return call(G, lowerBound, upperBound, cost,
supply, flow, dual);
186template<
typename TCost>
191 node s = G.firstNode();
192 node t = G.lastNode();
194 for (
node v : G.nodes) {
199 for (
edge e : G.edges) {
206 for (
node v = G.firstNode(),
vl = G.lastNode();
true; v = v->succ(),
vl =
vl->pred()) {
214 if (
vl == v->succ()) {
220template<
typename TCost>
227 for (
edge e : G.edges) {
228 if (lowerBound[e] > upperBound[e]) {
234 for (
node v : G.nodes) {
241template<
typename TCost>
247 for (
edge e : G.edges) {
248 if (flow[e] < lowerBound[e] || upperBound[e] < flow[e]) {
252 value += flow[e] * cost[e];
255 for (
node v : G.nodes) {
258 for (
adjEntry adj : v->adjEntries) {
259 edge e = adj->theEdge();
Includes declaration of graph class.
Class for adjacency list elements.
Dynamic arrays indexed with edges.
Class for the representation of edges.
bool isSelfLoop() const
Returns true iff the edge is a self-loop (source node = target node).
node source() const
Returns the source node of the edge.
Data type for general directed graphs (adjacency list representation).
Interface for min-cost flow algorithms.
static bool checkComputedFlow(const Graph &G, const EdgeArray< int > &lowerBound, const EdgeArray< int > &upperBound, const EdgeArray< TCost > &cost, const NodeArray< int > &supply, const EdgeArray< int > &flow, TCost &value)
checks if a computed flow is a feasible solution to the given problem instance.
virtual bool call(const Graph &G, const EdgeArray< int > &lowerBound, const EdgeArray< int > &upperBound, const EdgeArray< TCost > &cost, const NodeArray< int > &supply, EdgeArray< int > &flow, NodeArray< TCost > &dual)=0
Computes a min-cost flow in the directed graph G.
static void generateProblem(Graph &G, int n, int m, EdgeArray< int > &lowerBound, EdgeArray< int > &upperBound, EdgeArray< TCost > &cost, NodeArray< int > &supply)
Generates an instance of a min-cost flow problem with n nodes and m + n edges.
static bool checkComputedFlow(const Graph &G, const EdgeArray< int > &lowerBound, const EdgeArray< int > &upperBound, const EdgeArray< TCost > &cost, const NodeArray< int > &supply, const EdgeArray< int > &flow)
checks if a computed flow is a feasible solution to the given problem instance.
virtual ~MinCostFlowModule()
MinCostFlowModule()
Initializes a min-cost flow module.
static bool checkProblem(const Graph &G, const EdgeArray< int > &lowerBound, const EdgeArray< int > &upperBound, const NodeArray< int > &supply)
Checks if a given min-cost flow problem instance satisfies the preconditions.
virtual bool call(const Graph &G, const EdgeArray< int > &lowerBound, const EdgeArray< int > &upperBound, const EdgeArray< TCost > &cost, const NodeArray< int > &supply, EdgeArray< int > &flow)
Computes a min-cost flow in the directed graph G.
Dynamic arrays indexed with nodes.
Class for the representation of nodes.
Declaration of graph generators.
bool isConnected(const Graph &G)
Returns true iff G is connected.
void randomGraph(Graph &G, int n, int m)
Creates a random graph.
int randomNumber(int low, int high)
Returns random integer between low and high (including).
static MultilevelBuilder * getDoubleFactoredZeroAdjustedMerger()
The namespace for all OGDF objects.
Declaration of simple graph algorithms.