Changeset 1560:01707a8a4ca6 in lemon-0.x
- Timestamp:
- 07/15/05 18:01:55 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2058
- Location:
- demo
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
demo/coloring.cc
r1435 r1560 6 6 #include <lemon/graph_to_eps.h> 7 7 8 #include <fstream> 9 #include <iostream> 10 11 8 12 using namespace std; 9 13 using namespace lemon; 10 14 11 int main() { 15 int 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 12 28 typedef UndirSmartGraph Graph; 13 29 typedef Graph::Node Node; … … 18 34 Graph graph; 19 35 20 UndirGraphReader<Graph> reader( std::cin, graph);36 UndirGraphReader<Graph> reader(is, graph); 21 37 Graph::NodeMap<xy<double> > coords(graph); 22 38 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 1 26 #ifdef HAVE_CONFIG_H 2 27 #include <config.h> … … 5 30 #include<lemon/graph_reader.h> 6 31 #include<lemon/list_graph.h> 32 33 #include <fstream> 34 #include <iostream> 7 35 8 36 … … 76 104 } 77 105 78 int main( )106 int main(int argc, char *argv[]) 79 107 { 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 80 120 ListGraph g; 81 121 ListGraph::Node s; … … 84 124 ListGraph::EdgeMap<double> cap(g); 85 125 86 GraphReader<ListGraph> reader( std::cin,g);126 GraphReader<ListGraph> reader(is,g); 87 127 reader.readNode("source",s).readNode("target",t) 88 128 .readEdgeMap("capacity",cap).run(); 89 129 90 // std::ifstream file("../test/preflow_");91 // readDimacs(file, g, cap, s, t);92 93 130 std::cout << "Max flow value = " << maxFlow(g,cap,s,t) << std::endl; 94 131 -
demo/sub_graph_adaptor_demo.cc
r1544 r1560 1 1 // -*- c++ -*- 2 2 3 // Use a DIMACS max flow file as stdin.3 // Use a DIMACS max flow file as input. 4 4 // sub_graph_adaptor_demo < dimacs_max_flow_file 5 5 // This program computes a maximum number of edge-disjoint shortest paths … … 22 22 using std::endl; 23 23 24 int main() 25 { 24 int 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 26 37 typedef SmartGraph Graph; 27 38 … … 36 47 LengthMap length(g); 37 48 38 readDimacs( std::cin, g, length, s, t);49 readDimacs(is, g, length, s, t); 39 50 40 51 cout << "edges with lengths (of form id, source--length->target): " << endl;
Note: See TracChangeset
for help on using the changeset viewer.