misc
authormarci
Mon, 26 Apr 2004 17:10:27 +0000
changeset 423fac60be3129b
parent 422 ede61a3d229b
child 424 f07ff78d4fad
misc
doc/Doxyfile
src/include/dimacs.h
src/work/marci/dimacs.h
     1.1 --- a/doc/Doxyfile	Mon Apr 26 17:05:22 2004 +0000
     1.2 +++ b/doc/Doxyfile	Mon Apr 26 17:10:27 2004 +0000
     1.3 @@ -399,11 +399,12 @@
     1.4                           ../src/include/dijkstra.h \
     1.5                           ../src/include/bin_heap.h \
     1.6                           ../src/include/fib_heap.h \
     1.7 +                         ../src/include/dimacs.h \
     1.8                           ../src/work/alpar/list_graph.h \
     1.9                           ../src/work/athos/xy/xy.h \
    1.10                           ../src/work/athos/minlengthpaths.h \
    1.11  			 ../src/work/marci/time_measure.h \
    1.12 -			 ../src/work/marci/graph_wrapper.h
    1.13 +			 ../src/work/marci/graph_wrapper.h	
    1.14                           
    1.15  
    1.16  # If the value of the INPUT tag contains directories, you can use the 
     2.1 --- /dev/null	Thu Jan 01 00:00:00 1970 +0000
     2.2 +++ b/src/include/dimacs.h	Mon Apr 26 17:10:27 2004 +0000
     2.3 @@ -0,0 +1,69 @@
     2.4 +// -*- c++ -*-
     2.5 +#ifndef HUGO_DIMACS_H
     2.6 +#define HUGO_DIMACS_H
     2.7 +
     2.8 +#include <iostream>
     2.9 +#include <string>
    2.10 +#include <vector>
    2.11 +
    2.12 +namespace hugo {
    2.13 +
    2.14 +  /// Dimacs flow files.
    2.15 +
    2.16 +  /// This function reads a flow instance from dimacs flow format.
    2.17 +  /// At the beginning \c g is destroyed by \c g.clear().
    2.18 +  /// If the data coming from \c is is a max flow innstance, then 
    2.19 +  /// \c s and \t will be respectively the source and target nodes 
    2.20 +  /// and \c capacity will contain the edge capacities.
    2.21 +  /// If the data is a shortest path problem then \c s will be the 
    2.22 +  /// source node and \capacity will contain the edge lengths.
    2.23 +  template<typename Graph, typename CapacityMap>
    2.24 +  void readDimacsMaxFlow(std::istream& is, Graph &g, typename Graph::Node &s, typename Graph::Node &t, CapacityMap& capacity) {
    2.25 +    g.clear();
    2.26 +    int cap;
    2.27 +    char d;
    2.28 +    std::string problem;
    2.29 +    char c;
    2.30 +    int i, j;
    2.31 +    std::string str;
    2.32 +    int n, m; 
    2.33 +    typename Graph::Edge e;
    2.34 +    std::vector<typename Graph::Node> nodes;
    2.35 +    while (is>>c) {
    2.36 +      switch (c) {
    2.37 +      case 'c': //comment
    2.38 +	getline(is, str);
    2.39 +	break;
    2.40 +      case 'p': //problem definition
    2.41 +	is >> problem >> n >> m;
    2.42 +	getline(is, str);
    2.43 +	nodes.resize(n+1);
    2.44 +	for (int k=1; k<=n; ++k) nodes[k]=g.addNode();
    2.45 +	break;
    2.46 +      case 'n': //node definition
    2.47 +	if (problem=="sp") { //shortest path problem
    2.48 +	  is >> i;
    2.49 +	  getline(is, str);
    2.50 +	  s=nodes[i];
    2.51 +	}
    2.52 +	if (problem=="max") { //max flow problem
    2.53 +	  is >> i >> d;
    2.54 +	  getline(is, str);
    2.55 +	  if (d=='s') s=nodes[i];
    2.56 +	  if (d=='t') t=nodes[i];
    2.57 +	}
    2.58 +	break;
    2.59 +      case 'a':
    2.60 +	is >> i >> j >> cap;
    2.61 +	getline(is, str);
    2.62 +	e=g.addEdge(nodes[i], nodes[j]);
    2.63 +	capacity.update();
    2.64 +	capacity.set(e, cap);
    2.65 +	break;
    2.66 +      }
    2.67 +    }
    2.68 +  }
    2.69 +  
    2.70 +} //namespace hugo
    2.71 +
    2.72 +#endif //HUGO_DIMACS_H
     3.1 --- a/src/work/marci/dimacs.h	Mon Apr 26 17:05:22 2004 +0000
     3.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     3.3 @@ -1,69 +0,0 @@
     3.4 -// -*- c++ -*-
     3.5 -#ifndef HUGO_DIMACS_H
     3.6 -#define HUGO_DIMACS_H
     3.7 -
     3.8 -#include <iostream>
     3.9 -#include <string>
    3.10 -#include <vector>
    3.11 -
    3.12 -namespace hugo {
    3.13 -
    3.14 -  /// Dimacs flow files.
    3.15 -
    3.16 -  /// This function reads a flow instance from dimacs flow format.
    3.17 -  /// At the beginning \c g is destroyed by \c g.clear().
    3.18 -  /// If the data coming from \c is is a max flow innstance, then 
    3.19 -  /// \c s and \t will be respectively the source and target nodes 
    3.20 -  /// and \c capacity will contain the edge capacities.
    3.21 -  /// If the data is a shortest path problem then \c s will be the 
    3.22 -  /// source node and \capacity will contain the edge lengths.
    3.23 -  template<typename Graph, typename CapacityMap>
    3.24 -  void readDimacsMaxFlow(std::istream& is, Graph &g, typename Graph::Node &s, typename Graph::Node &t, CapacityMap& capacity) {
    3.25 -    g.clear();
    3.26 -    int cap;
    3.27 -    char d;
    3.28 -    std::string problem;
    3.29 -    char c;
    3.30 -    int i, j;
    3.31 -    std::string str;
    3.32 -    int n, m; 
    3.33 -    typename Graph::Edge e;
    3.34 -    std::vector<typename Graph::Node> nodes;
    3.35 -    while (is>>c) {
    3.36 -      switch (c) {
    3.37 -      case 'c': //comment
    3.38 -	getline(is, str);
    3.39 -	break;
    3.40 -      case 'p': //problem definition
    3.41 -	is >> problem >> n >> m;
    3.42 -	getline(is, str);
    3.43 -	nodes.resize(n+1);
    3.44 -	for (int k=1; k<=n; ++k) nodes[k]=g.addNode();
    3.45 -	break;
    3.46 -      case 'n': //node definition
    3.47 -	if (problem=="sp") { //shortest path problem
    3.48 -	  is >> i;
    3.49 -	  getline(is, str);
    3.50 -	  s=nodes[i];
    3.51 -	}
    3.52 -	if (problem=="max") { //max flow problem
    3.53 -	  is >> i >> d;
    3.54 -	  getline(is, str);
    3.55 -	  if (d=='s') s=nodes[i];
    3.56 -	  if (d=='t') t=nodes[i];
    3.57 -	}
    3.58 -	break;
    3.59 -      case 'a':
    3.60 -	is >> i >> j >> cap;
    3.61 -	getline(is, str);
    3.62 -	e=g.addEdge(nodes[i], nodes[j]);
    3.63 -	capacity.update();
    3.64 -	capacity.set(e, cap);
    3.65 -	break;
    3.66 -      }
    3.67 -    }
    3.68 -  }
    3.69 -  
    3.70 -} //namespace hugo
    3.71 -
    3.72 -#endif //HUGO_DIMACS_H