/* -*- C++ -*- * * This file is a part of LEMON, a generic C++ optimization library * * Copyright (C) 2003-2008 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport * (Egervary Research Group on Combinatorial Optimization, EGRES). * * Permission to use, modify and distribute this software is granted * provided that this copyright notice appears in all copies. For * precise terms see the accompanying LICENSE file. * * This software is provided "AS IS" with no warranty of any kind, * express or implied, and with no claim as to its suitability for any * purpose. * */ #include <iostream> #include <lemon/list_graph.h> #include <lemon/circulation.h> #include <lemon/graph_reader.h> #include <lemon/graph_writer.h> using namespace lemon; int main (int, char*[]) { typedef ListGraph Graph; typedef Graph::Node Node; typedef Graph::NodeIt NodeIt; typedef Graph::Edge Edge; typedef Graph::EdgeIt EdgeIt; typedef Graph::EdgeMap<int> EdgeMap; typedef Graph::NodeMap<int> NodeMap; typedef Graph::NodeMap<double> DNodeMap; Graph g; EdgeMap lo(g); EdgeMap up(g); NodeMap delta(g); NodeMap nid(g); EdgeMap eid(g); DNodeMap cx(g); DNodeMap cy(g); GraphReader<Graph>("circulation-input.lgf", g). readEdgeMap("lo_cap", lo). readEdgeMap("up_cap", up). readNodeMap("delta", delta). readEdgeMap("label", eid). readNodeMap("label", nid). readNodeMap("coordinates_x", cx). readNodeMap("coordinates_y", cy). run(); Circulation<Graph> gen(g,lo,up,delta); bool ret=gen.run(); if(ret) { std::cout << "\nA feasible flow has been found.\n"; if(!gen.checkFlow()) std::cerr << "Oops!!!\n"; GraphWriter<Graph>("circulation-output.lgf", g). writeEdgeMap("lo_cap", lo). writeEdgeMap("up_cap", up). writeEdgeMap("flow", gen.flowMap()). writeNodeMap("delta", delta). writeEdgeMap("label", eid). writeNodeMap("label", nid). writeNodeMap("coordinates_x", cx). writeNodeMap("coordinates_y", cy). run(); } else { std::cout << "\nThere is no such a flow\n"; Graph::NodeMap<int> bar(g); gen.barrierMap(bar); if(!gen.checkBarrier()) std::cerr << "Dual Oops!!!\n"; GraphWriter<Graph>("circulation-output.lgf", g). writeEdgeMap("lo_cap", lo). writeEdgeMap("up_cap", up). writeNodeMap("barrier", bar). writeNodeMap("delta", delta). writeEdgeMap("label", eid). writeNodeMap("label", nid). writeNodeMap("coordinates_x", cx). writeNodeMap("coordinates_y", cy). run(); } std::cout << "The output is written to file 'circulation-output.lgf'\n\n"; }
#include <iostream>
#include <lemon/list_graph.h>
#include <lemon/circulation.h>
#include <lemon/graph_reader.h>
#include <lemon/graph_writer.h>