↑ Collapse diff ↑
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
/**
20 20
\dir demo
21 21
\brief A collection of demo applications.
22 22

	
23 23
This directory contains several simple demo applications, mainly
24 24
for educational purposes.
25 25
*/
26 26

	
27 27
/**
28 28
\dir doc
29 29
\brief Auxiliary (and the whole generated) documentation.
30 30

	
31 31
This directory contains some auxiliary pages and the whole generated
32 32
documentation.
33 33
*/
34 34

	
35 35
/**
36 36
\dir test
37 37
\brief Test programs.
38 38

	
39 39
This directory contains several test programs that check the consistency
40 40
of the code.
41 41
*/
42 42

	
43 43
/**
44 44
\dir tools
45 45
\brief Some useful executables.
46 46

	
47 47
This directory contains the sources of some useful complete executables.
48 48
*/
49 49

	
50 50
/**
51 51
\dir lemon
52 52
\brief Base include directory of LEMON.
53 53

	
54 54
This is the base directory of LEMON includes, so each include file must be
55 55
prefixed with this, e.g.
56 56
\code
57 57
#include<lemon/list_graph.h>
58 58
#include<lemon/dijkstra.h>
59 59
\endcode
60 60
*/
61 61

	
62 62
/**
63 63
\dir concepts
64 64
\brief Concept descriptors and checking classes.
65 65

	
66 66
This directory contains the concept descriptors and concept checking tools.
67 67
For more information see the \ref concept "Concepts" module.
68 68
*/
69 69

	
70 70
/**
71 71
\dir bits
72 72
\brief Auxiliary tools for implementation.
73 73

	
74 74
This directory contains some auxiliary classes for implementing graphs, 
75 75
maps and some other classes.
76 76
As a user you typically don't have to deal with these files.
77 77
*/
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
/**
20 20
@defgroup datas Data Structures
21 21
This group describes the several data structures implemented in LEMON.
22 22
*/
23 23

	
24 24
/**
25 25
@defgroup graphs Graph Structures
26 26
@ingroup datas
27 27
\brief Graph structures implemented in LEMON.
28 28

	
29 29
The implementation of combinatorial algorithms heavily relies on
30 30
efficient graph implementations. LEMON offers data structures which are
31 31
planned to be easily used in an experimental phase of implementation studies,
32 32
and thereafter the program code can be made efficient by small modifications.
33 33

	
34 34
The most efficient implementation of diverse applications require the
35 35
usage of different physical graph implementations. These differences
36 36
appear in the size of graph we require to handle, memory or time usage
37 37
limitations or in the set of operations through which the graph can be
38 38
accessed.  LEMON provides several physical graph structures to meet
39 39
the diverging requirements of the possible users.  In order to save on
40 40
running time or on memory usage, some structures may fail to provide
41 41
some graph features like arc/edge or node deletion.
42 42

	
43 43
You are free to use the graph structure that fit your requirements
44 44
the best, most graph algorithms and auxiliary data structures can be used
45 45
with any graph structure.
46 46

	
47 47
<b>See also:</b> \ref graph_concepts "Graph Structure Concepts".
48 48
*/
49 49

	
50 50
/**
51 51
@defgroup maps Maps
52 52
@ingroup datas
53 53
\brief Map structures implemented in LEMON.
54 54

	
55 55
This group describes the map structures implemented in LEMON.
56 56

	
57 57
LEMON provides several special purpose maps and map adaptors that e.g. combine
58 58
new maps from existing ones.
59 59

	
60 60
<b>See also:</b> \ref map_concepts "Map Concepts".
61 61
*/
62 62

	
63 63
/**
64 64
@defgroup graph_maps Graph Maps
65 65
@ingroup maps
66 66
\brief Special graph-related maps.
67 67

	
68 68
This group describes maps that are specifically designed to assign
69 69
values to the nodes and arcs of graphs.
70 70
*/
71 71

	
72 72
/**
73 73
\defgroup map_adaptors Map Adaptors
74 74
\ingroup maps
75 75
\brief Tools to create new maps from existing ones
76 76

	
77 77
This group describes map adaptors that are used to create "implicit"
78 78
maps from other maps.
79 79

	
80 80
Most of them are \ref lemon::concepts::ReadMap "read-only maps".
81 81
They can make arithmetic and logical operations between one or two maps
82 82
(negation, shifting, addition, multiplication, logical 'and', 'or',
83 83
'not' etc.) or e.g. convert a map to another one of different Value type.
84 84

	
85 85
The typical usage of this classes is passing implicit maps to
86 86
algorithms.  If a function type algorithm is called then the function
87 87
type map adaptors can be used comfortable. For example let's see the
88 88
usage of map adaptors with the \c graphToEps() function.
89 89
\code
90 90
  Color nodeColor(int deg) {
91 91
    if (deg >= 2) {
92 92
      return Color(0.5, 0.0, 0.5);
93 93
    } else if (deg == 1) {
94 94
      return Color(1.0, 0.5, 1.0);
95 95
    } else {
96 96
      return Color(0.0, 0.0, 0.0);
97 97
    }
98 98
  }
99 99

	
100 100
  Digraph::NodeMap<int> degree_map(graph);
101 101

	
102 102
  graphToEps(graph, "graph.eps")
103 103
    .coords(coords).scaleToA4().undirected()
104 104
    .nodeColors(composeMap(functorToMap(nodeColor), degree_map))
105 105
    .run();
106 106
\endcode
107 107
The \c functorToMap() function makes an \c int to \c Color map from the
108 108
\c nodeColor() function. The \c composeMap() compose the \c degree_map
109 109
and the previously created map. The composed map is a proper function to
110 110
get the color of each node.
111 111

	
112 112
The usage with class type algorithms is little bit harder. In this
113 113
case the function type map adaptors can not be used, because the
114 114
function map adaptors give back temporary objects.
115 115
\code
116 116
  Digraph graph;
117 117

	
118 118
  typedef Digraph::ArcMap<double> DoubleArcMap;
119 119
  DoubleArcMap length(graph);
120 120
  DoubleArcMap speed(graph);
121 121

	
122 122
  typedef DivMap<DoubleArcMap, DoubleArcMap> TimeMap;
123 123
  TimeMap time(length, speed);
124 124

	
125 125
  Dijkstra<Digraph, TimeMap> dijkstra(graph, time);
126 126
  dijkstra.run(source, target);
127 127
\endcode
128 128
We have a length map and a maximum speed map on the arcs of a digraph.
129 129
The minimum time to pass the arc can be calculated as the division of
130 130
the two maps which can be done implicitly with the \c DivMap template
131 131
class. We use the implicit minimum time map as the length map of the
132 132
\c Dijkstra algorithm.
133 133
*/
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
namespace lemon {
20 20
/*!
21 21

	
22 22

	
23 23

	
24 24
\page lgf-format LEMON Graph Format (LGF)
25 25

	
26 26
The \e LGF is a <em>column oriented</em>
27 27
file format for storing graphs and associated data like
28 28
node and edge maps.
29 29

	
30 30
Each line with \c '#' first non-whitespace
31 31
character is considered as a comment line.
32 32

	
33 33
Otherwise the file consists of sections starting with
34 34
a header line. The header lines starts with an \c '@' character followed by the
35 35
type of section. The standard section types are \c \@nodes, \c
36 36
\@arcs and \c \@edges
37 37
and \@attributes. Each header line may also have an optional
38 38
\e name, which can be use to distinguish the sections of the same
39 39
type.
40 40

	
41 41
The standard sections are column oriented, each line consists of
42 42
<em>token</em>s separated by whitespaces. A token can be \e plain or
43 43
\e quoted. A plain token is just a sequence of non-whitespace characters,
44 44
while a quoted token is a
45 45
character sequence surrounded by double quotes, and it can also
46 46
contain whitespaces and escape sequences.
47 47

	
48 48
The \c \@nodes section describes a set of nodes and associated
49 49
maps. The first is a header line, its columns are the names of the
50 50
maps appearing in the following lines.
51 51
One of the maps must be called \c
52 52
"label", which plays special role in the file.
53 53
The following
54 54
non-empty lines until the next section describes nodes of the
55 55
graph. Each line contains the values of the node maps
56 56
associated to the current node.
57 57

	
58 58
\code
59 59
 @nodes
60 60
 label  coordinates  size    title
61 61
 1      (10,20)      10      "First node"
62 62
 2      (80,80)      8       "Second node"
63 63
 3      (40,10)      10      "Third node"
64 64
\endcode
65 65

	
66 66
The \c \@arcs section is very similar to the \c \@nodes section, it
67 67
again starts with a header line describing the names of the maps, but
68 68
the \c "label" map is not obligatory here. The following lines
69 69
describe the arcs. The first two tokens of each line are the source
70 70
and the target node of the arc, respectively, then come the map
71 71
values. The source and target tokens must be node labels.
72 72

	
73 73
\code
74 74
 @arcs
75 75
         capacity
76 76
 1   2   16
77 77
 1   3   12
78 78
 2   3   18
79 79
\endcode
80 80

	
81 81
If there is no map in the \c \@arcs section at all, then it must be
82 82
indicated by a sole '-' sign in the first line.
83 83

	
84 84
\code
85 85
 @arcs
86 86
         -
87 87
 1   2
88 88
 1   3
89 89
 2   3
90 90
\endcode
91 91

	
92 92
The \c \@edges is just a synonym of \c \@arcs. The \@arcs section can
93 93
also store the edge set of an undirected graph. In such case there is
94 94
a conventional method for store arc maps in the file, if two columns
95 95
have the same caption with \c '+' and \c '-' prefix, then these columns
96 96
can be regarded as the values of an arc map.
97 97

	
98 98
The \c \@attributes section contains key-value pairs, each line
99 99
consists of two tokens, an attribute name, and then an attribute
100 100
value. The value of the attribute could be also a label value of a
101 101
node or an edge, or even an edge label prefixed with \c '+' or \c '-',
102 102
which regards to the forward or backward directed arc of the
103 103
corresponding edge.
104 104

	
105 105
\code
106 106
 @attributes
107 107
 source 1
108 108
 target 3
109 109
 caption "LEMON test digraph"
110 110
\endcode
111 111

	
112 112
The \e LGF can contain extra sections, but there is no restriction on
113 113
the format of such sections.
114 114

	
115 115
*/
116 116
}
117 117

	
118 118
//  LocalWords:  whitespace whitespaces
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
///\file
20 20
///\brief Some basic non-inline functions and static global data.
21 21

	
22 22
#include<lemon/tolerance.h>
23 23
#include<lemon/core.h>
24 24
namespace lemon {
25 25

	
26 26
  float Tolerance<float>::def_epsilon = static_cast<float>(1e-4);
27 27
  double Tolerance<double>::def_epsilon = 1e-10;
28 28
  long double Tolerance<long double>::def_epsilon = 1e-14;
29 29

	
30 30
#ifndef LEMON_ONLY_TEMPLATES
31 31
  const Invalid INVALID = Invalid();
32 32
#endif
33 33

	
34 34
} //namespace lemon
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_BITS_DEFAULT_MAP_H
20 20
#define LEMON_BITS_DEFAULT_MAP_H
21 21

	
22 22
#include <lemon/config.h>
23 23
#include <lemon/bits/array_map.h>
24 24
#include <lemon/bits/vector_map.h>
25 25
//#include <lemon/bits/debug_map.h>
26 26

	
27 27
//\ingroup graphbits
28 28
//\file
29 29
//\brief Graph maps that construct and destruct their elements dynamically.
30 30

	
31 31
namespace lemon {
32 32

	
33 33

	
34 34
  //#ifndef LEMON_USE_DEBUG_MAP
35 35

	
36 36
  template <typename _Graph, typename _Item, typename _Value>
37 37
  struct DefaultMapSelector {
38 38
    typedef ArrayMap<_Graph, _Item, _Value> Map;
39 39
  };
40 40

	
41 41
  // bool
42 42
  template <typename _Graph, typename _Item>
43 43
  struct DefaultMapSelector<_Graph, _Item, bool> {
44 44
    typedef VectorMap<_Graph, _Item, bool> Map;
45 45
  };
46 46

	
47 47
  // char
48 48
  template <typename _Graph, typename _Item>
49 49
  struct DefaultMapSelector<_Graph, _Item, char> {
50 50
    typedef VectorMap<_Graph, _Item, char> Map;
51 51
  };
52 52

	
53 53
  template <typename _Graph, typename _Item>
54 54
  struct DefaultMapSelector<_Graph, _Item, signed char> {
55 55
    typedef VectorMap<_Graph, _Item, signed char> Map;
56 56
  };
57 57

	
58 58
  template <typename _Graph, typename _Item>
59 59
  struct DefaultMapSelector<_Graph, _Item, unsigned char> {
60 60
    typedef VectorMap<_Graph, _Item, unsigned char> Map;
61 61
  };
62 62

	
63 63

	
64 64
  // int
65 65
  template <typename _Graph, typename _Item>
66 66
  struct DefaultMapSelector<_Graph, _Item, signed int> {
67 67
    typedef VectorMap<_Graph, _Item, signed int> Map;
68 68
  };
69 69

	
70 70
  template <typename _Graph, typename _Item>
71 71
  struct DefaultMapSelector<_Graph, _Item, unsigned int> {
72 72
    typedef VectorMap<_Graph, _Item, unsigned int> Map;
73 73
  };
74 74

	
75 75

	
76 76
  // short
77 77
  template <typename _Graph, typename _Item>
78 78
  struct DefaultMapSelector<_Graph, _Item, signed short> {
79 79
    typedef VectorMap<_Graph, _Item, signed short> Map;
80 80
  };
81 81

	
82 82
  template <typename _Graph, typename _Item>
83 83
  struct DefaultMapSelector<_Graph, _Item, unsigned short> {
84 84
    typedef VectorMap<_Graph, _Item, unsigned short> Map;
85 85
  };
86 86

	
87 87

	
88 88
  // long
89 89
  template <typename _Graph, typename _Item>
90 90
  struct DefaultMapSelector<_Graph, _Item, signed long> {
91 91
    typedef VectorMap<_Graph, _Item, signed long> Map;
92 92
  };
93 93

	
94 94
  template <typename _Graph, typename _Item>
95 95
  struct DefaultMapSelector<_Graph, _Item, unsigned long> {
96 96
    typedef VectorMap<_Graph, _Item, unsigned long> Map;
97 97
  };
98 98

	
99 99

	
100 100
#if defined LEMON_HAVE_LONG_LONG
101 101

	
102 102
  // long long
103 103
  template <typename _Graph, typename _Item>
104 104
  struct DefaultMapSelector<_Graph, _Item, signed long long> {
105 105
    typedef VectorMap<_Graph, _Item, signed long long> Map;
106 106
  };
107 107

	
108 108
  template <typename _Graph, typename _Item>
109 109
  struct DefaultMapSelector<_Graph, _Item, unsigned long long> {
110 110
    typedef VectorMap<_Graph, _Item, unsigned long long> Map;
111 111
  };
112 112

	
113 113
#endif
114 114

	
115 115

	
116 116
  // float
117 117
  template <typename _Graph, typename _Item>
118 118
  struct DefaultMapSelector<_Graph, _Item, float> {
119 119
    typedef VectorMap<_Graph, _Item, float> Map;
120 120
  };
121 121

	
122 122

	
123 123
  // double
124 124
  template <typename _Graph, typename _Item>
125 125
  struct DefaultMapSelector<_Graph, _Item, double> {
126 126
    typedef VectorMap<_Graph, _Item,  double> Map;
127 127
  };
128 128

	
129 129

	
130 130
  // long double
131 131
  template <typename _Graph, typename _Item>
132 132
  struct DefaultMapSelector<_Graph, _Item, long double> {
133 133
    typedef VectorMap<_Graph, _Item, long double> Map;
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_BITS_MAP_EXTENDER_H
20 20
#define LEMON_BITS_MAP_EXTENDER_H
21 21

	
22 22
#include <iterator>
23 23

	
24 24
#include <lemon/bits/traits.h>
25 25

	
26 26
#include <lemon/concept_check.h>
27 27
#include <lemon/concepts/maps.h>
28 28

	
29 29
//\file
30 30
//\brief Extenders for iterable maps.
31 31

	
32 32
namespace lemon {
33 33

	
34 34
  // \ingroup graphbits
35 35
  //
36 36
  // \brief Extender for maps
37 37
  template <typename _Map>
38 38
  class MapExtender : public _Map {
39 39
  public:
40 40

	
41 41
    typedef _Map Parent;
42 42
    typedef MapExtender Map;
43 43

	
44 44

	
45 45
    typedef typename Parent::Graph Graph;
46 46
    typedef typename Parent::Key Item;
47 47

	
48 48
    typedef typename Parent::Key Key;
49 49
    typedef typename Parent::Value Value;
50 50

	
51 51
    class MapIt;
52 52
    class ConstMapIt;
53 53

	
54 54
    friend class MapIt;
55 55
    friend class ConstMapIt;
56 56

	
57 57
  public:
58 58

	
59 59
    MapExtender(const Graph& graph)
60 60
      : Parent(graph) {}
61 61

	
62 62
    MapExtender(const Graph& graph, const Value& value)
63 63
      : Parent(graph, value) {}
64 64

	
65 65
  private:
66 66
    MapExtender& operator=(const MapExtender& cmap) {
67 67
      return operator=<MapExtender>(cmap);
68 68
    }
69 69

	
70 70
    template <typename CMap>
71 71
    MapExtender& operator=(const CMap& cmap) {
72 72
      Parent::operator=(cmap);
73 73
      return *this;
74 74
    }
75 75

	
76 76
  public:
77 77
    class MapIt : public Item {
78 78
    public:
79 79

	
80 80
      typedef Item Parent;
81 81
      typedef typename Map::Value Value;
82 82

	
83 83
      MapIt() : map(NULL) {}
84 84

	
85 85
      MapIt(Invalid i) : Parent(i), map(NULL) {}
86 86

	
87 87
      explicit MapIt(Map& _map) : map(&_map) {
88 88
        map->notifier()->first(*this);
89 89
      }
90 90

	
91 91
      MapIt(const Map& _map, const Item& item)
92 92
        : Parent(item), map(&_map) {}
93 93

	
94 94
      MapIt& operator++() {
95 95
        map->notifier()->next(*this);
96 96
        return *this;
97 97
      }
98 98

	
99 99
      typename MapTraits<Map>::ConstReturnValue operator*() const {
100 100
        return (*map)[*this];
101 101
      }
102 102

	
103 103
      typename MapTraits<Map>::ReturnValue operator*() {
104 104
        return (*map)[*this];
105 105
      }
106 106

	
107 107
      void set(const Value& value) {
108 108
        map->set(*this, value);
109 109
      }
110 110

	
111 111
    protected:
112 112
      Map* map;
113 113

	
114 114
    };
115 115

	
116 116
    class ConstMapIt : public Item {
117 117
    public:
118 118

	
119 119
      typedef Item Parent;
120 120

	
121 121
      typedef typename Map::Value Value;
122 122

	
123 123
      ConstMapIt() : map(NULL) {}
124 124

	
125 125
      ConstMapIt(Invalid i) : Parent(i), map(NULL) {}
126 126

	
127 127
      explicit ConstMapIt(Map& _map) : map(&_map) {
128 128
        map->notifier()->first(*this);
129 129
      }
130 130

	
131 131
      ConstMapIt(const Map& _map, const Item& item)
132 132
        : Parent(item), map(_map) {}
133 133

	
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_BITS_PRED_MAP_PATH_H
20 20
#define LEMON_BITS_PRED_MAP_PATH_H
21 21

	
22 22
namespace lemon {
23 23

	
24 24
  template <typename _Digraph, typename _PredMap>
25 25
  class PredMapPath {
26 26
  public:
27 27
    typedef True RevPathTag;
28 28

	
29 29
    typedef _Digraph Digraph;
30 30
    typedef typename Digraph::Arc Arc;
31 31
    typedef _PredMap PredMap;
32 32

	
33 33
    PredMapPath(const Digraph& _digraph, const PredMap& _predMap,
34 34
                typename Digraph::Node _target)
35 35
      : digraph(_digraph), predMap(_predMap), target(_target) {}
36 36

	
37 37
    int length() const {
38 38
      int len = 0;
39 39
      typename Digraph::Node node = target;
40 40
      typename Digraph::Arc arc;
41 41
      while ((arc = predMap[node]) != INVALID) {
42 42
        node = digraph.source(arc);
43 43
        ++len;
44 44
      }
45 45
      return len;
46 46
    }
47 47

	
48 48
    bool empty() const {
49 49
      return predMap[target] == INVALID;
50 50
    }
51 51

	
52 52
    class RevArcIt {
53 53
    public:
54 54
      RevArcIt() {}
55 55
      RevArcIt(Invalid) : path(0), current(INVALID) {}
56 56
      RevArcIt(const PredMapPath& _path)
57 57
        : path(&_path), current(_path.target) {
58 58
        if (path->predMap[current] == INVALID) current = INVALID;
59 59
      }
60 60

	
61 61
      operator const typename Digraph::Arc() const {
62 62
        return path->predMap[current];
63 63
      }
64 64

	
65 65
      RevArcIt& operator++() {
66 66
        current = path->digraph.source(path->predMap[current]);
67 67
        if (path->predMap[current] == INVALID) current = INVALID;
68 68
        return *this;
69 69
      }
70 70

	
71 71
      bool operator==(const RevArcIt& e) const {
72 72
        return current == e.current;
73 73
      }
74 74

	
75 75
      bool operator!=(const RevArcIt& e) const {
76 76
        return current != e.current;
77 77
      }
78 78

	
79 79
      bool operator<(const RevArcIt& e) const {
80 80
        return current < e.current;
81 81
      }
82 82

	
83 83
    private:
84 84
      const PredMapPath* path;
85 85
      typename Digraph::Node current;
86 86
    };
87 87

	
88 88
  private:
89 89
    const Digraph& digraph;
90 90
    const PredMap& predMap;
91 91
    typename Digraph::Node target;
92 92
  };
93 93

	
94 94

	
95 95
  template <typename _Digraph, typename _PredMatrixMap>
96 96
  class PredMatrixMapPath {
97 97
  public:
98 98
    typedef True RevPathTag;
99 99

	
100 100
    typedef _Digraph Digraph;
101 101
    typedef typename Digraph::Arc Arc;
102 102
    typedef _PredMatrixMap PredMatrixMap;
103 103

	
104 104
    PredMatrixMapPath(const Digraph& _digraph,
105 105
                      const PredMatrixMap& _predMatrixMap,
106 106
                      typename Digraph::Node _source,
107 107
                      typename Digraph::Node _target)
108 108
      : digraph(_digraph), predMatrixMap(_predMatrixMap),
109 109
        source(_source), target(_target) {}
110 110

	
111 111
    int length() const {
112 112
      int len = 0;
113 113
      typename Digraph::Node node = target;
114 114
      typename Digraph::Arc arc;
115 115
      while ((arc = predMatrixMap(source, node)) != INVALID) {
116 116
        node = digraph.source(arc);
117 117
        ++len;
118 118
      }
119 119
      return len;
120 120
    }
121 121

	
122 122
    bool empty() const {
123 123
      return predMatrixMap(source, target) == INVALID;
124 124
    }
125 125

	
126 126
    class RevArcIt {
127 127
    public:
128 128
      RevArcIt() {}
129 129
      RevArcIt(Invalid) : path(0), current(INVALID) {}
130 130
      RevArcIt(const PredMatrixMapPath& _path)
131 131
        : path(&_path), current(_path.target) {
132 132
        if (path->predMatrixMap(path->source, current) == INVALID)
133 133
          current = INVALID;
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2009
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
///\file
20 20
///\brief Some basic non-inline functions and static global data.
21 21

	
22 22
#include<lemon/bits/windows.h>
23 23

	
24 24
#ifdef WIN32
25 25
#ifndef WIN32_LEAN_AND_MEAN
26 26
#define WIN32_LEAN_AND_MEAN
27 27
#endif
28 28
#ifndef NOMINMAX
29 29
#define NOMINMAX
30 30
#endif
31 31
#ifdef UNICODE
32 32
#undef UNICODE
33 33
#endif
34 34
#include <windows.h>
35 35
#ifdef LOCALE_INVARIANT
36 36
#define MY_LOCALE LOCALE_INVARIANT
37 37
#else
38 38
#define MY_LOCALE LOCALE_NEUTRAL
39 39
#endif
40 40
#else
41 41
#include <unistd.h>
42 42
#include <ctime>
43 43
#include <sys/times.h>
44 44
#include <sys/time.h>
45 45
#endif
46 46

	
47 47
#include <cmath>
48 48
#include <sstream>
49 49

	
50 50
namespace lemon {
51 51
  namespace bits {
52 52
    void getWinProcTimes(double &rtime,
53 53
                         double &utime, double &stime,
54 54
                         double &cutime, double &cstime)
55 55
    {
56 56
#ifdef WIN32
57 57
      static const double ch = 4294967296.0e-7;
58 58
      static const double cl = 1.0e-7;
59 59

	
60 60
      FILETIME system;
61 61
      GetSystemTimeAsFileTime(&system);
62 62
      rtime = ch * system.dwHighDateTime + cl * system.dwLowDateTime;
63 63

	
64 64
      FILETIME create, exit, kernel, user;
65 65
      if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
66 66
        utime = ch * user.dwHighDateTime + cl * user.dwLowDateTime;
67 67
        stime = ch * kernel.dwHighDateTime + cl * kernel.dwLowDateTime;
68 68
        cutime = 0;
69 69
        cstime = 0;
70 70
      } else {
71 71
        rtime = 0;
72 72
        utime = 0;
73 73
        stime = 0;
74 74
        cutime = 0;
75 75
        cstime = 0;
76 76
      }
77 77
#else
78 78
      timeval tv;
79 79
      gettimeofday(&tv, 0);
80 80
      rtime=tv.tv_sec+double(tv.tv_usec)/1e6;
81 81

	
82 82
      tms ts;
83 83
      double tck=sysconf(_SC_CLK_TCK);
84 84
      times(&ts);
85 85
      utime=ts.tms_utime/tck;
86 86
      stime=ts.tms_stime/tck;
87 87
      cutime=ts.tms_cutime/tck;
88 88
      cstime=ts.tms_cstime/tck;
89 89
#endif
90 90
    }
91 91

	
92 92
    std::string getWinFormattedDate()
93 93
    {
94 94
      std::ostringstream os;
95 95
#ifdef WIN32
96 96
      SYSTEMTIME time;
97 97
      GetSystemTime(&time);
98 98
      char buf1[11], buf2[9], buf3[5];
99 99
	  if (GetDateFormat(MY_LOCALE, 0, &time,
100 100
                        ("ddd MMM dd"), buf1, 11) &&
101 101
          GetTimeFormat(MY_LOCALE, 0, &time,
102 102
                        ("HH':'mm':'ss"), buf2, 9) &&
103 103
          GetDateFormat(MY_LOCALE, 0, &time,
104 104
                        ("yyyy"), buf3, 5)) {
105 105
        os << buf1 << ' ' << buf2 << ' ' << buf3;
106 106
      }
107 107
      else os << "unknown";
108 108
#else
109 109
      timeval tv;
110 110
      gettimeofday(&tv, 0);
111 111

	
112 112
      char cbuf[26];
113 113
      ctime_r(&tv.tv_sec,cbuf);
114 114
      os << cbuf;
115 115
#endif
116 116
      return os.str();
117 117
    }
118 118

	
119 119
    int getWinRndSeed()
120 120
    {
121 121
#ifdef WIN32
122 122
      FILETIME time;
123 123
      GetSystemTimeAsFileTime(&time);
124 124
      return GetCurrentProcessId() + time.dwHighDateTime + time.dwLowDateTime;
125 125
#else
126 126
      timeval tv;
127 127
      gettimeofday(&tv, 0);
128 128
      return getpid() + tv.tv_sec + tv.tv_usec;
129 129
#endif
130 130
    }
131 131
  }
132 132
}
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_CORE_H
20 20
#define LEMON_CORE_H
21 21

	
22 22
#include <vector>
23 23
#include <algorithm>
24 24

	
25 25
#include <lemon/config.h>
26 26
#include <lemon/bits/enable_if.h>
27 27
#include <lemon/bits/traits.h>
28 28
#include <lemon/assert.h>
29 29

	
30 30
///\file
31 31
///\brief LEMON core utilities.
32 32
///
33 33
///This header file contains core utilities for LEMON.
34 34
///It is automatically included by all graph types, therefore it usually
35 35
///do not have to be included directly.
36 36

	
37 37
namespace lemon {
38 38

	
39 39
  /// \brief Dummy type to make it easier to create invalid iterators.
40 40
  ///
41 41
  /// Dummy type to make it easier to create invalid iterators.
42 42
  /// See \ref INVALID for the usage.
43 43
  struct Invalid {
44 44
  public:
45 45
    bool operator==(Invalid) { return true;  }
46 46
    bool operator!=(Invalid) { return false; }
47 47
    bool operator< (Invalid) { return false; }
48 48
  };
49 49

	
50 50
  /// \brief Invalid iterators.
51 51
  ///
52 52
  /// \ref Invalid is a global type that converts to each iterator
53 53
  /// in such a way that the value of the target iterator will be invalid.
54 54
#ifdef LEMON_ONLY_TEMPLATES
55 55
  const Invalid INVALID = Invalid();
56 56
#else
57 57
  extern const Invalid INVALID;
58 58
#endif
59 59

	
60 60
  /// \addtogroup gutils
61 61
  /// @{
62 62

	
63 63
  ///Create convenience typedefs for the digraph types and iterators
64 64

	
65 65
  ///This \c \#define creates convenient type definitions for the following
66 66
  ///types of \c Digraph: \c Node,  \c NodeIt, \c Arc, \c ArcIt, \c InArcIt,
67 67
  ///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap,
68 68
  ///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap.
69 69
  ///
70 70
  ///\note If the graph type is a dependent type, ie. the graph type depend
71 71
  ///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS()
72 72
  ///macro.
73 73
#define DIGRAPH_TYPEDEFS(Digraph)                                       \
74 74
  typedef Digraph::Node Node;                                           \
75 75
  typedef Digraph::NodeIt NodeIt;                                       \
76 76
  typedef Digraph::Arc Arc;                                             \
77 77
  typedef Digraph::ArcIt ArcIt;                                         \
78 78
  typedef Digraph::InArcIt InArcIt;                                     \
79 79
  typedef Digraph::OutArcIt OutArcIt;                                   \
80 80
  typedef Digraph::NodeMap<bool> BoolNodeMap;                           \
81 81
  typedef Digraph::NodeMap<int> IntNodeMap;                             \
82 82
  typedef Digraph::NodeMap<double> DoubleNodeMap;                       \
83 83
  typedef Digraph::ArcMap<bool> BoolArcMap;                             \
84 84
  typedef Digraph::ArcMap<int> IntArcMap;                               \
85 85
  typedef Digraph::ArcMap<double> DoubleArcMap
86 86

	
87 87
  ///Create convenience typedefs for the digraph types and iterators
88 88

	
89 89
  ///\see DIGRAPH_TYPEDEFS
90 90
  ///
91 91
  ///\note Use this macro, if the graph type is a dependent type,
92 92
  ///ie. the graph type depend on a template parameter.
93 93
#define TEMPLATE_DIGRAPH_TYPEDEFS(Digraph)                              \
94 94
  typedef typename Digraph::Node Node;                                  \
95 95
  typedef typename Digraph::NodeIt NodeIt;                              \
96 96
  typedef typename Digraph::Arc Arc;                                    \
97 97
  typedef typename Digraph::ArcIt ArcIt;                                \
98 98
  typedef typename Digraph::InArcIt InArcIt;                            \
99 99
  typedef typename Digraph::OutArcIt OutArcIt;                          \
100 100
  typedef typename Digraph::template NodeMap<bool> BoolNodeMap;         \
101 101
  typedef typename Digraph::template NodeMap<int> IntNodeMap;           \
102 102
  typedef typename Digraph::template NodeMap<double> DoubleNodeMap;     \
103 103
  typedef typename Digraph::template ArcMap<bool> BoolArcMap;           \
104 104
  typedef typename Digraph::template ArcMap<int> IntArcMap;             \
105 105
  typedef typename Digraph::template ArcMap<double> DoubleArcMap
106 106

	
107 107
  ///Create convenience typedefs for the graph types and iterators
108 108

	
109 109
  ///This \c \#define creates the same convenient type definitions as defined
110 110
  ///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates
111 111
  ///\c Edge, \c EdgeIt, \c IncEdgeIt, \c BoolEdgeMap, \c IntEdgeMap,
112 112
  ///\c DoubleEdgeMap.
113 113
  ///
114 114
  ///\note If the graph type is a dependent type, ie. the graph type depend
115 115
  ///on a template parameter, then use \c TEMPLATE_GRAPH_TYPEDEFS()
116 116
  ///macro.
117 117
#define GRAPH_TYPEDEFS(Graph)                                           \
118 118
  DIGRAPH_TYPEDEFS(Graph);                                              \
119 119
  typedef Graph::Edge Edge;                                             \
120 120
  typedef Graph::EdgeIt EdgeIt;                                         \
121 121
  typedef Graph::IncEdgeIt IncEdgeIt;                                   \
122 122
  typedef Graph::EdgeMap<bool> BoolEdgeMap;                             \
123 123
  typedef Graph::EdgeMap<int> IntEdgeMap;                               \
124 124
  typedef Graph::EdgeMap<double> DoubleEdgeMap
125 125

	
126 126
  ///Create convenience typedefs for the graph types and iterators
127 127

	
128 128
  ///\see GRAPH_TYPEDEFS
129 129
  ///
130 130
  ///\note Use this macro, if the graph type is a dependent type,
131 131
  ///ie. the graph type depend on a template parameter.
132 132
#define TEMPLATE_GRAPH_TYPEDEFS(Graph)                                  \
133 133
  TEMPLATE_DIGRAPH_TYPEDEFS(Graph);                                     \
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_DFS_H
20 20
#define LEMON_DFS_H
21 21

	
22 22
///\ingroup search
23 23
///\file
24 24
///\brief DFS algorithm.
25 25

	
26 26
#include <lemon/list_graph.h>
27 27
#include <lemon/bits/path_dump.h>
28 28
#include <lemon/core.h>
29 29
#include <lemon/error.h>
30 30
#include <lemon/maps.h>
31 31
#include <lemon/path.h>
32 32

	
33 33
namespace lemon {
34 34

	
35 35
  ///Default traits class of Dfs class.
36 36

	
37 37
  ///Default traits class of Dfs class.
38 38
  ///\tparam GR Digraph type.
39 39
  template<class GR>
40 40
  struct DfsDefaultTraits
41 41
  {
42 42
    ///The type of the digraph the algorithm runs on.
43 43
    typedef GR Digraph;
44 44

	
45 45
    ///\brief The type of the map that stores the predecessor
46 46
    ///arcs of the %DFS paths.
47 47
    ///
48 48
    ///The type of the map that stores the predecessor
49 49
    ///arcs of the %DFS paths.
50 50
    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
51 51
    typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap;
52 52
    ///Instantiates a PredMap.
53 53

	
54 54
    ///This function instantiates a PredMap.
55 55
    ///\param g is the digraph, to which we would like to define the
56 56
    ///PredMap.
57 57
    static PredMap *createPredMap(const Digraph &g)
58 58
    {
59 59
      return new PredMap(g);
60 60
    }
61 61

	
62 62
    ///The type of the map that indicates which nodes are processed.
63 63

	
64 64
    ///The type of the map that indicates which nodes are processed.
65 65
    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
66 66
    typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
67 67
    ///Instantiates a ProcessedMap.
68 68

	
69 69
    ///This function instantiates a ProcessedMap.
70 70
    ///\param g is the digraph, to which
71 71
    ///we would like to define the ProcessedMap
72 72
#ifdef DOXYGEN
73 73
    static ProcessedMap *createProcessedMap(const Digraph &g)
74 74
#else
75 75
    static ProcessedMap *createProcessedMap(const Digraph &)
76 76
#endif
77 77
    {
78 78
      return new ProcessedMap();
79 79
    }
80 80

	
81 81
    ///The type of the map that indicates which nodes are reached.
82 82

	
83 83
    ///The type of the map that indicates which nodes are reached.
84 84
    ///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept.
85 85
    typedef typename Digraph::template NodeMap<bool> ReachedMap;
86 86
    ///Instantiates a ReachedMap.
87 87

	
88 88
    ///This function instantiates a ReachedMap.
89 89
    ///\param g is the digraph, to which
90 90
    ///we would like to define the ReachedMap.
91 91
    static ReachedMap *createReachedMap(const Digraph &g)
92 92
    {
93 93
      return new ReachedMap(g);
94 94
    }
95 95

	
96 96
    ///The type of the map that stores the distances of the nodes.
97 97

	
98 98
    ///The type of the map that stores the distances of the nodes.
99 99
    ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
100 100
    typedef typename Digraph::template NodeMap<int> DistMap;
101 101
    ///Instantiates a DistMap.
102 102

	
103 103
    ///This function instantiates a DistMap.
104 104
    ///\param g is the digraph, to which we would like to define the
105 105
    ///DistMap.
106 106
    static DistMap *createDistMap(const Digraph &g)
107 107
    {
108 108
      return new DistMap(g);
109 109
    }
110 110
  };
111 111

	
112 112
  ///%DFS algorithm class.
113 113

	
114 114
  ///\ingroup search
115 115
  ///This class provides an efficient implementation of the %DFS algorithm.
116 116
  ///
117 117
  ///There is also a \ref dfs() "function-type interface" for the DFS
118 118
  ///algorithm, which is convenient in the simplier cases and it can be
119 119
  ///used easier.
120 120
  ///
121 121
  ///\tparam GR The type of the digraph the algorithm runs on.
122 122
  ///The default value is \ref ListDigraph. The value of GR is not used
123 123
  ///directly by \ref Dfs, it is only passed to \ref DfsDefaultTraits.
124 124
  ///\tparam TR Traits class to set various data types used by the algorithm.
125 125
  ///The default traits class is
126 126
  ///\ref DfsDefaultTraits "DfsDefaultTraits<GR>".
127 127
  ///See \ref DfsDefaultTraits for the documentation of
128 128
  ///a Dfs traits class.
129 129
#ifdef DOXYGEN
130 130
  template <typename GR,
131 131
            typename TR>
132 132
#else
133 133
  template <typename GR=ListDigraph,
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_GRAPH_TO_EPS_H
20 20
#define LEMON_GRAPH_TO_EPS_H
21 21

	
22 22
#include<iostream>
23 23
#include<fstream>
24 24
#include<sstream>
25 25
#include<algorithm>
26 26
#include<vector>
27 27

	
28 28
#ifndef WIN32
29 29
#include<sys/time.h>
30 30
#include<ctime>
31 31
#else
32 32
#include<lemon/bits/windows.h>
33 33
#endif
34 34

	
35 35
#include<lemon/math.h>
36 36
#include<lemon/core.h>
37 37
#include<lemon/dim2.h>
38 38
#include<lemon/maps.h>
39 39
#include<lemon/color.h>
40 40
#include<lemon/bits/bezier.h>
41 41
#include<lemon/error.h>
42 42

	
43 43

	
44 44
///\ingroup eps_io
45 45
///\file
46 46
///\brief A well configurable tool for visualizing graphs
47 47

	
48 48
namespace lemon {
49 49

	
50 50
  namespace _graph_to_eps_bits {
51 51
    template<class MT>
52 52
    class _NegY {
53 53
    public:
54 54
      typedef typename MT::Key Key;
55 55
      typedef typename MT::Value Value;
56 56
      const MT &map;
57 57
      int yscale;
58 58
      _NegY(const MT &m,bool b) : map(m), yscale(1-b*2) {}
59 59
      Value operator[](Key n) { return Value(map[n].x,map[n].y*yscale);}
60 60
    };
61 61
  }
62 62

	
63 63
///Default traits class of GraphToEps
64 64

	
65 65
///Default traits class of \ref GraphToEps.
66 66
///
67 67
///\c G is the type of the underlying graph.
68 68
template<class G>
69 69
struct DefaultGraphToEpsTraits
70 70
{
71 71
  typedef G Graph;
72 72
  typedef typename Graph::Node Node;
73 73
  typedef typename Graph::NodeIt NodeIt;
74 74
  typedef typename Graph::Arc Arc;
75 75
  typedef typename Graph::ArcIt ArcIt;
76 76
  typedef typename Graph::InArcIt InArcIt;
77 77
  typedef typename Graph::OutArcIt OutArcIt;
78 78

	
79 79

	
80 80
  const Graph &g;
81 81

	
82 82
  std::ostream& os;
83 83

	
84 84
  typedef ConstMap<typename Graph::Node,dim2::Point<double> > CoordsMapType;
85 85
  CoordsMapType _coords;
86 86
  ConstMap<typename Graph::Node,double > _nodeSizes;
87 87
  ConstMap<typename Graph::Node,int > _nodeShapes;
88 88

	
89 89
  ConstMap<typename Graph::Node,Color > _nodeColors;
90 90
  ConstMap<typename Graph::Arc,Color > _arcColors;
91 91

	
92 92
  ConstMap<typename Graph::Arc,double > _arcWidths;
93 93

	
94 94
  double _arcWidthScale;
95 95

	
96 96
  double _nodeScale;
97 97
  double _xBorder, _yBorder;
98 98
  double _scale;
99 99
  double _nodeBorderQuotient;
100 100

	
101 101
  bool _drawArrows;
102 102
  double _arrowLength, _arrowWidth;
103 103

	
104 104
  bool _showNodes, _showArcs;
105 105

	
106 106
  bool _enableParallel;
107 107
  double _parArcDist;
108 108

	
109 109
  bool _showNodeText;
110 110
  ConstMap<typename Graph::Node,bool > _nodeTexts;
111 111
  double _nodeTextSize;
112 112

	
113 113
  bool _showNodePsText;
114 114
  ConstMap<typename Graph::Node,bool > _nodePsTexts;
115 115
  char *_nodePsTextsPreamble;
116 116

	
117 117
  bool _undirected;
118 118

	
119 119
  bool _pleaseRemoveOsStream;
120 120

	
121 121
  bool _scaleToA4;
122 122

	
123 123
  std::string _title;
124 124
  std::string _copyright;
125 125

	
126 126
  enum NodeTextColorType
127 127
    { DIST_COL=0, DIST_BW=1, CUST_COL=2, SAME_COL=3 } _nodeTextColorType;
128 128
  ConstMap<typename Graph::Node,Color > _nodeTextColors;
129 129

	
130 130
  bool _autoNodeScale;
131 131
  bool _autoArcWidthScale;
132 132

	
133 133
  bool _absoluteNodeSizes;
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
///\ingroup lemon_io
20 20
///\file
21 21
///\brief \ref lgf-format "LEMON Graph Format" writer.
22 22

	
23 23

	
24 24
#ifndef LEMON_LGF_WRITER_H
25 25
#define LEMON_LGF_WRITER_H
26 26

	
27 27
#include <iostream>
28 28
#include <fstream>
29 29
#include <sstream>
30 30

	
31 31
#include <algorithm>
32 32

	
33 33
#include <vector>
34 34
#include <functional>
35 35

	
36 36
#include <lemon/core.h>
37 37
#include <lemon/maps.h>
38 38

	
39 39
#include <lemon/concept_check.h>
40 40
#include <lemon/concepts/maps.h>
41 41

	
42 42
namespace lemon {
43 43

	
44 44
  namespace _writer_bits {
45 45

	
46 46
    template <typename Value>
47 47
    struct DefaultConverter {
48 48
      std::string operator()(const Value& value) {
49 49
        std::ostringstream os;
50 50
        os << value;
51 51
        return os.str();
52 52
      }
53 53
    };
54 54

	
55 55
    template <typename T>
56 56
    bool operator<(const T&, const T&) {
57 57
      throw FormatError("Label map is not comparable");
58 58
    }
59 59

	
60 60
    template <typename _Map>
61 61
    class MapLess {
62 62
    public:
63 63
      typedef _Map Map;
64 64
      typedef typename Map::Key Item;
65 65

	
66 66
    private:
67 67
      const Map& _map;
68 68

	
69 69
    public:
70 70
      MapLess(const Map& map) : _map(map) {}
71 71

	
72 72
      bool operator()(const Item& left, const Item& right) {
73 73
        return _map[left] < _map[right];
74 74
      }
75 75
    };
76 76

	
77 77
    template <typename _Graph, bool _dir, typename _Map>
78 78
    class GraphArcMapLess {
79 79
    public:
80 80
      typedef _Map Map;
81 81
      typedef _Graph Graph;
82 82
      typedef typename Graph::Edge Item;
83 83

	
84 84
    private:
85 85
      const Graph& _graph;
86 86
      const Map& _map;
87 87

	
88 88
    public:
89 89
      GraphArcMapLess(const Graph& graph, const Map& map)
90 90
        : _graph(graph), _map(map) {}
91 91

	
92 92
      bool operator()(const Item& left, const Item& right) {
93 93
        return _map[_graph.direct(left, _dir)] <
94 94
          _map[_graph.direct(right, _dir)];
95 95
      }
96 96
    };
97 97

	
98 98
    template <typename _Item>
99 99
    class MapStorageBase {
100 100
    public:
101 101
      typedef _Item Item;
102 102

	
103 103
    public:
104 104
      MapStorageBase() {}
105 105
      virtual ~MapStorageBase() {}
106 106

	
107 107
      virtual std::string get(const Item& item) = 0;
108 108
      virtual void sort(std::vector<Item>&) = 0;
109 109
    };
110 110

	
111 111
    template <typename _Item, typename _Map,
112 112
              typename _Converter = DefaultConverter<typename _Map::Value> >
113 113
    class MapStorage : public MapStorageBase<_Item> {
114 114
    public:
115 115
      typedef _Map Map;
116 116
      typedef _Converter Converter;
117 117
      typedef _Item Item;
118 118

	
119 119
    private:
120 120
      const Map& _map;
121 121
      Converter _converter;
122 122

	
123 123
    public:
124 124
      MapStorage(const Map& map, const Converter& converter = Converter())
125 125
        : _map(map), _converter(converter) {}
126 126
      virtual ~MapStorage() {}
127 127

	
128 128
      virtual std::string get(const Item& item) {
129 129
        return _converter(_map[item]);
130 130
      }
131 131
      virtual void sort(std::vector<Item>& items) {
132 132
        MapLess<Map> less(_map);
133 133
        std::sort(items.begin(), items.end(), less);
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_LIST_GRAPH_H
20 20
#define LEMON_LIST_GRAPH_H
21 21

	
22 22
///\ingroup graphs
23 23
///\file
24 24
///\brief ListDigraph, ListGraph classes.
25 25

	
26 26
#include <lemon/core.h>
27 27
#include <lemon/error.h>
28 28
#include <lemon/bits/graph_extender.h>
29 29

	
30 30
#include <vector>
31 31
#include <list>
32 32

	
33 33
namespace lemon {
34 34

	
35 35
  class ListDigraphBase {
36 36

	
37 37
  protected:
38 38
    struct NodeT {
39 39
      int first_in, first_out;
40 40
      int prev, next;
41 41
    };
42 42

	
43 43
    struct ArcT {
44 44
      int target, source;
45 45
      int prev_in, prev_out;
46 46
      int next_in, next_out;
47 47
    };
48 48

	
49 49
    std::vector<NodeT> nodes;
50 50

	
51 51
    int first_node;
52 52

	
53 53
    int first_free_node;
54 54

	
55 55
    std::vector<ArcT> arcs;
56 56

	
57 57
    int first_free_arc;
58 58

	
59 59
  public:
60 60

	
61 61
    typedef ListDigraphBase Digraph;
62 62

	
63 63
    class Node {
64 64
      friend class ListDigraphBase;
65 65
    protected:
66 66

	
67 67
      int id;
68 68
      explicit Node(int pid) { id = pid;}
69 69

	
70 70
    public:
71 71
      Node() {}
72 72
      Node (Invalid) { id = -1; }
73 73
      bool operator==(const Node& node) const {return id == node.id;}
74 74
      bool operator!=(const Node& node) const {return id != node.id;}
75 75
      bool operator<(const Node& node) const {return id < node.id;}
76 76
    };
77 77

	
78 78
    class Arc {
79 79
      friend class ListDigraphBase;
80 80
    protected:
81 81

	
82 82
      int id;
83 83
      explicit Arc(int pid) { id = pid;}
84 84

	
85 85
    public:
86 86
      Arc() {}
87 87
      Arc (Invalid) { id = -1; }
88 88
      bool operator==(const Arc& arc) const {return id == arc.id;}
89 89
      bool operator!=(const Arc& arc) const {return id != arc.id;}
90 90
      bool operator<(const Arc& arc) const {return id < arc.id;}
91 91
    };
92 92

	
93 93

	
94 94

	
95 95
    ListDigraphBase()
96 96
      : nodes(), first_node(-1),
97 97
        first_free_node(-1), arcs(), first_free_arc(-1) {}
98 98

	
99 99

	
100 100
    int maxNodeId() const { return nodes.size()-1; }
101 101
    int maxArcId() const { return arcs.size()-1; }
102 102

	
103 103
    Node source(Arc e) const { return Node(arcs[e.id].source); }
104 104
    Node target(Arc e) const { return Node(arcs[e.id].target); }
105 105

	
106 106

	
107 107
    void first(Node& node) const {
108 108
      node.id = first_node;
109 109
    }
110 110

	
111 111
    void next(Node& node) const {
112 112
      node.id = nodes[node.id].next;
113 113
    }
114 114

	
115 115

	
116 116
    void first(Arc& arc) const {
117 117
      int n;
118 118
      for(n = first_node;
119 119
          n!=-1 && nodes[n].first_in == -1;
120 120
          n = nodes[n].next) {}
121 121
      arc.id = (n == -1) ? -1 : nodes[n].first_in;
122 122
    }
123 123

	
124 124
    void next(Arc& arc) const {
125 125
      if (arcs[arc.id].next_in != -1) {
126 126
        arc.id = arcs[arc.id].next_in;
127 127
      } else {
128 128
        int n;
129 129
        for(n = nodes[arcs[arc.id].target].next;
130 130
            n!=-1 && nodes[n].first_in == -1;
131 131
            n = nodes[n].next) {}
132 132
        arc.id = (n == -1) ? -1 : nodes[n].first_in;
133 133
      }
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
///\ingroup paths
20 20
///\file
21 21
///\brief Classes for representing paths in digraphs.
22 22
///
23 23

	
24 24
#ifndef LEMON_PATH_H
25 25
#define LEMON_PATH_H
26 26

	
27 27
#include <vector>
28 28
#include <algorithm>
29 29

	
30 30
#include <lemon/error.h>
31 31
#include <lemon/core.h>
32 32
#include <lemon/concepts/path.h>
33 33

	
34 34
namespace lemon {
35 35

	
36 36
  /// \addtogroup paths
37 37
  /// @{
38 38

	
39 39

	
40 40
  /// \brief A structure for representing directed paths in a digraph.
41 41
  ///
42 42
  /// A structure for representing directed path in a digraph.
43 43
  /// \tparam _Digraph The digraph type in which the path is.
44 44
  ///
45 45
  /// In a sense, the path can be treated as a list of arcs. The
46 46
  /// lemon path type stores just this list. As a consequence, it
47 47
  /// cannot enumerate the nodes of the path and the source node of
48 48
  /// a zero length path is undefined.
49 49
  ///
50 50
  /// This implementation is a back and front insertable and erasable
51 51
  /// path type. It can be indexed in O(1) time. The front and back
52 52
  /// insertion and erase is done in O(1) (amortized) time. The
53 53
  /// implementation uses two vectors for storing the front and back
54 54
  /// insertions.
55 55
  template <typename _Digraph>
56 56
  class Path {
57 57
  public:
58 58

	
59 59
    typedef _Digraph Digraph;
60 60
    typedef typename Digraph::Arc Arc;
61 61

	
62 62
    /// \brief Default constructor
63 63
    ///
64 64
    /// Default constructor
65 65
    Path() {}
66 66

	
67 67
    /// \brief Template copy constructor
68 68
    ///
69 69
    /// This constuctor initializes the path from any other path type.
70 70
    /// It simply makes a copy of the given path.
71 71
    template <typename CPath>
72 72
    Path(const CPath& cpath) {
73 73
      pathCopy(cpath, *this);
74 74
    }
75 75

	
76 76
    /// \brief Template copy assignment
77 77
    ///
78 78
    /// This operator makes a copy of a path of any other type.
79 79
    template <typename CPath>
80 80
    Path& operator=(const CPath& cpath) {
81 81
      pathCopy(cpath, *this);
82 82
      return *this;
83 83
    }
84 84

	
85 85
    /// \brief LEMON style iterator for path arcs
86 86
    ///
87 87
    /// This class is used to iterate on the arcs of the paths.
88 88
    class ArcIt {
89 89
      friend class Path;
90 90
    public:
91 91
      /// \brief Default constructor
92 92
      ArcIt() {}
93 93
      /// \brief Invalid constructor
94 94
      ArcIt(Invalid) : path(0), idx(-1) {}
95 95
      /// \brief Initializate the iterator to the first arc of path
96 96
      ArcIt(const Path &_path)
97 97
        : path(&_path), idx(_path.empty() ? -1 : 0) {}
98 98

	
99 99
    private:
100 100

	
101 101
      ArcIt(const Path &_path, int _idx)
102 102
        : path(&_path), idx(_idx) {}
103 103

	
104 104
    public:
105 105

	
106 106
      /// \brief Conversion to Arc
107 107
      operator const Arc&() const {
108 108
        return path->nth(idx);
109 109
      }
110 110

	
111 111
      /// \brief Next arc
112 112
      ArcIt& operator++() {
113 113
        ++idx;
114 114
        if (idx >= path->length()) idx = -1;
115 115
        return *this;
116 116
      }
117 117

	
118 118
      /// \brief Comparison operator
119 119
      bool operator==(const ArcIt& e) const { return idx==e.idx; }
120 120
      /// \brief Comparison operator
121 121
      bool operator!=(const ArcIt& e) const { return idx!=e.idx; }
122 122
      /// \brief Comparison operator
123 123
      bool operator<(const ArcIt& e) const { return idx<e.idx; }
124 124

	
125 125
    private:
126 126
      const Path *path;
127 127
      int idx;
128 128
    };
129 129

	
130 130
    /// \brief Length of the path.
131 131
    int length() const { return head.size() + tail.size(); }
132 132
    /// \brief Return whether the path is empty.
133 133
    bool empty() const { return head.empty() && tail.empty(); }
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
/*
20 20
 * This file contains the reimplemented version of the Mersenne Twister
21 21
 * Generator of Matsumoto and Nishimura.
22 22
 *
23 23
 * See the appropriate copyright notice below.
24 24
 *
25 25
 * Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
26 26
 * All rights reserved.
27 27
 *
28 28
 * Redistribution and use in source and binary forms, with or without
29 29
 * modification, are permitted provided that the following conditions
30 30
 * are met:
31 31
 *
32 32
 * 1. Redistributions of source code must retain the above copyright
33 33
 *    notice, this list of conditions and the following disclaimer.
34 34
 *
35 35
 * 2. Redistributions in binary form must reproduce the above copyright
36 36
 *    notice, this list of conditions and the following disclaimer in the
37 37
 *    documentation and/or other materials provided with the distribution.
38 38
 *
39 39
 * 3. The names of its contributors may not be used to endorse or promote
40 40
 *    products derived from this software without specific prior written
41 41
 *    permission.
42 42
 *
43 43
 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
44 44
 * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
45 45
 * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
46 46
 * FOR A PARTICULAR PURPOSE ARE DISCLAIMED.  IN NO EVENT SHALL THE
47 47
 * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
48 48
 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
49 49
 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
50 50
 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
51 51
 * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
52 52
 * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
53 53
 * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
54 54
 * OF THE POSSIBILITY OF SUCH DAMAGE.
55 55
 *
56 56
 *
57 57
 * Any feedback is very welcome.
58 58
 * http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/emt.html
59 59
 * email: m-mat @ math.sci.hiroshima-u.ac.jp (remove space)
60 60
 */
61 61

	
62 62
#ifndef LEMON_RANDOM_H
63 63
#define LEMON_RANDOM_H
64 64

	
65 65
#include <algorithm>
66 66
#include <iterator>
67 67
#include <vector>
68 68
#include <limits>
69 69
#include <fstream>
70 70

	
71 71
#include <lemon/math.h>
72 72
#include <lemon/dim2.h>
73 73

	
74 74
#ifndef WIN32
75 75
#include <sys/time.h>
76 76
#include <ctime>
77 77
#include <sys/types.h>
78 78
#include <unistd.h>
79 79
#else
80 80
#include <lemon/bits/windows.h>
81 81
#endif
82 82

	
83 83
///\ingroup misc
84 84
///\file
85 85
///\brief Mersenne Twister random number generator
86 86

	
87 87
namespace lemon {
88 88

	
89 89
  namespace _random_bits {
90 90

	
91 91
    template <typename _Word, int _bits = std::numeric_limits<_Word>::digits>
92 92
    struct RandomTraits {};
93 93

	
94 94
    template <typename _Word>
95 95
    struct RandomTraits<_Word, 32> {
96 96

	
97 97
      typedef _Word Word;
98 98
      static const int bits = 32;
99 99

	
100 100
      static const int length = 624;
101 101
      static const int shift = 397;
102 102

	
103 103
      static const Word mul = 0x6c078965u;
104 104
      static const Word arrayInit = 0x012BD6AAu;
105 105
      static const Word arrayMul1 = 0x0019660Du;
106 106
      static const Word arrayMul2 = 0x5D588B65u;
107 107

	
108 108
      static const Word mask = 0x9908B0DFu;
109 109
      static const Word loMask = (1u << 31) - 1;
110 110
      static const Word hiMask = ~loMask;
111 111

	
112 112

	
113 113
      static Word tempering(Word rnd) {
114 114
        rnd ^= (rnd >> 11);
115 115
        rnd ^= (rnd << 7) & 0x9D2C5680u;
116 116
        rnd ^= (rnd << 15) & 0xEFC60000u;
117 117
        rnd ^= (rnd >> 18);
118 118
        return rnd;
119 119
      }
120 120

	
121 121
    };
122 122

	
123 123
    template <typename _Word>
124 124
    struct RandomTraits<_Word, 64> {
125 125

	
126 126
      typedef _Word Word;
127 127
      static const int bits = 64;
128 128

	
129 129
      static const int length = 312;
130 130
      static const int shift = 156;
131 131

	
132 132
      static const Word mul = Word(0x5851F42Du) << 32 | Word(0x4C957F2Du);
133 133
      static const Word arrayInit = Word(0x00000000u) << 32 |Word(0x012BD6AAu);
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_SMART_GRAPH_H
20 20
#define LEMON_SMART_GRAPH_H
21 21

	
22 22
///\ingroup graphs
23 23
///\file
24 24
///\brief SmartDigraph and SmartGraph classes.
25 25

	
26 26
#include <vector>
27 27

	
28 28
#include <lemon/core.h>
29 29
#include <lemon/error.h>
30 30
#include <lemon/bits/graph_extender.h>
31 31

	
32 32
namespace lemon {
33 33

	
34 34
  class SmartDigraph;
35 35
  ///Base of SmartDigraph
36 36

	
37 37
  ///Base of SmartDigraph
38 38
  ///
39 39
  class SmartDigraphBase {
40 40
  protected:
41 41

	
42 42
    struct NodeT
43 43
    {
44 44
      int first_in, first_out;
45 45
      NodeT() {}
46 46
    };
47 47
    struct ArcT
48 48
    {
49 49
      int target, source, next_in, next_out;
50 50
      ArcT() {}
51 51
    };
52 52

	
53 53
    std::vector<NodeT> nodes;
54 54
    std::vector<ArcT> arcs;
55 55

	
56 56
  public:
57 57

	
58 58
    typedef SmartDigraphBase Graph;
59 59

	
60 60
    class Node;
61 61
    class Arc;
62 62

	
63 63
  public:
64 64

	
65 65
    SmartDigraphBase() : nodes(), arcs() { }
66 66
    SmartDigraphBase(const SmartDigraphBase &_g)
67 67
      : nodes(_g.nodes), arcs(_g.arcs) { }
68 68

	
69 69
    typedef True NodeNumTag;
70 70
    typedef True EdgeNumTag;
71 71

	
72 72
    int nodeNum() const { return nodes.size(); }
73 73
    int arcNum() const { return arcs.size(); }
74 74

	
75 75
    int maxNodeId() const { return nodes.size()-1; }
76 76
    int maxArcId() const { return arcs.size()-1; }
77 77

	
78 78
    Node addNode() {
79 79
      int n = nodes.size();
80 80
      nodes.push_back(NodeT());
81 81
      nodes[n].first_in = -1;
82 82
      nodes[n].first_out = -1;
83 83
      return Node(n);
84 84
    }
85 85

	
86 86
    Arc addArc(Node u, Node v) {
87 87
      int n = arcs.size();
88 88
      arcs.push_back(ArcT());
89 89
      arcs[n].source = u._id;
90 90
      arcs[n].target = v._id;
91 91
      arcs[n].next_out = nodes[u._id].first_out;
92 92
      arcs[n].next_in = nodes[v._id].first_in;
93 93
      nodes[u._id].first_out = nodes[v._id].first_in = n;
94 94

	
95 95
      return Arc(n);
96 96
    }
97 97

	
98 98
    void clear() {
99 99
      arcs.clear();
100 100
      nodes.clear();
101 101
    }
102 102

	
103 103
    Node source(Arc a) const { return Node(arcs[a._id].source); }
104 104
    Node target(Arc a) const { return Node(arcs[a._id].target); }
105 105

	
106 106
    static int id(Node v) { return v._id; }
107 107
    static int id(Arc a) { return a._id; }
108 108

	
109 109
    static Node nodeFromId(int id) { return Node(id);}
110 110
    static Arc arcFromId(int id) { return Arc(id);}
111 111

	
112 112
    bool valid(Node n) const {
113 113
      return n._id >= 0 && n._id < static_cast<int>(nodes.size());
114 114
    }
115 115
    bool valid(Arc a) const {
116 116
      return a._id >= 0 && a._id < static_cast<int>(arcs.size());
117 117
    }
118 118

	
119 119
    class Node {
120 120
      friend class SmartDigraphBase;
121 121
      friend class SmartDigraph;
122 122

	
123 123
    protected:
124 124
      int _id;
125 125
      explicit Node(int id) : _id(id) {}
126 126
    public:
127 127
      Node() {}
128 128
      Node (Invalid) : _id(-1) {}
129 129
      bool operator==(const Node i) const {return _id == i._id;}
130 130
      bool operator!=(const Node i) const {return _id != i._id;}
131 131
      bool operator<(const Node i) const {return _id < i._id;}
132 132
    };
133 133

	
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_TIME_MEASURE_H
20 20
#define LEMON_TIME_MEASURE_H
21 21

	
22 22
///\ingroup timecount
23 23
///\file
24 24
///\brief Tools for measuring cpu usage
25 25

	
26 26
#ifdef WIN32
27 27
#include <lemon/bits/windows.h>
28 28
#else
29 29
#include <unistd.h>
30 30
#include <sys/times.h>
31 31
#include <sys/time.h>
32 32
#endif
33 33

	
34 34
#include <string>
35 35
#include <fstream>
36 36
#include <iostream>
37 37

	
38 38
namespace lemon {
39 39

	
40 40
  /// \addtogroup timecount
41 41
  /// @{
42 42

	
43 43
  /// A class to store (cpu)time instances.
44 44

	
45 45
  /// This class stores five time values.
46 46
  /// - a real time
47 47
  /// - a user cpu time
48 48
  /// - a system cpu time
49 49
  /// - a user cpu time of children
50 50
  /// - a system cpu time of children
51 51
  ///
52 52
  /// TimeStamp's can be added to or substracted from each other and
53 53
  /// they can be pushed to a stream.
54 54
  ///
55 55
  /// In most cases, perhaps the \ref Timer or the \ref TimeReport
56 56
  /// class is what you want to use instead.
57 57

	
58 58
  class TimeStamp
59 59
  {
60 60
    double utime;
61 61
    double stime;
62 62
    double cutime;
63 63
    double cstime;
64 64
    double rtime;
65 65

	
66 66
    void _reset() {
67 67
      utime = stime = cutime = cstime = rtime = 0;
68 68
    }
69 69

	
70 70
  public:
71 71

	
72 72
    ///Read the current time values of the process
73 73
    void stamp()
74 74
    {
75 75
#ifndef WIN32
76 76
      timeval tv;
77 77
      gettimeofday(&tv, 0);
78 78
      rtime=tv.tv_sec+double(tv.tv_usec)/1e6;
79 79

	
80 80
      tms ts;
81 81
      double tck=sysconf(_SC_CLK_TCK);
82 82
      times(&ts);
83 83
      utime=ts.tms_utime/tck;
84 84
      stime=ts.tms_stime/tck;
85 85
      cutime=ts.tms_cutime/tck;
86 86
      cstime=ts.tms_cstime/tck;
87 87
#else
88 88
      bits::getWinProcTimes(rtime, utime, stime, cutime, cstime);
89 89
#endif
90 90
    }
91 91

	
92 92
    /// Constructor initializing with zero
93 93
    TimeStamp()
94 94
    { _reset(); }
95 95
    ///Constructor initializing with the current time values of the process
96 96
    TimeStamp(void *) { stamp();}
97 97

	
98 98
    ///Set every time value to zero
99 99
    TimeStamp &reset() {_reset();return *this;}
100 100

	
101 101
    ///\e
102 102
    TimeStamp &operator+=(const TimeStamp &b)
103 103
    {
104 104
      utime+=b.utime;
105 105
      stime+=b.stime;
106 106
      cutime+=b.cutime;
107 107
      cstime+=b.cstime;
108 108
      rtime+=b.rtime;
109 109
      return *this;
110 110
    }
111 111
    ///\e
112 112
    TimeStamp operator+(const TimeStamp &b) const
113 113
    {
114 114
      TimeStamp t(*this);
115 115
      return t+=b;
116 116
    }
117 117
    ///\e
118 118
    TimeStamp &operator-=(const TimeStamp &b)
119 119
    {
120 120
      utime-=b.utime;
121 121
      stime-=b.stime;
122 122
      cutime-=b.cutime;
123 123
      cstime-=b.cstime;
124 124
      rtime-=b.rtime;
125 125
      return *this;
126 126
    }
127 127
    ///\e
128 128
    TimeStamp operator-(const TimeStamp &b) const
129 129
    {
130 130
      TimeStamp t(*this);
131 131
      return t-=b;
132 132
    }
133 133
    ///\e
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_TOLERANCE_H
20 20
#define LEMON_TOLERANCE_H
21 21

	
22 22
///\ingroup misc
23 23
///\file
24 24
///\brief A basic tool to handle the anomalies of calculation with
25 25
///floating point numbers.
26 26
///
27 27

	
28 28
namespace lemon {
29 29

	
30 30
  /// \addtogroup misc
31 31
  /// @{
32 32

	
33 33
  ///\brief A class to provide a basic way to
34 34
  ///handle the comparison of numbers that are obtained
35 35
  ///as a result of a probably inexact computation.
36 36
  ///
37 37
  ///\ref Tolerance is a class to provide a basic way to
38 38
  ///handle the comparison of numbers that are obtained
39 39
  ///as a result of a probably inexact computation.
40 40
  ///
41 41
  ///The general implementation is suitable only if the data type is exact,
42 42
  ///like the integer types, otherwise a specialized version must be
43 43
  ///implemented. These specialized classes like
44 44
  ///Tolerance<double> may offer additional tuning parameters.
45 45
  ///
46 46
  ///\sa Tolerance<float>
47 47
  ///\sa Tolerance<double>
48 48
  ///\sa Tolerance<long double>
49 49

	
50 50
  template<class T>
51 51
  class Tolerance
52 52
  {
53 53
  public:
54 54
    typedef T Value;
55 55

	
56 56
    ///\name Comparisons
57 57
    ///The concept is that these bool functions return \c true only if
58 58
    ///the related comparisons hold even if some numerical error appeared
59 59
    ///during the computations.
60 60

	
61 61
    ///@{
62 62

	
63 63
    ///Returns \c true if \c a is \e surely strictly less than \c b
64 64
    static bool less(Value a,Value b) {return a<b;}
65 65
    ///Returns \c true if \c a is \e surely different from \c b
66 66
    static bool different(Value a,Value b) {return a!=b;}
67 67
    ///Returns \c true if \c a is \e surely positive
68 68
    static bool positive(Value a) {return static_cast<Value>(0) < a;}
69 69
    ///Returns \c true if \c a is \e surely negative
70 70
    static bool negative(Value a) {return a < static_cast<Value>(0);}
71 71
    ///Returns \c true if \c a is \e surely non-zero
72 72
    static bool nonZero(Value a) {return a != static_cast<Value>(0);}
73 73

	
74 74
    ///@}
75 75

	
76 76
    ///Returns the zero value.
77 77
    static Value zero() {return static_cast<Value>(0);}
78 78

	
79 79
    //   static bool finite(Value a) {}
80 80
    //   static Value big() {}
81 81
    //   static Value negativeBig() {}
82 82
  };
83 83

	
84 84

	
85 85
  ///Float specialization of Tolerance.
86 86

	
87 87
  ///Float specialization of Tolerance.
88 88
  ///\sa Tolerance
89 89
  ///\relates Tolerance
90 90
  template<>
91 91
  class Tolerance<float>
92 92
  {
93 93
    static float def_epsilon;
94 94
    float _epsilon;
95 95
  public:
96 96
    ///\e
97 97
    typedef float Value;
98 98

	
99 99
    ///Constructor setting the epsilon tolerance to the default value.
100 100
    Tolerance() : _epsilon(def_epsilon) {}
101 101
    ///Constructor setting the epsilon tolerance to the given value.
102 102
    Tolerance(float e) : _epsilon(e) {}
103 103

	
104 104
    ///Returns the epsilon value.
105 105
    Value epsilon() const {return _epsilon;}
106 106
    ///Sets the epsilon value.
107 107
    void epsilon(Value e) {_epsilon=e;}
108 108

	
109 109
    ///Returns the default epsilon value.
110 110
    static Value defaultEpsilon() {return def_epsilon;}
111 111
    ///Sets the default epsilon value.
112 112
    static void defaultEpsilon(Value e) {def_epsilon=e;}
113 113

	
114 114
    ///\name Comparisons
115 115
    ///See \ref lemon::Tolerance "Tolerance" for more details.
116 116

	
117 117
    ///@{
118 118

	
119 119
    ///Returns \c true if \c a is \e surely strictly less than \c b
120 120
    bool less(Value a,Value b) const {return a+_epsilon<b;}
121 121
    ///Returns \c true if \c a is \e surely different from \c b
122 122
    bool different(Value a,Value b) const { return less(a,b)||less(b,a); }
123 123
    ///Returns \c true if \c a is \e surely positive
124 124
    bool positive(Value a) const { return _epsilon<a; }
125 125
    ///Returns \c true if \c a is \e surely negative
126 126
    bool negative(Value a) const { return -_epsilon>a; }
127 127
    ///Returns \c true if \c a is \e surely non-zero
128 128
    bool nonZero(Value a) const { return positive(a)||negative(a); }
129 129

	
130 130
    ///@}
131 131

	
132 132
    ///Returns zero
133 133
    static Value zero() {return 0;}
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#ifndef LEMON_UNION_FIND_H
20 20
#define LEMON_UNION_FIND_H
21 21

	
22 22
//!\ingroup auxdat
23 23
//!\file
24 24
//!\brief Union-Find data structures.
25 25
//!
26 26

	
27 27
#include <vector>
28 28
#include <list>
29 29
#include <utility>
30 30
#include <algorithm>
31 31
#include <functional>
32 32

	
33 33
#include <lemon/core.h>
34 34

	
35 35
namespace lemon {
36 36

	
37 37
  /// \ingroup auxdat
38 38
  ///
39 39
  /// \brief A \e Union-Find data structure implementation
40 40
  ///
41 41
  /// The class implements the \e Union-Find data structure.
42 42
  /// The union operation uses rank heuristic, while
43 43
  /// the find operation uses path compression.
44 44
  /// This is a very simple but efficient implementation, providing
45 45
  /// only four methods: join (union), find, insert and size.
46 46
  /// For more features see the \ref UnionFindEnum class.
47 47
  ///
48 48
  /// It is primarily used in Kruskal algorithm for finding minimal
49 49
  /// cost spanning tree in a graph.
50 50
  /// \sa kruskal()
51 51
  ///
52 52
  /// \pre You need to add all the elements by the \ref insert()
53 53
  /// method.
54 54
  template <typename _ItemIntMap>
55 55
  class UnionFind {
56 56
  public:
57 57

	
58 58
    typedef _ItemIntMap ItemIntMap;
59 59
    typedef typename ItemIntMap::Key Item;
60 60

	
61 61
  private:
62 62
    // If the items vector stores negative value for an item then
63 63
    // that item is root item and it has -items[it] component size.
64 64
    // Else the items[it] contains the index of the parent.
65 65
    std::vector<int> items;
66 66
    ItemIntMap& index;
67 67

	
68 68
    bool rep(int idx) const {
69 69
      return items[idx] < 0;
70 70
    }
71 71

	
72 72
    int repIndex(int idx) const {
73 73
      int k = idx;
74 74
      while (!rep(k)) {
75 75
        k = items[k] ;
76 76
      }
77 77
      while (idx != k) {
78 78
        int next = items[idx];
79 79
        const_cast<int&>(items[idx]) = k;
80 80
        idx = next;
81 81
      }
82 82
      return k;
83 83
    }
84 84

	
85 85
  public:
86 86

	
87 87
    /// \brief Constructor
88 88
    ///
89 89
    /// Constructor of the UnionFind class. You should give an item to
90 90
    /// integer map which will be used from the data structure. If you
91 91
    /// modify directly this map that may cause segmentation fault,
92 92
    /// invalid data structure, or infinite loop when you use again
93 93
    /// the union-find.
94 94
    UnionFind(ItemIntMap& m) : index(m) {}
95 95

	
96 96
    /// \brief Returns the index of the element's component.
97 97
    ///
98 98
    /// The method returns the index of the element's component.
99 99
    /// This is an integer between zero and the number of inserted elements.
100 100
    ///
101 101
    int find(const Item& a) {
102 102
      return repIndex(index[a]);
103 103
    }
104 104

	
105 105
    /// \brief Clears the union-find data structure
106 106
    ///
107 107
    /// Erase each item from the data structure.
108 108
    void clear() {
109 109
      items.clear();
110 110
    }
111 111

	
112 112
    /// \brief Inserts a new element into the structure.
113 113
    ///
114 114
    /// This method inserts a new element into the data structure.
115 115
    ///
116 116
    /// The method returns the index of the new component.
117 117
    int insert(const Item& a) {
118 118
      int n = items.size();
119 119
      items.push_back(-1);
120 120
      index.set(a,n);
121 121
      return n;
122 122
    }
123 123

	
124 124
    /// \brief Joining the components of element \e a and element \e b.
125 125
    ///
126 126
    /// This is the \e union operation of the Union-Find structure.
127 127
    /// Joins the component of element \e a and component of
128 128
    /// element \e b. If \e a and \e b are in the same component then
129 129
    /// it returns false otherwise it returns true.
130 130
    bool join(const Item& a, const Item& b) {
131 131
      int ka = repIndex(index[a]);
132 132
      int kb = repIndex(index[b]);
133 133

	
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#include <lemon/concepts/digraph.h>
20 20
#include <lemon/smart_graph.h>
21 21
#include <lemon/list_graph.h>
22 22
#include <lemon/lgf_reader.h>
23 23
#include <lemon/dfs.h>
24 24
#include <lemon/path.h>
25 25

	
26 26
#include "graph_test.h"
27 27
#include "test_tools.h"
28 28

	
29 29
using namespace lemon;
30 30

	
31 31
char test_lgf[] =
32 32
  "@nodes\n"
33 33
  "label\n"
34 34
  "0\n"
35 35
  "1\n"
36 36
  "2\n"
37 37
  "3\n"
38 38
  "4\n"
39 39
  "5\n"
40 40
  "6\n"
41 41
  "@arcs\n"
42 42
  "     label\n"
43 43
  "0 1  0\n"
44 44
  "1 2  1\n"
45 45
  "2 3  2\n"
46 46
  "1 4  3\n"
47 47
  "4 2  4\n"
48 48
  "4 5  5\n"
49 49
  "5 0  6\n"
50 50
  "6 3  7\n"
51 51
  "@attributes\n"
52 52
  "source 0\n"
53 53
  "target 5\n"
54 54
  "source1 6\n"
55 55
  "target1 3\n";
56 56

	
57 57

	
58 58
void checkDfsCompile()
59 59
{
60 60
  typedef concepts::Digraph Digraph;
61 61
  typedef Dfs<Digraph> DType;
62 62
  typedef Digraph::Node Node;
63 63
  typedef Digraph::Arc Arc;
64 64

	
65 65
  Digraph G;
66 66
  Node s, t;
67 67
  Arc e;
68 68
  int l;
69 69
  bool b;
70 70
  DType::DistMap d(G);
71 71
  DType::PredMap p(G);
72 72
  Path<Digraph> pp;
73 73

	
74 74
  {
75 75
    DType dfs_test(G);
76 76

	
77 77
    dfs_test.run(s);
78 78
    dfs_test.run(s,t);
79 79
    dfs_test.run();
80 80

	
81 81
    l  = dfs_test.dist(t);
82 82
    e  = dfs_test.predArc(t);
83 83
    s  = dfs_test.predNode(t);
84 84
    b  = dfs_test.reached(t);
85 85
    d  = dfs_test.distMap();
86 86
    p  = dfs_test.predMap();
87 87
    pp = dfs_test.path(t);
88 88
  }
89 89
  {
90 90
    DType
91 91
      ::SetPredMap<concepts::ReadWriteMap<Node,Arc> >
92 92
      ::SetDistMap<concepts::ReadWriteMap<Node,int> >
93 93
      ::SetReachedMap<concepts::ReadWriteMap<Node,bool> >
94 94
      ::SetProcessedMap<concepts::WriteMap<Node,bool> >
95 95
      ::SetStandardProcessedMap
96 96
      ::Create dfs_test(G);
97 97

	
98 98
    dfs_test.run(s);
99 99
    dfs_test.run(s,t);
100 100
    dfs_test.run();
101 101

	
102 102
    l  = dfs_test.dist(t);
103 103
    e  = dfs_test.predArc(t);
104 104
    s  = dfs_test.predNode(t);
105 105
    b  = dfs_test.reached(t);
106 106
    pp = dfs_test.path(t);
107 107
  }
108 108
}
109 109

	
110 110
void checkDfsFunctionCompile()
111 111
{
112 112
  typedef int VType;
113 113
  typedef concepts::Digraph Digraph;
114 114
  typedef Digraph::Arc Arc;
115 115
  typedef Digraph::Node Node;
116 116

	
117 117
  Digraph g;
118 118
  bool b;
119 119
  dfs(g).run(Node());
120 120
  b=dfs(g).run(Node(),Node());
121 121
  dfs(g).run();
122 122
  dfs(g)
123 123
    .predMap(concepts::ReadWriteMap<Node,Arc>())
124 124
    .distMap(concepts::ReadWriteMap<Node,VType>())
125 125
    .reachedMap(concepts::ReadWriteMap<Node,bool>())
126 126
    .processedMap(concepts::WriteMap<Node,bool>())
127 127
    .run(Node());
128 128
  b=dfs(g)
129 129
    .predMap(concepts::ReadWriteMap<Node,Arc>())
130 130
    .distMap(concepts::ReadWriteMap<Node,VType>())
131 131
    .reachedMap(concepts::ReadWriteMap<Node,bool>())
132 132
    .processedMap(concepts::WriteMap<Node,bool>())
133 133
    .path(concepts::Path<Digraph>())
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#include <lemon/smart_graph.h>
20 20
#include <lemon/list_graph.h>
21 21
#include <lemon/lgf_reader.h>
22 22
#include <lemon/error.h>
23 23

	
24 24
#include "test_tools.h"
25 25

	
26 26
using namespace std;
27 27
using namespace lemon;
28 28

	
29 29
void digraph_copy_test() {
30 30
  const int nn = 10;
31 31

	
32 32
  // Build a digraph
33 33
  SmartDigraph from;
34 34
  SmartDigraph::NodeMap<int> fnm(from);
35 35
  SmartDigraph::ArcMap<int> fam(from);
36 36
  SmartDigraph::Node fn = INVALID;
37 37
  SmartDigraph::Arc fa = INVALID;
38 38

	
39 39
  std::vector<SmartDigraph::Node> fnv;
40 40
  for (int i = 0; i < nn; ++i) {
41 41
    SmartDigraph::Node node = from.addNode();
42 42
    fnv.push_back(node);
43 43
    fnm[node] = i * i;
44 44
    if (i == 0) fn = node;
45 45
  }
46 46

	
47 47
  for (int i = 0; i < nn; ++i) {
48 48
    for (int j = 0; j < nn; ++j) {
49 49
      SmartDigraph::Arc arc = from.addArc(fnv[i], fnv[j]);
50 50
      fam[arc] = i + j * j;
51 51
      if (i == 0 && j == 0) fa = arc;
52 52
    }
53 53
  }
54 54

	
55 55
  // Test digraph copy
56 56
  ListDigraph to;
57 57
  ListDigraph::NodeMap<int> tnm(to);
58 58
  ListDigraph::ArcMap<int> tam(to);
59 59
  ListDigraph::Node tn;
60 60
  ListDigraph::Arc ta;
61 61

	
62 62
  SmartDigraph::NodeMap<ListDigraph::Node> nr(from);
63 63
  SmartDigraph::ArcMap<ListDigraph::Arc> er(from);
64 64

	
65 65
  ListDigraph::NodeMap<SmartDigraph::Node> ncr(to);
66 66
  ListDigraph::ArcMap<SmartDigraph::Arc> ecr(to);
67 67

	
68 68
  digraphCopy(from, to).
69 69
    nodeMap(fnm, tnm).arcMap(fam, tam).
70 70
    nodeRef(nr).arcRef(er).
71 71
    nodeCrossRef(ncr).arcCrossRef(ecr).
72 72
    node(fn, tn).arc(fa, ta).run();
73 73
  
74 74
  check(countNodes(from) == countNodes(to), "Wrong copy.");
75 75
  check(countArcs(from) == countArcs(to), "Wrong copy.");
76 76

	
77 77
  for (SmartDigraph::NodeIt it(from); it != INVALID; ++it) {
78 78
    check(ncr[nr[it]] == it, "Wrong copy.");
79 79
    check(fnm[it] == tnm[nr[it]], "Wrong copy.");
80 80
  }
81 81

	
82 82
  for (SmartDigraph::ArcIt it(from); it != INVALID; ++it) {
83 83
    check(ecr[er[it]] == it, "Wrong copy.");
84 84
    check(fam[it] == tam[er[it]], "Wrong copy.");
85 85
    check(nr[from.source(it)] == to.source(er[it]), "Wrong copy.");
86 86
    check(nr[from.target(it)] == to.target(er[it]), "Wrong copy.");
87 87
  }
88 88

	
89 89
  for (ListDigraph::NodeIt it(to); it != INVALID; ++it) {
90 90
    check(nr[ncr[it]] == it, "Wrong copy.");
91 91
  }
92 92

	
93 93
  for (ListDigraph::ArcIt it(to); it != INVALID; ++it) {
94 94
    check(er[ecr[it]] == it, "Wrong copy.");
95 95
  }
96 96
  check(tn == nr[fn], "Wrong copy.");
97 97
  check(ta == er[fa], "Wrong copy.");
98 98

	
99 99
  // Test repeated copy
100 100
  digraphCopy(from, to).run();
101 101
  
102 102
  check(countNodes(from) == countNodes(to), "Wrong copy.");
103 103
  check(countArcs(from) == countArcs(to), "Wrong copy.");
104 104
}
105 105

	
106 106
void graph_copy_test() {
107 107
  const int nn = 10;
108 108

	
109 109
  // Build a graph
110 110
  SmartGraph from;
111 111
  SmartGraph::NodeMap<int> fnm(from);
112 112
  SmartGraph::ArcMap<int> fam(from);
113 113
  SmartGraph::EdgeMap<int> fem(from);
114 114
  SmartGraph::Node fn = INVALID;
115 115
  SmartGraph::Arc fa = INVALID;
116 116
  SmartGraph::Edge fe = INVALID;
117 117

	
118 118
  std::vector<SmartGraph::Node> fnv;
119 119
  for (int i = 0; i < nn; ++i) {
120 120
    SmartGraph::Node node = from.addNode();
121 121
    fnv.push_back(node);
122 122
    fnm[node] = i * i;
123 123
    if (i == 0) fn = node;
124 124
  }
125 125

	
126 126
  for (int i = 0; i < nn; ++i) {
127 127
    for (int j = 0; j < nn; ++j) {
128 128
      SmartGraph::Edge edge = from.addEdge(fnv[i], fnv[j]);
129 129
      fem[edge] = i * i + j * j;
130 130
      fam[from.direct(edge, true)] = i + j * j;
131 131
      fam[from.direct(edge, false)] = i * i + j;
132 132
      if (i == 0 && j == 0) fa = from.direct(edge, true);
133 133
      if (i == 0 && j == 0) fe = edge;
Show white space 256 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5
 * Copyright (C) 2003-2008
5
 * Copyright (C) 2003-2011
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

	
19 19
#include <deque>
20 20
#include <set>
21 21

	
22 22
#include <lemon/concept_check.h>
23 23
#include <lemon/concepts/maps.h>
24 24
#include <lemon/maps.h>
25 25

	
26 26
#include "test_tools.h"
27 27

	
28 28
using namespace lemon;
29 29
using namespace lemon::concepts;
30 30

	
31 31
struct A {};
32 32
inline bool operator<(A, A) { return true; }
33 33
struct B {};
34 34

	
35 35
class C {
36 36
  int x;
37 37
public:
38 38
  C(int _x) : x(_x) {}
39 39
};
40 40

	
41 41
class F {
42 42
public:
43 43
  typedef A argument_type;
44 44
  typedef B result_type;
45 45

	
46 46
  B operator()(const A&) const { return B(); }
47 47
private:
48 48
  F& operator=(const F&);
49 49
};
50 50

	
51 51
int func(A) { return 3; }
52 52

	
53 53
int binc(int a, B) { return a+1; }
54 54

	
55 55
typedef ReadMap<A, double> DoubleMap;
56 56
typedef ReadWriteMap<A, double> DoubleWriteMap;
57 57
typedef ReferenceMap<A, double, double&, const double&> DoubleRefMap;
58 58

	
59 59
typedef ReadMap<A, bool> BoolMap;
60 60
typedef ReadWriteMap<A, bool> BoolWriteMap;
61 61
typedef ReferenceMap<A, bool, bool&, const bool&> BoolRefMap;
62 62

	
63 63
int main()
64 64
{
65 65
  // Map concepts
66 66
  checkConcept<ReadMap<A,B>, ReadMap<A,B> >();
67 67
  checkConcept<ReadMap<A,C>, ReadMap<A,C> >();
68 68
  checkConcept<WriteMap<A,B>, WriteMap<A,B> >();
69 69
  checkConcept<WriteMap<A,C>, WriteMap<A,C> >();
70 70
  checkConcept<ReadWriteMap<A,B>, ReadWriteMap<A,B> >();
71 71
  checkConcept<ReadWriteMap<A,C>, ReadWriteMap<A,C> >();
72
  checkConcept<ReferenceMap<A,B,B&,const B&>, ReferenceMap<A,B,B&,const B&> >();
73
  checkConcept<ReferenceMap<A,C,C&,const C&>, ReferenceMap<A,C,C&,const C&> >();
72
  checkConcept<ReferenceMap<A,B,B&,const B&>,
73
               ReferenceMap<A,B,B&,const B&> >();
74
  checkConcept<ReferenceMap<A,C,C&,const C&>,
75
               ReferenceMap<A,C,C&,const C&> >();
74 76

	
75 77
  // NullMap
76 78
  {
77 79
    checkConcept<ReadWriteMap<A,B>, NullMap<A,B> >();
78 80
    NullMap<A,B> map1;
79 81
    NullMap<A,B> map2 = map1;
80 82
    map1 = nullMap<A,B>();
81 83
  }
82 84

	
83 85
  // ConstMap
84 86
  {
85 87
    checkConcept<ReadWriteMap<A,B>, ConstMap<A,B> >();
86 88
    checkConcept<ReadWriteMap<A,C>, ConstMap<A,C> >();
87 89
    ConstMap<A,B> map1;
88 90
    ConstMap<A,B> map2 = B();
89 91
    ConstMap<A,B> map3 = map1;
90 92
    map1 = constMap<A>(B());
91 93
    map1 = constMap<A,B>();
92 94
    map1.setAll(B());
93 95
    ConstMap<A,C> map4(C(1));
94 96
    ConstMap<A,C> map5 = map4;
95 97
    map4 = constMap<A>(C(2));
96 98
    map4.setAll(C(3));
97 99

	
98 100
    checkConcept<ReadWriteMap<A,int>, ConstMap<A,int> >();
99 101
    check(constMap<A>(10)[A()] == 10, "Something is wrong with ConstMap");
100 102

	
101 103
    checkConcept<ReadWriteMap<A,int>, ConstMap<A,Const<int,10> > >();
102 104
    ConstMap<A,Const<int,10> > map6;
103 105
    ConstMap<A,Const<int,10> > map7 = map6;
104 106
    map6 = constMap<A,int,10>();
105 107
    map7 = constMap<A,Const<int,10> >();
106 108
    check(map6[A()] == 10 && map7[A()] == 10,
107 109
          "Something is wrong with ConstMap");
108 110
  }
109 111

	
110 112
  // IdentityMap
111 113
  {
112 114
    checkConcept<ReadMap<A,A>, IdentityMap<A> >();
113 115
    IdentityMap<A> map1;
114 116
    IdentityMap<A> map2 = map1;
115 117
    map1 = identityMap<A>();
116 118

	
117 119
    checkConcept<ReadMap<double,double>, IdentityMap<double> >();
118 120
    check(identityMap<double>()[1.0] == 1.0 &&
119 121
          identityMap<double>()[3.14] == 3.14,
120 122
          "Something is wrong with IdentityMap");
121 123
  }
122 124

	
123 125
  // RangeMap
124 126
  {
125 127
    checkConcept<ReferenceMap<int,B,B&,const B&>, RangeMap<B> >();
126 128
    RangeMap<B> map1;
127 129
    RangeMap<B> map2(10);
128 130
    RangeMap<B> map3(10,B());
129 131
    RangeMap<B> map4 = map1;
130 132
    RangeMap<B> map5 = rangeMap<B>();
131 133
    RangeMap<B> map6 = rangeMap<B>(10);
132 134
    RangeMap<B> map7 = rangeMap(10,B());
133 135

	
134 136
    checkConcept< ReferenceMap<int, double, double&, const double&>,
135 137
                  RangeMap<double> >();
136 138
    std::vector<double> v(10, 0);
137 139
    v[5] = 100;
138 140
    RangeMap<double> map8(v);
139 141
    RangeMap<double> map9 = rangeMap(v);
140 142
    check(map9.size() == 10 && map9[2] == 0 && map9[5] == 100,
141 143
          "Something is wrong with RangeMap");
142 144
  }
143 145

	
144 146
  // SparseMap
145 147
  {
146 148
    checkConcept<ReferenceMap<A,B,B&,const B&>, SparseMap<A,B> >();
147 149
    SparseMap<A,B> map1;
148 150
    SparseMap<A,B> map2 = B();
149 151
    SparseMap<A,B> map3 = sparseMap<A,B>();
150 152
    SparseMap<A,B> map4 = sparseMap<A>(B());
151 153

	
152 154
    checkConcept< ReferenceMap<double, int, int&, const int&>,
153 155
                  SparseMap<double, int> >();
154 156
    std::map<double, int> m;
155 157
    SparseMap<double, int> map5(m);
156 158
    SparseMap<double, int> map6(m,10);
157 159
    SparseMap<double, int> map7 = sparseMap(m);
158 160
    SparseMap<double, int> map8 = sparseMap(m,10);
159 161

	
160 162
    check(map5[1.0] == 0 && map5[3.14] == 0 &&
161 163
          map6[1.0] == 10 && map6[3.14] == 10,
162 164
          "Something is wrong with SparseMap");
163 165
    map5[1.0] = map6[3.14] = 100;
164 166
    check(map5[1.0] == 100 && map5[3.14] == 0 &&
165 167
          map6[1.0] == 10 && map6[3.14] == 100,
166 168
          "Something is wrong with SparseMap");
167 169
  }
168 170

	
169 171
  // ComposeMap
170 172
  {
171 173
    typedef ComposeMap<DoubleMap, ReadMap<B,A> > CompMap;
172 174
    checkConcept<ReadMap<B,double>, CompMap>();
173 175
    CompMap map1 = CompMap(DoubleMap(),ReadMap<B,A>());
174 176
    CompMap map2 = composeMap(DoubleMap(), ReadMap<B,A>());
175 177

	
176 178
    SparseMap<double, bool> m1(false); m1[3.14] = true;
177 179
    RangeMap<double> m2(2); m2[0] = 3.0; m2[1] = 3.14;
178 180
    check(!composeMap(m1,m2)[0] && composeMap(m1,m2)[1],
179 181
          "Something is wrong with ComposeMap")
180 182
  }
181 183

	
182 184
  // CombineMap
183 185
  {
184 186
    typedef CombineMap<DoubleMap, DoubleMap, std::plus<double> > CombMap;
185 187
    checkConcept<ReadMap<A,double>, CombMap>();
186 188
    CombMap map1 = CombMap(DoubleMap(), DoubleMap());
187 189
    CombMap map2 = combineMap(DoubleMap(), DoubleMap(), std::plus<double>());
188 190

	
189 191
    check(combineMap(constMap<B,int,2>(), identityMap<B>(), &binc)[B()] == 3,
190 192
          "Something is wrong with CombineMap");
191 193
  }
192 194

	
193 195
  // FunctorToMap, MapToFunctor
194 196
  {
195 197
    checkConcept<ReadMap<A,B>, FunctorToMap<F,A,B> >();
196 198
    checkConcept<ReadMap<A,B>, FunctorToMap<F> >();
197 199
    FunctorToMap<F> map1;
198 200
    FunctorToMap<F> map2 = FunctorToMap<F>(F());
199 201
    B b = functorToMap(F())[A()];
200 202

	
201 203
    checkConcept<ReadMap<A,B>, MapToFunctor<ReadMap<A,B> > >();
202
    MapToFunctor<ReadMap<A,B> > map = MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>());
204
    MapToFunctor<ReadMap<A,B> > map =
205
      MapToFunctor<ReadMap<A,B> >(ReadMap<A,B>());
203 206

	
204 207
    check(functorToMap(&func)[A()] == 3,
205 208
          "Something is wrong with FunctorToMap");
206 209
    check(mapToFunctor(constMap<A,int>(2))(A()) == 2,
207 210
          "Something is wrong with MapToFunctor");
208 211
    check(mapToFunctor(functorToMap(&func))(A()) == 3 &&
209 212
          mapToFunctor(functorToMap(&func))[A()] == 3,
210 213
          "Something is wrong with FunctorToMap or MapToFunctor");
211 214
    check(functorToMap(mapToFunctor(constMap<A,int>(2)))[A()] == 2,
212 215
          "Something is wrong with FunctorToMap or MapToFunctor");
213 216
  }
214 217

	
215 218
  // ConvertMap
216 219
  {
217 220
    checkConcept<ReadMap<double,double>,
218 221
      ConvertMap<ReadMap<double, int>, double> >();
219 222
    ConvertMap<RangeMap<bool>, int> map1(rangeMap(1, true));
220 223
    ConvertMap<RangeMap<bool>, int> map2 = convertMap<int>(rangeMap(2, false));
221 224
  }
222 225

	
223 226
  // ForkMap
224 227
  {
225 228
    checkConcept<DoubleWriteMap, ForkMap<DoubleWriteMap, DoubleWriteMap> >();
226 229

	
227 230
    typedef RangeMap<double> RM;
228 231
    typedef SparseMap<int, double> SM;
229 232
    RM m1(10, -1);
230 233
    SM m2(-1);
231 234
    checkConcept<ReadWriteMap<int, double>, ForkMap<RM, SM> >();
232 235
    checkConcept<ReadWriteMap<int, double>, ForkMap<SM, RM> >();
233 236
    ForkMap<RM, SM> map1(m1,m2);
234 237
    ForkMap<SM, RM> map2 = forkMap(m2,m1);
235 238
    map2.set(5, 10);
236 239
    check(m1[1] == -1 && m1[5] == 10 && m2[1] == -1 &&
237 240
          m2[5] == 10 && map2[1] == -1 && map2[5] == 10,
238 241
          "Something is wrong with ForkMap");
239 242
  }
240 243

	
241 244
  // Arithmetic maps:
242 245
  // - AddMap, SubMap, MulMap, DivMap
243 246
  // - ShiftMap, ShiftWriteMap, ScaleMap, ScaleWriteMap
244 247
  // - NegMap, NegWriteMap, AbsMap
245 248
  {
246 249
    checkConcept<DoubleMap, AddMap<DoubleMap,DoubleMap> >();
247 250
    checkConcept<DoubleMap, SubMap<DoubleMap,DoubleMap> >();
248 251
    checkConcept<DoubleMap, MulMap<DoubleMap,DoubleMap> >();
249 252
    checkConcept<DoubleMap, DivMap<DoubleMap,DoubleMap> >();
250 253

	
251 254
    ConstMap<int, double> c1(1.0), c2(3.14);
252 255
    IdentityMap<int> im;
253 256
    ConvertMap<IdentityMap<int>, double> id(im);
254 257
    check(addMap(c1,id)[0] == 1.0  && addMap(c1,id)[10] == 11.0,
255 258
          "Something is wrong with AddMap");
256 259
    check(subMap(id,c1)[0] == -1.0 && subMap(id,c1)[10] == 9.0,
257 260
          "Something is wrong with SubMap");
258 261
    check(mulMap(id,c2)[0] == 0    && mulMap(id,c2)[2]  == 6.28,
259 262
          "Something is wrong with MulMap");
260 263
    check(divMap(c2,id)[1] == 3.14 && divMap(c2,id)[2]  == 1.57,
261 264
          "Something is wrong with DivMap");
262 265

	
263 266
    checkConcept<DoubleMap, ShiftMap<DoubleMap> >();
264 267
    checkConcept<DoubleWriteMap, ShiftWriteMap<DoubleWriteMap> >();
265 268
    checkConcept<DoubleMap, ScaleMap<DoubleMap> >();
266 269
    checkConcept<DoubleWriteMap, ScaleWriteMap<DoubleWriteMap> >();
267 270
    checkConcept<DoubleMap, NegMap<DoubleMap> >();
268 271
    checkConcept<DoubleWriteMap, NegWriteMap<DoubleWriteMap> >();
269 272
    checkConcept<DoubleMap, AbsMap<DoubleMap> >();
270 273

	
271 274
    check(shiftMap(id, 2.0)[1] == 3.0 && shiftMap(id, 2.0)[10] == 12.0,
272 275
          "Something is wrong with ShiftMap");
273 276
    check(shiftWriteMap(id, 2.0)[1] == 3.0 &&
274 277
          shiftWriteMap(id, 2.0)[10] == 12.0,
275 278
          "Something is wrong with ShiftWriteMap");
276 279
    check(scaleMap(id, 2.0)[1] == 2.0 && scaleMap(id, 2.0)[10] == 20.0,
277 280
          "Something is wrong with ScaleMap");
278 281
    check(scaleWriteMap(id, 2.0)[1] == 2.0 &&
279 282
          scaleWriteMap(id, 2.0)[10] == 20.0,
280 283
          "Something is wrong with ScaleWriteMap");
281 284
    check(negMap(id)[1] == -1.0 && negMap(id)[-10] == 10.0,
282 285
          "Something is wrong with NegMap");
283 286
    check(negWriteMap(id)[1] == -1.0 && negWriteMap(id)[-10] == 10.0,
284 287
          "Something is wrong with NegWriteMap");
285 288
    check(absMap(id)[1] == 1.0 && absMap(id)[-10] == 10.0,
286 289
          "Something is wrong with AbsMap");
287 290
  }
288 291

	
289 292
  // Logical maps:
290 293
  // - TrueMap, FalseMap
291 294
  // - AndMap, OrMap
292 295
  // - NotMap, NotWriteMap
293 296
  // - EqualMap, LessMap
294 297
  {
295 298
    checkConcept<BoolMap, TrueMap<A> >();
296 299
    checkConcept<BoolMap, FalseMap<A> >();
297 300
    checkConcept<BoolMap, AndMap<BoolMap,BoolMap> >();
298 301
    checkConcept<BoolMap, OrMap<BoolMap,BoolMap> >();
299 302
    checkConcept<BoolMap, NotMap<BoolMap> >();
300 303
    checkConcept<BoolWriteMap, NotWriteMap<BoolWriteMap> >();
301 304
    checkConcept<BoolMap, EqualMap<DoubleMap,DoubleMap> >();
302 305
    checkConcept<BoolMap, LessMap<DoubleMap,DoubleMap> >();
303 306

	
304 307
    TrueMap<int> tm;
305 308
    FalseMap<int> fm;
306 309
    RangeMap<bool> rm(2);
307 310
    rm[0] = true; rm[1] = false;
308 311
    check(andMap(tm,rm)[0] && !andMap(tm,rm)[1] &&
309 312
          !andMap(fm,rm)[0] && !andMap(fm,rm)[1],
310 313
          "Something is wrong with AndMap");
311 314
    check(orMap(tm,rm)[0] && orMap(tm,rm)[1] &&
312 315
          orMap(fm,rm)[0] && !orMap(fm,rm)[1],
313 316
          "Something is wrong with OrMap");
314 317
    check(!notMap(rm)[0] && notMap(rm)[1],
315 318
          "Something is wrong with NotMap");
316 319
    check(!notWriteMap(rm)[0] && notWriteMap(rm)[1],
317 320
          "Something is wrong with NotWriteMap");
318 321

	
319 322
    ConstMap<int, double> cm(2.0);
320 323
    IdentityMap<int> im;
321 324
    ConvertMap<IdentityMap<int>, double> id(im);
322 325
    check(lessMap(id,cm)[1] && !lessMap(id,cm)[2] && !lessMap(id,cm)[3],
323 326
          "Something is wrong with LessMap");
324 327
    check(!equalMap(id,cm)[1] && equalMap(id,cm)[2] && !equalMap(id,cm)[3],
325 328
          "Something is wrong with EqualMap");
326 329
  }
327 330

	
328 331
  // LoggerBoolMap
329 332
  {
330 333
    typedef std::vector<int> vec;
0 comments (0 inline)