49template<
typename TCost>
80 return call(G, lowerBound, upperBound, cost, supply, flow, dual);
188template<
typename TCost>
193 node s = G.firstNode();
194 node t = G.lastNode();
196 for (
node v : G.nodes) {
201 for (
edge e : G.edges) {
208 for (
node v = G.firstNode(), vl = G.lastNode();
true; v = v->succ(), vl = vl->pred()) {
216 if (vl == v->succ()) {
222template<
typename TCost>
229 for (
edge e : G.edges) {
230 if (lowerBound[e] > upperBound[e]) {
236 for (
node v : G.nodes) {
243template<
typename TCost>
249 for (
edge e : G.edges) {
250 if (flow[e] < lowerBound[e] || upperBound[e] < flow[e]) {
254 value += flow[e] * cost[e];
257 for (
node v : G.nodes) {
260 for (
adjEntry adj : v->adjEntries) {
261 edge e = adj->theEdge();
273 if (
sum != supply[v]) {
Includes declaration of graph class.
Decralation of GraphElement and GraphList classes.
Basic declarations, included by all source files.
Class for adjacency list elements.
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.
Class for the representation of nodes.
RegisteredArray for edges of a graph, specialized for EdgeArray<edge>.
RegisteredArray for nodes, edges and adjEntries of a graph.
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).
The namespace for all OGDF objects.
Declaration of simple graph algorithms.