COIN-OR::LEMON - Graph Library

Changeset 1560:01707a8a4ca6 in lemon-0.x


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.

Location:
demo
Files:
3 edited

Legend:

Unmodified
Added
Removed
  • demo/coloring.cc

    r1435 r1560  
    66#include <lemon/graph_to_eps.h>
    77
     8#include <fstream>
     9#include <iostream>
     10
     11
    812using namespace std;
    913using namespace lemon;
    1014
    11 int main() {
     15int main(int argc, char *argv[])
     16{
     17  if(argc<2)
     18  {
     19      std::cerr << "USAGE: coloring <input_file.lgf>" << std::endl;
     20      std::cerr << "The file 'input_file.lgf' has to contain a graph in LEMON format together with a nodemap called 'coords' to draw the graph (e.g. sample.lgf is not such a file)." << std::endl;
     21      return 0;
     22  }
     23
     24
     25  //input stream to read the graph from
     26  std::ifstream is(argv[1]);
     27
    1228  typedef UndirSmartGraph Graph;
    1329  typedef Graph::Node Node;
     
    1834  Graph graph;
    1935
    20   UndirGraphReader<Graph> reader(std::cin, graph);
     36  UndirGraphReader<Graph> reader(is, graph);
    2137  Graph::NodeMap<xy<double> > coords(graph);
    2238  reader.readNodeMap("coords", coords);
  • 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
  • demo/sub_graph_adaptor_demo.cc

    r1544 r1560  
    11// -*- c++ -*-
    22
    3 // Use a DIMACS max flow file as stdin.
     3// Use a DIMACS max flow file as input.
    44// sub_graph_adaptor_demo < dimacs_max_flow_file
    55// This program computes a maximum number of edge-disjoint shortest paths
     
    2222using std::endl;
    2323
    24 int main()
    25 {   
     24int main(int argc, char *argv[])
     25{
     26  if(argc<2)
     27  {
     28      std::cerr << "USAGE: sub_graph_adaptor_demo <input_file.dim>" << std::endl;
     29      std::cerr << "The file 'input_file.dim' has to contain a max flow instance in DIMACS format (e.g. sub_graph_adaptor_demo.dim is such a file)." << std::endl;
     30      return 0;
     31  }
     32
     33
     34  //input stream to read the graph from
     35  std::ifstream is(argv[1]);
     36
    2637  typedef SmartGraph Graph;
    2738
     
    3647  LengthMap length(g);
    3748
    38   readDimacs(std::cin, g, length, s, t);
     49  readDimacs(is, g, length, s, t);
    3950
    4051  cout << "edges with lengths (of form id, source--length->target): " << endl;
Note: See TracChangeset for help on using the changeset viewer.