COIN-OR::LEMON - Graph Library

Changeset 1560:01707a8a4ca6 in lemon-0.x for demo/lp_maxflow_demo.cc


Ignore:
Timestamp:
07/15/05 18:01:55 (19 years ago)
Author:
athos
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2058
Message:

Some demo programs got some interface. Most progress with lp_maxflow_demo.cc, which also got documented.

File:
1 edited

Legend:

Unmodified
Added
Removed
  • demo/lp_maxflow_demo.cc

    r1518 r1560  
     1/* -*- C++ -*-
     2 * demo/lp_maxflow_demo.cc - Part of LEMON, a generic C++ optimization library
     3 *
     4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
     5 * (Egervary Research Group on Combinatorial Optimization, EGRES).
     6 *
     7 * Permission to use, modify and distribute this software is granted
     8 * provided that this copyright notice appears in all copies. For
     9 * precise terms see the accompanying LICENSE file.
     10 *
     11 * This software is provided "AS IS" with no warranty of any kind,
     12 * express or implied, and with no claim as to its suitability for any
     13 * purpose.
     14 *
     15 */
     16
     17///\ingroup demos
     18///\file
     19///\brief Max flow problem solved with an LP solver (demo).
     20///
     21///This demo program shows how to solve a maximum (or maximal) flow
     22///problem using the LEMON LP solver interface. We would like to lay
     23///the emphasis on the simplicity of the way one can formulate the LP
     24///constraints with LEMON that arise in graph theory.
     25
    126#ifdef HAVE_CONFIG_H
    227#include <config.h>
     
    530#include<lemon/graph_reader.h>
    631#include<lemon/list_graph.h>
     32
     33#include <fstream>
     34#include <iostream>
    735
    836
     
    76104}
    77105
    78 int main()
     106int main(int argc, char *argv[])
    79107{
     108  if(argc<2)
     109  {
     110      std::cerr << "USAGE: lp_maxflow_demo <input_file.lgf>" << std::endl;
     111      std::cerr << "The file 'input_file.lgf' has to contain a max flow instance in LEMON format (e.g. sample.lgf is such a file)." << std::endl;
     112      return 0;
     113  }
     114
     115
     116  //input stream to read the graph from
     117  std::ifstream is(argv[1]);
     118
     119
    80120  ListGraph g;
    81121  ListGraph::Node s;
     
    84124  ListGraph::EdgeMap<double> cap(g);
    85125 
    86   GraphReader<ListGraph> reader(std::cin,g);
     126  GraphReader<ListGraph> reader(is,g);
    87127  reader.readNode("source",s).readNode("target",t)
    88128    .readEdgeMap("capacity",cap).run();
    89129 
    90   // std::ifstream file("../test/preflow_");
    91 //   readDimacs(file, g, cap, s, t);
    92 
    93130  std::cout << "Max flow value = " << maxFlow(g,cap,s,t) << std::endl;
    94131
Note: See TracChangeset for help on using the changeset viewer.