1 /* -*- mode: C++; indent-tabs-mode: nil; -*-
3 * This file is a part of LEMON, a generic C++ optimization library.
5 * Copyright (C) 2003-2008
6 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 * (Egervary Research Group on Combinatorial Optimization, EGRES).
9 * Permission to use, modify and distribute this software is granted
10 * provided that this copyright notice appears in all copies. For
11 * precise terms see the accompanying LICENSE file.
13 * This software is provided "AS IS" with no warranty of any kind,
14 * express or implied, and with no claim as to its suitability for any
21 ///\brief Demonstrating the usage of LEMON's General Flow algorithm
23 /// This demo program reads a general network circulation problem from the
24 /// file 'circulation-input.lgf', runs the preflow based algorithm for
25 /// finding a feasible solution and writes the output
26 /// to 'circulation-input.lgf'
28 /// \include circulation_demo.cc
32 #include "test_tools.h"
33 #include <lemon/list_graph.h>
34 #include <lemon/circulation.h>
35 #include <lemon/lgf_reader.h>
37 using namespace lemon;
53 " label lo_cap up_cap\n"
75 int main (int, char*[])
78 typedef ListDigraph Digraph;
79 typedef Digraph::Node Node;
80 typedef Digraph::NodeIt NodeIt;
81 typedef Digraph::Arc Arc;
82 typedef Digraph::ArcIt ArcIt;
83 typedef Digraph::ArcMap<int> ArcMap;
84 typedef Digraph::NodeMap<int> NodeMap;
85 typedef Digraph::NodeMap<double> DNodeMap;
95 std::istringstream input(test_lgf);
96 DigraphReader<Digraph>(g,input).
99 nodeMap("delta", delta).
100 arcMap("label", eid).
101 nodeMap("label", nid).
102 node("source",source).
106 Circulation<Digraph> gen(g,lo,up,delta);
108 check(ret,"A feasible solution should have been found.");
109 check(gen.checkFlow(), "The found flow is corrupt.");
115 check(!ret2,"A feasible solution should not have been found.");
116 check(gen.checkBarrier(), "The found barrier is corrupt.");