↑ Collapse diff ↑
Ignore white space 6 line context
1
%!PS-Adobe-2.0 EPSF-2.0
2
%%Creator: LEMON, graphToEps()
3
%%CreationDate: Sun Mar 14 09:08:34 2010
4
%%BoundingBox: -353 -264 559 292
5
%%EndComments
6
/lb { setlinewidth setrgbcolor newpath moveto
7
      4 2 roll 1 index 1 index curveto stroke } bind def
8
/l { setlinewidth setrgbcolor newpath moveto lineto stroke } bind def
9
/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath } bind def
10
/sq { newpath 2 index 1 index add 2 index 2 index add moveto
11
      2 index 1 index sub 2 index 2 index add lineto
12
      2 index 1 index sub 2 index 2 index sub lineto
13
      2 index 1 index add 2 index 2 index sub lineto
14
      closepath pop pop pop} bind def
15
/di { newpath 2 index 1 index add 2 index moveto
16
      2 index             2 index 2 index add lineto
17
      2 index 1 index sub 2 index             lineto
18
      2 index             2 index 2 index sub lineto
19
      closepath pop pop pop} bind def
20
/nc { 0 0 0 setrgbcolor 5 index 5 index 5 index c fill
21
     setrgbcolor 1.1 div c fill
22
   } bind def
23
/nsq { 0 0 0 setrgbcolor 5 index 5 index 5 index sq fill
24
     setrgbcolor 1.1 div sq fill
25
   } bind def
26
/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill
27
     setrgbcolor 1.1 div di fill
28
   } bind def
29
/nfemale { 0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
30
  newpath 5 index 5 index moveto 5 index 5 index 5 index 3.01 mul sub
31
  lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub moveto
32
  5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto stroke
33
  5 index 5 index 5 index c fill
34
  setrgbcolor 1.1 div c fill
35
  } bind def
36
/nmale {
37
  0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
38
  newpath 5 index 5 index moveto
39
  5 index 4 index 1 mul 1.5 mul add
40
  5 index 5 index 3 sqrt 1.5 mul mul add
41
  1 index 1 index lineto
42
  1 index 1 index 7 index sub moveto
43
  1 index 1 index lineto
44
  exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub lineto
45
  stroke
46
  5 index 5 index 5 index c fill
47
  setrgbcolor 1.1 div c fill
48
  } bind def
49
/arrl 1 def
50
/arrw 0.3 def
51
/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def
52
/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx exch def
53
       /w exch def /len exch def
54
       newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto
55
       len w sub arrl sub dx dy lrl
56
       arrw dy dx neg lrl
57
       dx arrl w add mul dy w 2 div arrw add mul sub
58
       dy arrl w add mul dx w 2 div arrw add mul add rlineto
59
       dx arrl w add mul neg dy w 2 div arrw add mul sub
60
       dy arrl w add mul neg dx w 2 div arrw add mul add rlineto
61
       arrw dy dx neg lrl
62
       len w sub arrl sub neg dx dy lrl
63
       closepath fill } bind def
64
/cshow { 2 index 2 index moveto dup stringwidth pop
65
         neg 2 div fosi .35 mul neg rmoveto show pop pop} def
66

	
67
gsave
68
%Arcs:
69
gsave
70
140.321 266.249 -327.729 150.06 0 0 0 4.99223 l
71
82.1207 -238.726 -245.288 -110.743 0 0 0 4.99223 l
72
336.635 -229.036 533.603 13.109 0 0 0 4.99223 l
73
53.8598 -45.8071 -245.288 -110.743 0 0 0 4.99223 l
74
-75.5617 118.579 -327.729 150.06 0 0 0 4.99223 l
75
-327.729 150.06 -245.288 -110.743 1 0 0 11.9813 l
76
533.603 13.109 218.184 -84.2955 0 0 0 4.99223 l
77
39.87 175.035 141.163 67.2575 0 0 0 4.99223 l
78
53.8598 -45.8071 -75.5617 118.579 0 0 0 4.99223 l
79
-102.406 -141.267 82.1207 -238.726 0 0 0 4.99223 l
80
399.144 166.894 533.603 13.109 1 0 0 11.9813 l
81
39.87 175.035 140.321 266.249 1 0 0 11.9813 l
82
399.144 166.894 140.321 266.249 0 0 0 4.99223 l
83
399.144 166.894 141.163 67.2575 0 0 0 4.99223 l
84
53.8598 -45.8071 204.765 -173.77 0 0 0 4.99223 l
85
82.1207 -238.726 204.765 -173.77 0 0 0 4.99223 l
86
258.227 61.658 399.144 166.894 0 0 0 4.99223 l
87
53.8598 -45.8071 -102.406 -141.267 1 0 0 11.9813 l
88
175.073 -37.4477 141.163 67.2575 0 0 0 4.99223 l
89
258.227 61.658 380 0 0 0 0 4.99223 l
90
34.6739 40.8267 -75.5617 118.579 1 0 0 11.9813 l
91
380 0 533.603 13.109 0 0 0 4.99223 l
92
175.073 -37.4477 380 0 0 0 0 4.99223 l
93
218.184 -84.2955 204.765 -173.77 0 0 0 4.99223 l
94
53.8598 -45.8071 34.6739 40.8267 0 0 0 4.99223 l
95
167.905 -213.988 82.1207 -238.726 1 0 0 11.9813 l
96
336.635 -229.036 204.765 -173.77 1 0 0 11.9813 l
97
336.635 -229.036 167.905 -213.988 0 0 0 4.99223 l
98
329.08 -26.3098 218.184 -84.2955 0 0 0 4.99223 l
99
39.87 175.035 -75.5617 118.579 0 0 0 4.99223 l
100
53.8598 -45.8071 175.073 -37.4477 0 0 0 4.99223 l
101
34.6739 40.8267 141.163 67.2575 0 0 0 4.99223 l
102
258.227 61.658 141.163 67.2575 1 0 0 11.9813 l
103
175.073 -37.4477 218.184 -84.2955 1 0 0 11.9813 l
104
380 0 329.08 -26.3098 1 0 0 11.9813 l
105
grestore
106
%Nodes:
107
gsave
108
-245.288 -110.743 14.9767 1 1 1 nc
109
204.765 -173.77 14.9767 1 1 1 nc
110
-327.729 150.06 14.9767 1 1 1 nc
111
-75.5617 118.579 14.9767 1 1 1 nc
112
218.184 -84.2955 14.9767 1 1 1 nc
113
140.321 266.249 14.9767 1 1 1 nc
114
141.163 67.2575 14.9767 1 1 1 nc
115
82.1207 -238.726 14.9767 1 1 1 nc
116
329.08 -26.3098 14.9767 1 1 1 nc
117
-102.406 -141.267 14.9767 1 1 1 nc
118
533.603 13.109 14.9767 1 1 1 nc
119
167.905 -213.988 14.9767 1 1 1 nc
120
336.635 -229.036 14.9767 1 1 1 nc
121
380 0 14.9767 1 1 1 nc
122
399.144 166.894 14.9767 1 1 1 nc
123
34.6739 40.8267 14.9767 1 1 1 nc
124
39.87 175.035 14.9767 1 1 1 nc
125
175.073 -37.4477 14.9767 1 1 1 nc
126
53.8598 -45.8071 14.9767 1 1 1 nc
127
258.227 61.658 14.9767 1 1 1 nc
128
grestore
129
grestore
130
showpage
Ignore white space 6 line context
1
%!PS-Adobe-2.0 EPSF-2.0
2
%%Creator: LEMON, graphToEps()
3
%%CreationDate: Fri Oct 19 18:32:32 2007
4
%%BoundingBox: 0 0 596 842
5
%%DocumentPaperSizes: a4
6
%%EndComments
7
/lb { setlinewidth setrgbcolor newpath moveto
8
      4 2 roll 1 index 1 index curveto stroke } bind def
9
/l { setlinewidth setrgbcolor newpath moveto lineto stroke } bind def
10
/c { newpath dup 3 index add 2 index moveto 0 360 arc closepath } bind def
11
/sq { newpath 2 index 1 index add 2 index 2 index add moveto
12
      2 index 1 index sub 2 index 2 index add lineto
13
      2 index 1 index sub 2 index 2 index sub lineto
14
      2 index 1 index add 2 index 2 index sub lineto
15
      closepath pop pop pop} bind def
16
/di { newpath 2 index 1 index add 2 index moveto
17
      2 index             2 index 2 index add lineto
18
      2 index 1 index sub 2 index             lineto
19
      2 index             2 index 2 index sub lineto
20
      closepath pop pop pop} bind def
21
/nc { 0 0 0 setrgbcolor 5 index 5 index 5 index c fill
22
     setrgbcolor 1.1 div c fill
23
   } bind def
24
/nsq { 0 0 0 setrgbcolor 5 index 5 index 5 index sq fill
25
     setrgbcolor 1.1 div sq fill
26
   } bind def
27
/ndi { 0 0 0 setrgbcolor 5 index 5 index 5 index di fill
28
     setrgbcolor 1.1 div di fill
29
   } bind def
30
/nfemale { 0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
31
  newpath 5 index 5 index moveto 5 index 5 index 5 index 3.01 mul sub
32
  lineto 5 index 4 index .7 mul sub 5 index 5 index 2.2 mul sub moveto
33
  5 index 4 index .7 mul add 5 index 5 index 2.2 mul sub lineto stroke
34
  5 index 5 index 5 index c fill
35
  setrgbcolor 1.1 div c fill
36
  } bind def
37
/nmale {
38
  0 0 0 setrgbcolor 3 index 0.0909091 1.5 mul mul setlinewidth
39
  newpath 5 index 5 index moveto
40
  5 index 4 index 1 mul 1.5 mul add
41
  5 index 5 index 3 sqrt 1.5 mul mul add
42
  1 index 1 index lineto
43
  1 index 1 index 7 index sub moveto
44
  1 index 1 index lineto
45
  exch 5 index 3 sqrt .5 mul mul sub exch 5 index .5 mul sub lineto
46
  stroke
47
  5 index 5 index 5 index c fill
48
  setrgbcolor 1.1 div c fill
49
  } bind def
50
/arrl 1 def
51
/arrw 0.3 def
52
/lrl { 2 index mul exch 2 index mul exch rlineto pop} bind def
53
/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx exch def
54
       /w exch def /len exch def
55
       newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto
56
       len w sub arrl sub dx dy lrl
57
       arrw dy dx neg lrl
58
       dx arrl w add mul dy w 2 div arrw add mul sub
59
       dy arrl w add mul dx w 2 div arrw add mul add rlineto
60
       dx arrl w add mul neg dy w 2 div arrw add mul sub
61
       dy arrl w add mul neg dx w 2 div arrw add mul add rlineto
62
       arrw dy dx neg lrl
63
       len w sub arrl sub neg dx dy lrl
64
       closepath fill } bind def
65
/cshow { 2 index 2 index moveto dup stringwidth pop
66
         neg 2 div fosi .35 mul neg rmoveto show pop pop} def
67

	
68
gsave
69
15 138.307 translate
70
12.7843 dup scale
71
90 rotate
72
0.608112 -43.6081 translate
73
%Edges:
74
gsave
75
9 31 9.5 30.5 10 30 0 0 0 0.091217 lb
76
9 31 5.5 34.5 2 38 0 0 0 0.091217 lb
77
9 31 25.5 16 42 1 0 0 0 0.091217 lb
78
3 40 23 20.5 43 1 0 0 0 0.091217 lb
79
3 40 22.5 20.5 42 1 0 0 0 0.091217 lb
80
3 40 2.5 40.5 2 41 0 0 0 0.091217 lb
81
13 25 10.5 24.5 8 24 0 0 0 0.091217 lb
82
13 25 12 27 11 29 0 0 0 0.091217 lb
83
3 4 2.5 3 2 2 0 0 0 0.091217 lb
84
3 4 4.5 3 6 2 0 0 0 0.091217 lb
85
6 25 7 24.5 8 24 0 0 0 0.091217 lb
86
6 25 6 24.5 6 24 0 0 0 0.091217 lb
87
34 2 33.5 2 33 2 0 0 0 0.091217 lb
88
34 2 35 2 36 2 0 0 0 0.091217 lb
89
6 8 16 9 26 10 0 0 0 0.091217 lb
90
6 8 6 10.5 6 13 0 0 0 0.091217 lb
91
6 8 6 7.5 6 7 0 0 0 0.091217 lb
92
26 10 27.5 8.5 29 7 0 0 0 0.091217 lb
93
26 10 27.5 9 29 8 0 0 0 0.091217 lb
94
10 30 10.5 29.5 11 29 0 0 0 0.091217 lb
95
8 24 7 23.5 6 23 0 0 0 0.091217 lb
96
8 24 8 24.5 8 25 0 0 0 0.091217 lb
97
33 2 32.5 2 32 2 0 0 0 0.091217 lb
98
29 7 17.5 7 6 7 0 0 0 0.091217 lb
99
2 2 1.5 22 1 42 0 0 0 0.091217 lb
100
2 2 3.5 2 5 2 0 0 0 0.091217 lb
101
21 15 13.5 14.5 6 14 0 0 0 0.091217 lb
102
21 15 21 15.5 21 16 0 0 0 0.091217 lb
103
1 42 0.5 42.5 0 43 0 0 0 0.091217 lb
104
1 42 1.5 41.5 2 41 0 0 0 0.091217 lb
105
6 15 6 15.5 6 16 0 0 0 0.091217 lb
106
6 15 6 14.5 6 14 0 0 0 0.091217 lb
107
43 1 22 0.5 1 0 0 0 0 0.091217 lb
108
31 2 18.5 2 6 2 0 0 0 0.091217 lb
109
31 2 31.5 2 32 2 0 0 0 0.091217 lb
110
6 24 6 23.5 6 23 0 0 0 0.091217 lb
111
6 16 6 16.5 6 17 0 0 0 0.091217 lb
112
6 23 6 20 6 17 0 0 0 0.091217 lb
113
6 2 5.5 2 5 2 0 0 0 0.091217 lb
114
6 2 6 4.5 6 7 0 0 0 0.091217 lb
115
0 43 0.5 21.5 1 0 0 0 0 0.091217 lb
116
1 1 19.5 1.5 38 2 0 0 0 0.091217 lb
117
1 1 1 0.5 1 0 0 0 0 0.091217 lb
118
2 38 5.5 31.5 9 25 0 0 0 0.091217 lb
119
25 13 15.5 13 6 13 0 0 0 0.091217 lb
120
25 13 15.5 13.5 6 14 0 0 0 0.091217 lb
121
8 25 8.5 25 9 25 0 0 0 0.091217 lb
122
11 29 24.5 15.5 38 2 0 0 0 0.091217 lb
123
6 17 11.5 18 17 19 0 0 0 0.091217 lb
124
16 23 26.5 12.5 37 2 0 0 0 0.091217 lb
125
16 23 18.5 19.5 21 16 0 0 0 0.091217 lb
126
36 2 36.5 2 37 2 0 0 0 0.091217 lb
127
36 2 32.5 5 29 8 0 0 0 0.091217 lb
128
6 13 6 13.5 6 14 0 0 0 0.091217 lb
129
37 2 37.5 2 38 2 0 0 0 0.091217 lb
130
21 16 19 17.5 17 19 0 0 0 0.091217 lb
131
grestore
132
%Nodes:
133
gsave
134
29 8 0.304556 1 1 1 nc
135
2 41 0.304556 1 1 1 nc
136
6 7 0.304556 1 1 1 nc
137
5 2 0.304556 1 1 1 nc
138
17 19 0.304556 1 1 1 nc
139
21 16 0.304556 1 1 1 nc
140
1 0 0.304556 1 1 1 nc
141
9 25 0.304556 1 1 1 nc
142
6 14 0.304556 1 1 1 nc
143
42 1 0.304556 1 1 1 nc
144
38 2 0.304556 1 1 1 nc
145
37 2 0.304556 1 1 1 nc
146
6 13 0.304556 1 1 1 nc
147
36 2 0.304556 1 1 1 nc
148
16 23 0.304556 1 1 1 nc
149
6 17 0.304556 1 1 1 nc
150
11 29 0.304556 1 1 1 nc
151
8 25 0.304556 1 1 1 nc
152
32 2 0.304556 1 1 1 nc
153
25 13 0.304556 1 1 1 nc
154
2 38 0.304556 1 1 1 nc
155
1 1 0.304556 1 1 1 nc
156
0 43 0.304556 1 1 1 nc
157
6 2 0.304556 1 1 1 nc
158
6 23 0.304556 1 1 1 nc
159
6 16 0.304556 1 1 1 nc
160
6 24 0.304556 1 1 1 nc
161
31 2 0.304556 1 1 1 nc
162
43 1 0.304556 1 1 1 nc
163
6 15 0.304556 1 1 1 nc
164
1 42 0.304556 1 1 1 nc
165
21 15 0.304556 1 1 1 nc
166
2 2 0.304556 1 1 1 nc
167
29 7 0.304556 1 1 1 nc
168
33 2 0.304556 1 1 1 nc
169
8 24 0.304556 1 1 1 nc
170
10 30 0.304556 1 1 1 nc
171
26 10 0.304556 1 1 1 nc
172
6 8 0.304556 1 1 1 nc
173
34 2 0.304556 1 1 1 nc
174
6 25 0.304556 1 1 1 nc
175
3 4 0.304556 1 1 1 nc
176
13 25 0.304556 1 1 1 nc
177
3 40 0.304556 1 1 1 nc
178
9 31 0.304556 1 1 1 nc
179
grestore
180
grestore
181
showpage
Ignore white space 6 line context
1
%%%%% Defining LEMON %%%%%
2

	
3
@misc{lemon,
4
  key =          {LEMON},
5
  title =        {{LEMON} -- {L}ibrary for {E}fficient {M}odeling and
6
                  {O}ptimization in {N}etworks},
7
  howpublished = {\url{http://lemon.cs.elte.hu/}},
8
  year =         2009
9
}
10

	
11
@misc{egres,
12
  key =          {EGRES},
13
  title =        {{EGRES} -- {E}gerv{\'a}ry {R}esearch {G}roup on
14
                  {C}ombinatorial {O}ptimization},
15
  url =          {http://www.cs.elte.hu/egres/}
16
}
17

	
18
@misc{coinor,
19
  key =          {COIN-OR},
20
  title =        {{COIN-OR} -- {C}omputational {I}nfrastructure for
21
                  {O}perations {R}esearch},
22
  url =          {http://www.coin-or.org/}
23
}
24

	
25

	
26
%%%%% Other libraries %%%%%%
27

	
28
@misc{boost,
29
  key =          {Boost},
30
  title =        {{B}oost {C++} {L}ibraries},
31
  url =          {http://www.boost.org/}
32
}
33

	
34
@book{bglbook,
35
  author =       {Jeremy G. Siek and Lee-Quan Lee and Andrew
36
                  Lumsdaine},
37
  title =        {The Boost Graph Library: User Guide and Reference
38
                  Manual},
39
  publisher =    {Addison-Wesley},
40
  year =         2002
41
}
42

	
43
@misc{leda,
44
  key =          {LEDA},
45
  title =        {{LEDA} -- {L}ibrary of {E}fficient {D}ata {T}ypes and
46
                  {A}lgorithms},
47
  url =          {http://www.algorithmic-solutions.com/}
48
}
49

	
50
@book{ledabook,
51
  author =       {Kurt Mehlhorn and Stefan N{\"a}her},
52
  title =        {{LEDA}: {A} platform for combinatorial and geometric
53
                  computing},
54
  isbn =         {0-521-56329-1},
55
  publisher =    {Cambridge University Press},
56
  address =      {New York, NY, USA},
57
  year =         1999
58
}
59

	
60

	
61
%%%%% Tools that LEMON depends on %%%%%
62

	
63
@misc{cmake,
64
  key =          {CMake},
65
  title =        {{CMake} -- {C}ross {P}latform {M}ake},
66
  url =          {http://www.cmake.org/}
67
}
68

	
69
@misc{doxygen,
70
  key =          {Doxygen},
71
  title =        {{Doxygen} -- {S}ource code documentation generator
72
                  tool},
73
  url =          {http://www.doxygen.org/}
74
}
75

	
76

	
77
%%%%% LP/MIP libraries %%%%%
78

	
79
@misc{glpk,
80
  key =          {GLPK},
81
  title =        {{GLPK} -- {GNU} {L}inear {P}rogramming {K}it},
82
  url =          {http://www.gnu.org/software/glpk/}
83
}
84

	
85
@misc{clp,
86
  key =          {Clp},
87
  title =        {{Clp} -- {Coin-Or} {L}inear {P}rogramming},
88
  url =          {http://projects.coin-or.org/Clp/}
89
}
90

	
91
@misc{cbc,
92
  key =          {Cbc},
93
  title =        {{Cbc} -- {Coin-Or} {B}ranch and {C}ut},
94
  url =          {http://projects.coin-or.org/Cbc/}
95
}
96

	
97
@misc{cplex,
98
  key =          {CPLEX},
99
  title =        {{ILOG} {CPLEX}},
100
  url =          {http://www.ilog.com/}
101
}
102

	
103
@misc{soplex,
104
  key =          {SoPlex},
105
  title =        {{SoPlex} -- {T}he {S}equential {O}bject-{O}riented
106
                  {S}implex},
107
  url =          {http://soplex.zib.de/}
108
}
109

	
110

	
111
%%%%% General books %%%%%
112

	
113
@book{amo93networkflows,
114
  author =       {Ravindra K. Ahuja and Thomas L. Magnanti and James
115
                  B. Orlin},
116
  title =        {Network Flows: Theory, Algorithms, and Applications},
117
  publisher =    {Prentice-Hall, Inc.},
118
  year =         1993,
119
  month =        feb,
120
  isbn =         {978-0136175490}
121
}
122

	
123
@book{schrijver03combinatorial,
124
  author =       {Alexander Schrijver},
125
  title =        {Combinatorial Optimization: Polyhedra and Efficiency},
126
  publisher =    {Springer-Verlag},
127
  year =         2003,
128
  isbn =         {978-3540443896}
129
}
130

	
131
@book{clrs01algorithms,
132
  author =       {Thomas H. Cormen and Charles E. Leiserson and Ronald
133
                  L. Rivest and Clifford Stein},
134
  title =        {Introduction to Algorithms},
135
  publisher =    {The MIT Press},
136
  year =         2001,
137
  edition =      {2nd}
138
}
139

	
140
@book{stroustrup00cpp,
141
  author =       {Bjarne Stroustrup},
142
  title =        {The C++ Programming Language},
143
  edition =      {3rd},
144
  publisher =    {Addison-Wesley Professional},
145
  isbn =         0201700735,
146
  month =        {February},
147
  year =         2000
148
}
149

	
150

	
151
%%%%% Maximum flow algorithms %%%%%
152

	
153
@article{edmondskarp72theoretical,
154
  author =       {Jack Edmonds and Richard M. Karp},
155
  title =        {Theoretical improvements in algorithmic efficiency
156
                  for network flow problems},
157
  journal =      {Journal of the ACM},
158
  year =         1972,
159
  volume =       19,
160
  number =       2,
161
  pages =        {248-264}
162
}
163

	
164
@article{goldberg88newapproach,
165
  author =       {Andrew V. Goldberg and Robert E. Tarjan},
166
  title =        {A new approach to the maximum flow problem},
167
  journal =      {Journal of the ACM},
168
  year =         1988,
169
  volume =       35,
170
  number =       4,
171
  pages =        {921-940}
172
}
173

	
174
@article{dinic70algorithm,
175
  author =       {E. A. Dinic},
176
  title =        {Algorithm for solution of a problem of maximum flow
177
                  in a network with power estimation},
178
  journal =      {Soviet Math. Doklady},
179
  year =         1970,
180
  volume =       11,
181
  pages =        {1277-1280}
182
}
183

	
184
@article{goldberg08partial,
185
  author =       {Andrew V. Goldberg},
186
  title =        {The Partial Augment-Relabel Algorithm for the
187
                  Maximum Flow Problem},
188
  journal =      {16th Annual European Symposium on Algorithms},
189
  year =         2008,
190
  pages =        {466-477}
191
}
192

	
193
@article{sleator83dynamic,
194
  author =       {Daniel D. Sleator and Robert E. Tarjan},
195
  title =        {A data structure for dynamic trees},
196
  journal =      {Journal of Computer and System Sciences},
197
  year =         1983,
198
  volume =       26,
199
  number =       3,
200
  pages =        {362-391}
201
}
202

	
203

	
204
%%%%% Minimum mean cycle algorithms %%%%%
205

	
206
@article{karp78characterization,
207
  author =       {Richard M. Karp},
208
  title =        {A characterization of the minimum cycle mean in a
209
                  digraph},
210
  journal =      {Discrete Math.},
211
  year =         1978,
212
  volume =       23,
213
  pages =        {309-311}
214
}
215

	
216
@article{dasdan98minmeancycle,
217
  author =       {Ali Dasdan and Rajesh K. Gupta},
218
  title =        {Faster Maximum and Minimum Mean Cycle Alogrithms for
219
                  System Performance Analysis},
220
  journal =      {IEEE Transactions on Computer-Aided Design of
221
                  Integrated Circuits and Systems},
222
  year =         1998,
223
  volume =       17,
224
  number =       10,
225
  pages =        {889-899}
226
}
227

	
228

	
229
%%%%% Minimum cost flow algorithms %%%%%
230

	
231
@article{klein67primal,
232
  author =       {Morton Klein},
233
  title =        {A primal method for minimal cost flows with
234
                  applications to the assignment and transportation
235
                  problems},
236
  journal =      {Management Science},
237
  year =         1967,
238
  volume =       14,
239
  pages =        {205-220}
240
}
241

	
242
@article{goldberg89cyclecanceling,
243
  author =       {Andrew V. Goldberg and Robert E. Tarjan},
244
  title =        {Finding minimum-cost circulations by canceling
245
                  negative cycles},
246
  journal =      {Journal of the ACM},
247
  year =         1989,
248
  volume =       36,
249
  number =       4,
250
  pages =        {873-886}
251
}
252

	
253
@article{goldberg90approximation,
254
  author =       {Andrew V. Goldberg and Robert E. Tarjan},
255
  title =        {Finding Minimum-Cost Circulations by Successive
256
                  Approximation},
257
  journal =      {Mathematics of Operations Research},
258
  year =         1990,
259
  volume =       15,
260
  number =       3,
261
  pages =        {430-466}
262
}
263

	
264
@article{goldberg97efficient,
265
  author =       {Andrew V. Goldberg},
266
  title =        {An Efficient Implementation of a Scaling
267
                  Minimum-Cost Flow Algorithm},
268
  journal =      {Journal of Algorithms},
269
  year =         1997,
270
  volume =       22,
271
  number =       1,
272
  pages =        {1-29}
273
}
274

	
275
@article{bunnagel98efficient,
276
  author =       {Ursula B{\"u}nnagel and Bernhard Korte and Jens
277
                  Vygen},
278
  title =        {Efficient implementation of the {G}oldberg-{T}arjan
279
                  minimum-cost flow algorithm},
280
  journal =      {Optimization Methods and Software},
281
  year =         1998,
282
  volume =       10,
283
  pages =        {157-174}
284
}
285

	
286
@book{dantzig63linearprog,
287
  author =       {George B. Dantzig},
288
  title =        {Linear Programming and Extensions},
289
  publisher =    {Princeton University Press},
290
  year =         1963
291
}
292

	
293
@mastersthesis{kellyoneill91netsimplex,
294
  author =       {Damian J. Kelly and Garrett M. O'Neill},
295
  title =        {The Minimum Cost Flow Problem and The Network
296
                  Simplex Method},
297
  school =       {University College},
298
  address =      {Dublin, Ireland},
299
  year =         1991,
300
  month =        sep,
301
}
Ignore white space 6 line context
1 1
syntax: glob
2 2
*.obj
3 3
*.orig
4 4
*.rej
5 5
*~
6 6
*.o
7 7
*.log
8 8
*.lo
9 9
*.tar.*
10 10
*.bak
11 11
Makefile.in
12 12
aclocal.m4
13 13
config.h.in
14 14
configure
15 15
Makefile
16 16
config.h
17 17
config.log
18 18
config.status
19 19
libtool
20 20
stamp-h1
21 21
lemon/lemon.pc
22 22
lemon/libemon.la
23 23
lemon/stamp-h2
24 24
doc/Doxyfile
25
doc/references.dox
25 26
cmake/version.cmake
26 27
.dirstamp
27 28
.libs/*
28 29
.deps/*
29 30
demo/*.eps
30 31
m4/libtool.m4
31 32
m4/ltoptions.m4
32 33
m4/ltsugar.m4
33 34
m4/ltversion.m4
34 35
m4/lt~obsolete.m4
35 36

	
36 37
syntax: regexp
37 38
(.*/)?\#[^/]*\#$
38 39
(.*/)?\.\#[^/]*$
39 40
^doc/html/.*
40 41
^doc/.*\.tag
41 42
^autom4te.cache/.*
42 43
^build-aux/.*
43 44
^.*objs.*/.*
44 45
^test/[a-z_]*$
45 46
^tools/[a-z-_]*$
46 47
^demo/.*_demo$
47 48
^.*build.*/.*
48 49
^doc/gen-images/.*
49 50
CMakeFiles
50 51
DartTestfile.txt
51 52
cmake_install.cmake
52 53
CMakeCache.txt
Ignore white space 6 line context
1 1
CMAKE_MINIMUM_REQUIRED(VERSION 2.6)
2 2

	
3 3
SET(PROJECT_NAME "LEMON")
4 4
PROJECT(${PROJECT_NAME})
5 5

	
6 6
INCLUDE(FindPythonInterp)
7 7
INCLUDE(FindWget)
8 8

	
9 9
IF(EXISTS ${PROJECT_SOURCE_DIR}/cmake/version.cmake)
10 10
  INCLUDE(${PROJECT_SOURCE_DIR}/cmake/version.cmake)
11 11
ELSEIF(DEFINED ENV{LEMON_VERSION})
12 12
  SET(LEMON_VERSION $ENV{LEMON_VERSION} CACHE STRING "LEMON version string.")
13 13
ELSE()
14 14
  EXECUTE_PROCESS(
15 15
    COMMAND ${PYTHON_EXECUTABLE} ./scripts/chg-len.py
16 16
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
17 17
    OUTPUT_VARIABLE HG_REVISION_PATH
18 18
    ERROR_QUIET
19 19
    OUTPUT_STRIP_TRAILING_WHITESPACE
20 20
  )
21 21
  EXECUTE_PROCESS(
22 22
    COMMAND hg id -i
23 23
    WORKING_DIRECTORY ${PROJECT_SOURCE_DIR}
24 24
    OUTPUT_VARIABLE HG_REVISION
25 25
    ERROR_QUIET
26 26
    OUTPUT_STRIP_TRAILING_WHITESPACE
27 27
  )
28 28
  IF(HG_REVISION STREQUAL "")
29 29
    SET(HG_REVISION_ID "hg-tip")
30 30
  ELSE()
31 31
    IF(HG_REVISION_PATH STREQUAL "")
32 32
      SET(HG_REVISION_ID ${HG_REVISION})
33 33
    ELSE()
34 34
      SET(HG_REVISION_ID ${HG_REVISION_PATH}.${HG_REVISION})
35 35
    ENDIF()
36 36
  ENDIF()
37 37
  SET(LEMON_VERSION ${HG_REVISION_ID} CACHE STRING "LEMON version string.")
38 38
ENDIF()
39 39

	
40 40
SET(PROJECT_VERSION ${LEMON_VERSION})
41 41

	
42 42
SET(CMAKE_MODULE_PATH ${PROJECT_SOURCE_DIR}/cmake)
43 43

	
44 44
FIND_PACKAGE(Doxygen)
45 45
FIND_PACKAGE(Ghostscript)
46 46
FIND_PACKAGE(GLPK 4.33)
47 47
FIND_PACKAGE(CPLEX)
48 48
FIND_PACKAGE(COIN)
49 49

	
50 50
IF(DEFINED ENV{LEMON_CXX_WARNING})
51 51
  SET(CXX_WARNING $ENV{LEMON_CXX_WARNING})
52 52
ELSE()
53 53
  IF(CMAKE_COMPILER_IS_GNUCXX)
54 54
    SET(CXX_WARNING "-Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas")
55 55
    SET(CMAKE_CXX_FLAGS_DEBUG CACHE STRING "-ggdb")
56 56
    SET(CMAKE_C_FLAGS_DEBUG CACHE STRING "-ggdb")
57 57
  ELSEIF(MSVC)
58 58
    # This part is unnecessary 'casue the same is set by the lemon/core.h.
59 59
    # Still keep it as an example.
60 60
    SET(CXX_WARNING "/wd4250 /wd4355 /wd4503 /wd4800 /wd4996")
61 61
    # Suppressed warnings:
62 62
    # C4250: 'class1' : inherits 'class2::member' via dominance
63 63
    # C4355: 'this' : used in base member initializer list
64 64
    # C4503: 'function' : decorated name length exceeded, name was truncated
65 65
    # C4800: 'type' : forcing value to bool 'true' or 'false'
66 66
    #        (performance warning)
67 67
    # C4996: 'function': was declared deprecated
68 68
  ELSE()
69 69
    SET(CXX_WARNING "-Wall -W")
70 70
  ENDIF()
71 71
ENDIF()
72 72
SET(LEMON_CXX_WARNING_FLAGS ${CXX_WARNING} CACHE STRING "LEMON warning flags.")
73 73

	
74 74
SET(CMAKE_CXX_FLAGS "${CMAKE_CXX_FLAGS} ${LEMON_CXX_WARNING_FLAGS}")
75 75

	
76 76
SET( CMAKE_CXX_FLAGS_MAINTAINER "-Werror -ggdb" CACHE STRING
77 77
    "Flags used by the C++ compiler during maintainer builds."
78 78
    FORCE )
79 79
SET( CMAKE_C_FLAGS_MAINTAINER "-Werror" CACHE STRING
80 80
    "Flags used by the C compiler during maintainer builds."
81 81
    FORCE )
82 82
SET( CMAKE_EXE_LINKER_FLAGS_MAINTAINER
83 83
    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
84 84
    "Flags used for linking binaries during maintainer builds."
85 85
    FORCE )
86 86
SET( CMAKE_SHARED_LINKER_FLAGS_MAINTAINER
87 87
    "-Wl,--warn-unresolved-symbols,--warn-once" CACHE STRING
88 88
    "Flags used by the shared libraries linker during maintainer builds."
89 89
    FORCE )
90 90
MARK_AS_ADVANCED(
91 91
    CMAKE_CXX_FLAGS_MAINTAINER
92 92
    CMAKE_C_FLAGS_MAINTAINER
93 93
    CMAKE_EXE_LINKER_FLAGS_MAINTAINER
94 94
    CMAKE_SHARED_LINKER_FLAGS_MAINTAINER )
95 95

	
96 96
IF(CMAKE_CONFIGURATION_TYPES)
97 97
  LIST(APPEND CMAKE_CONFIGURATION_TYPES Maintainer)
98 98
  LIST(REMOVE_DUPLICATES CMAKE_CONFIGURATION_TYPES)
99 99
  SET(CMAKE_CONFIGURATION_TYPES "${CMAKE_CONFIGURATION_TYPES}" CACHE STRING
100 100
      "Add the configurations that we need"
101 101
      FORCE)
102 102
 endif()
103 103

	
104 104
IF(NOT CMAKE_BUILD_TYPE)
105 105
  SET(CMAKE_BUILD_TYPE "Release")
106 106
ENDIF()
107 107

	
108 108
SET( CMAKE_BUILD_TYPE "${CMAKE_BUILD_TYPE}" CACHE STRING
109 109
    "Choose the type of build, options are: None(CMAKE_CXX_FLAGS or CMAKE_C_FLAGS used) Debug Release RelWithDebInfo MinSizeRel Maintainer."
110 110
    FORCE )
111 111

	
112 112

	
113 113
INCLUDE(CheckTypeSize)
114 114
CHECK_TYPE_SIZE("long long" LONG_LONG)
115 115
SET(LEMON_HAVE_LONG_LONG ${HAVE_LONG_LONG})
116 116

	
117
INCLUDE(FindPythonInterp)
118

	
117 119
ENABLE_TESTING()
118 120

	
119 121
IF(${CMAKE_BUILD_TYPE} STREQUAL "Maintainer")
120 122
  ADD_CUSTOM_TARGET(check ALL COMMAND ${CMAKE_CTEST_COMMAND})
121 123
ELSE()
122 124
  ADD_CUSTOM_TARGET(check COMMAND ${CMAKE_CTEST_COMMAND})
123 125
ENDIF()
124 126

	
125 127
ADD_SUBDIRECTORY(lemon)
126 128
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
127 129
  ADD_SUBDIRECTORY(demo)
128 130
  ADD_SUBDIRECTORY(tools)
129 131
  ADD_SUBDIRECTORY(doc)
130 132
  ADD_SUBDIRECTORY(test)
131 133
ENDIF()
132 134

	
133 135
CONFIGURE_FILE(
134 136
  ${PROJECT_SOURCE_DIR}/cmake/LEMONConfig.cmake.in
135 137
  ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
136 138
  @ONLY
137 139
)
138 140
IF(UNIX)
139 141
  INSTALL(
140 142
    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
141 143
    DESTINATION share/lemon/cmake
142 144
  )
143 145
ELSEIF(WIN32)
144 146
  INSTALL(
145 147
    FILES ${PROJECT_BINARY_DIR}/cmake/LEMONConfig.cmake
146 148
    DESTINATION cmake
147 149
  )
148 150
ENDIF()
149 151

	
150 152
IF(${CMAKE_SOURCE_DIR} STREQUAL ${PROJECT_SOURCE_DIR})
151 153
  SET(CPACK_PACKAGE_NAME ${PROJECT_NAME})
152 154
  SET(CPACK_PACKAGE_VENDOR "EGRES")
153 155
  SET(CPACK_PACKAGE_DESCRIPTION_SUMMARY
154 156
    "LEMON - Library for Efficient Modeling and Optimization in Networks")
155 157
  SET(CPACK_RESOURCE_FILE_LICENSE "${PROJECT_SOURCE_DIR}/LICENSE")
156 158

	
157 159
  SET(CPACK_PACKAGE_VERSION ${PROJECT_VERSION})
158 160

	
159 161
  SET(CPACK_PACKAGE_INSTALL_DIRECTORY
160 162
    "${PROJECT_NAME} ${PROJECT_VERSION}")
161 163
  SET(CPACK_PACKAGE_INSTALL_REGISTRY_KEY
162 164
    "${PROJECT_NAME} ${PROJECT_VERSION}")
163 165

	
164 166
  SET(CPACK_COMPONENTS_ALL headers library html_documentation bin)
165 167

	
166 168
  SET(CPACK_COMPONENT_HEADERS_DISPLAY_NAME "C++ headers")
167 169
  SET(CPACK_COMPONENT_LIBRARY_DISPLAY_NAME "Dynamic-link library")
168 170
  SET(CPACK_COMPONENT_BIN_DISPLAY_NAME "Command line utilities")
169 171
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DISPLAY_NAME "HTML documentation")
170 172

	
171 173
  SET(CPACK_COMPONENT_HEADERS_DESCRIPTION
172 174
    "C++ header files")
173 175
  SET(CPACK_COMPONENT_LIBRARY_DESCRIPTION
174 176
    "DLL and import library")
175 177
  SET(CPACK_COMPONENT_BIN_DESCRIPTION
176 178
    "Command line utilities")
177 179
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_DESCRIPTION
178 180
    "Doxygen generated documentation")
179 181

	
180 182
  SET(CPACK_COMPONENT_HEADERS_DEPENDS library)
181 183

	
182 184
  SET(CPACK_COMPONENT_HEADERS_GROUP "Development")
183 185
  SET(CPACK_COMPONENT_LIBRARY_GROUP "Development")
184 186
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_GROUP "Documentation")
185 187

	
186 188
  SET(CPACK_COMPONENT_GROUP_DEVELOPMENT_DESCRIPTION
187 189
    "Components needed to develop software using LEMON")
188 190
  SET(CPACK_COMPONENT_GROUP_DOCUMENTATION_DESCRIPTION
189 191
    "Documentation of LEMON")
190 192

	
191 193
  SET(CPACK_ALL_INSTALL_TYPES Full Developer)
192 194

	
193 195
  SET(CPACK_COMPONENT_HEADERS_INSTALL_TYPES Developer Full)
194 196
  SET(CPACK_COMPONENT_LIBRARY_INSTALL_TYPES Developer Full)
195 197
  SET(CPACK_COMPONENT_HTML_DOCUMENTATION_INSTALL_TYPES Full)
196 198

	
197 199
  SET(CPACK_GENERATOR "NSIS")
198 200
  SET(CPACK_NSIS_MUI_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis/lemon.ico")
199 201
  SET(CPACK_NSIS_MUI_UNIICON "${PROJECT_SOURCE_DIR}/cmake/nsis/uninstall.ico")
200 202
  #SET(CPACK_PACKAGE_ICON "${PROJECT_SOURCE_DIR}/cmake/nsis\\\\installer.bmp")
201 203
  SET(CPACK_NSIS_INSTALLED_ICON_NAME "bin\\\\lemon.ico")
202 204
  SET(CPACK_NSIS_DISPLAY_NAME "${CPACK_PACKAGE_INSTALL_DIRECTORY} ${PROJECT_NAME}")
203 205
  SET(CPACK_NSIS_HELP_LINK "http:\\\\\\\\lemon.cs.elte.hu")
204 206
  SET(CPACK_NSIS_URL_INFO_ABOUT "http:\\\\\\\\lemon.cs.elte.hu")
205 207
  SET(CPACK_NSIS_CONTACT "lemon-user@lemon.cs.elte.hu")
206 208
  SET(CPACK_NSIS_CREATE_ICONS_EXTRA "
207 209
    CreateShortCut \\\"$SMPROGRAMS\\\\$STARTMENU_FOLDER\\\\Documentation.lnk\\\" \\\"$INSTDIR\\\\share\\\\doc\\\\index.html\\\"
208 210
    ")
209 211
  SET(CPACK_NSIS_DELETE_ICONS_EXTRA "
210 212
    !insertmacro MUI_STARTMENU_GETFOLDER Application $MUI_TEMP
211 213
    Delete \\\"$SMPROGRAMS\\\\$MUI_TEMP\\\\Documentation.lnk\\\"
212 214
    ")
213 215

	
214 216
  INCLUDE(CPack)
215 217
ENDIF()
Ignore white space 6 line context
1 1
Installation Instructions
2 2
=========================
3 3

	
4 4
Since you are reading this I assume you already obtained one of the release
5 5
tarballs and successfully extracted it. The latest version of LEMON is
6 6
available at our web page (http://lemon.cs.elte.hu/).
7 7

	
8 8
LEMON provides two different build environments, one is based on "autotool",
9 9
while the other is based on "cmake". This file contains instructions only for
10 10
the former one, which is the recommended build environment on Linux, Mac OSX
11 11
and other unices or if you use Cygwin on Windows. For cmake installation
12 12
instructions visit http://lemon.cs.elte.hu.
13 13

	
14 14
In order to install LEMON from the extracted source tarball you have to
15 15
issue the following commands:
16 16

	
17 17
   1. `cd lemon-x.y.z'
18 18

	
19 19
      This command changes to the directory which was created when you
20 20
      extracted the sources. The x.y.z part is a version number.
21 21

	
22 22
   2. `./configure'
23 23

	
24 24
      This command runs the configure shell script, which does some checks and
25 25
      creates the makefiles.
26 26

	
27 27
   3. `make'
28 28

	
29 29
      This command compiles the non-template part of LEMON into libemon.a
30 30
      file. It also compiles the programs in the tools subdirectory by
31 31
      default.
32 32

	
33 33
   4. `make check'
34 34

	
35 35
      This step is optional, but recommended. It runs the test programs that
36 36
      we developed for LEMON to check whether the library works properly on
37 37
      your platform.
38 38

	
39 39
   5. `make install'
40 40

	
41 41
      This command installs LEMON under /usr/local (you will need root
42 42
      privileges to be able to do that). If you want to install it to some
43 43
      other location, then pass the --prefix=DIRECTORY flag to configure in
44 44
      step 2. For example: `./configure --prefix=/home/username/lemon'.
45 45

	
46 46
   6. `make install-html'
47 47

	
48 48
      This command installs the documentation under share/doc/lemon/docs. The
49 49
      generated documentation is included in the tarball. If you want to
50 50
      generate it yourself, then run `make html'. Note that for this you need
51 51
      to have the following programs installed: Doxygen, Graphviz, Ghostscript,
52 52
      Latex.
53 53

	
54 54

	
55 55
Configure Options and Variables
56 56
===============================
57 57

	
58 58
In step 2 you can customize the actions of configure by setting variables
59 59
and passing options to it. This can be done like this:
60 60
`./configure [OPTION]... [VARIABLE=VALUE]...'
61 61

	
62 62
Below you will find some useful variables and options (see `./configure --help'
63 63
for more):
64 64

	
65 65
CXX='comp'
66 66

	
67 67
  Change the C++ compiler to 'comp'.
68 68

	
69 69
CXXFLAGS='flags'
70 70

	
71 71
  Pass the 'flags' to the compiler. For example CXXFLAGS='-O3 -march=pentium-m'
72 72
  turns on generation of aggressively optimized Pentium-M specific code.
73 73

	
74 74
--prefix=PREFIX
75 75

	
76 76
  Set the installation prefix to PREFIX. By default it is /usr/local.
77 77

	
78 78
--enable-tools
79 79

	
80 80
   Build the programs in the tools subdirectory (default).
81 81

	
82 82
--disable-tools
83 83

	
84 84
   Do not build the programs in the tools subdirectory.
85 85

	
86 86
--with-glpk[=PREFIX]
87 87

	
88 88
   Enable GLPK support (default). You should specify the prefix too if
89 89
   you installed GLPK to some non-standard location (e.g. your home
90 90
   directory). If it is not found, GLPK support will be disabled.
91 91

	
92 92
--with-glpk-includedir=DIR
93 93

	
94 94
   The directory where the GLPK header files are located. This is only
95 95
   useful when the GLPK headers and libraries are not under the same
96 96
   prefix (which is unlikely).
97 97

	
98 98
--with-glpk-libdir=DIR
99 99

	
100 100
   The directory where the GLPK libraries are located. This is only
101 101
   useful when the GLPK headers and libraries are not under the same
102 102
   prefix (which is unlikely).
103 103

	
104 104
--without-glpk
105 105

	
106 106
   Disable GLPK support.
107 107

	
108 108
--with-cplex[=PREFIX]
109 109

	
110 110
   Enable CPLEX support (default). You should specify the prefix too
111 111
   if you installed CPLEX to some non-standard location
112 112
   (e.g. /opt/ilog/cplex75). If it is not found, CPLEX support will be
113 113
   disabled.
114 114

	
115 115
--with-cplex-includedir=DIR
116 116

	
117 117
   The directory where the CPLEX header files are located. This is
118 118
   only useful when the CPLEX headers and libraries are not under the
119 119
   same prefix (e.g.  /usr/local/cplex/cplex75/include).
120 120

	
121 121
--with-cplex-libdir=DIR
122 122

	
123 123
   The directory where the CPLEX libraries are located. This is only
124 124
   useful when the CPLEX headers and libraries are not under the same
125 125
   prefix (e.g.
126 126
   /usr/local/cplex/cplex75/lib/i86_linux2_glibc2.2_gcc3.0/static_pic_mt).
127 127

	
128 128
--without-cplex
129 129

	
130 130
   Disable CPLEX support.
131 131

	
132 132
--with-soplex[=PREFIX]
133 133

	
134 134
   Enable SoPlex support (default). You should specify the prefix too if
135 135
   you installed SoPlex to some non-standard location (e.g. your home
136 136
   directory). If it is not found, SoPlex support will be disabled.
137 137

	
138 138
--with-soplex-includedir=DIR
139 139

	
140 140
   The directory where the SoPlex header files are located. This is only
141 141
   useful when the SoPlex headers and libraries are not under the same
142 142
   prefix (which is unlikely).
143 143

	
144 144
--with-soplex-libdir=DIR
145 145

	
146 146
   The directory where the SoPlex libraries are located. This is only
147 147
   useful when the SoPlex headers and libraries are not under the same
148 148
   prefix (which is unlikely).
149 149

	
150 150
--without-soplex
151 151

	
152 152
   Disable SoPlex support.
153 153

	
154 154
--with-coin[=PREFIX]
155 155

	
156 156
   Enable support for COIN-OR solvers (CLP and CBC). You should
157 157
   specify the prefix too. (by default, COIN-OR tools install
158 158
   themselves to the source code directory). This command enables the
159 159
   solvers that are actually found.
160 160

	
161 161
--with-coin-includedir=DIR
162 162

	
163 163
   The directory where the COIN-OR header files are located. This is
164 164
   only useful when the COIN-OR headers and libraries are not under
165 165
   the same prefix (which is unlikely).
166 166

	
167 167
--with-coin-libdir=DIR
168 168

	
169 169
   The directory where the COIN-OR libraries are located. This is only
170 170
   useful when the COIN-OR headers and libraries are not under the
171 171
   same prefix (which is unlikely).
172 172

	
173 173
--without-coin
174 174

	
175 175
   Disable COIN-OR support.
176

	
177

	
178
Makefile Variables
179
==================
180

	
181
Some Makefile variables are reserved by the GNU Coding Standards for
182
the use of the "user" - the person building the package. For instance,
183
CXX and CXXFLAGS are such variables, and have the same meaning as
184
explained in the previous section. These variables can be set on the
185
command line when invoking `make' like this:
186
`make [VARIABLE=VALUE]...'
187

	
188
WARNINGCXXFLAGS is a non-standard Makefile variable introduced by us
189
to hold several compiler flags related to warnings. Its default value
190
can be overridden when invoking `make'. For example to disable all
191
warning flags use `make WARNINGCXXFLAGS='.
192

	
193
In order to turn off a single flag from the default set of warning
194
flags, you can use the CXXFLAGS variable, since this is passed after
195
WARNINGCXXFLAGS. For example to turn off `-Wold-style-cast' (which is
196
used by default when g++ is detected) you can use
197
`make CXXFLAGS="-g -O2 -Wno-old-style-cast"'.
Ignore white space 6 line context
1 1
ACLOCAL_AMFLAGS = -I m4
2 2

	
3 3
AM_CXXFLAGS = $(WARNINGCXXFLAGS)
4 4

	
5 5
AM_CPPFLAGS = -I$(top_srcdir) -I$(top_builddir)
6 6
LDADD = $(top_builddir)/lemon/libemon.la
7 7

	
8 8
EXTRA_DIST = \
9 9
	AUTHORS \
10 10
	LICENSE \
11 11
	m4/lx_check_cplex.m4 \
12 12
	m4/lx_check_glpk.m4 \
13 13
	m4/lx_check_soplex.m4 \
14 14
	m4/lx_check_coin.m4 \
15 15
	CMakeLists.txt \
16 16
	cmake/FindGhostscript.cmake \
17 17
	cmake/FindCPLEX.cmake \
18 18
	cmake/FindGLPK.cmake \
19 19
	cmake/FindCOIN.cmake \
20 20
	cmake/LEMONConfig.cmake.in \
21 21
	cmake/version.cmake.in \
22 22
	cmake/version.cmake \
23 23
	cmake/nsis/lemon.ico \
24 24
	cmake/nsis/uninstall.ico
25 25

	
26 26
pkgconfigdir = $(libdir)/pkgconfig
27 27
lemondir = $(pkgincludedir)
28 28
bitsdir = $(lemondir)/bits
29 29
conceptdir = $(lemondir)/concepts
30 30
pkgconfig_DATA =
31 31
lib_LTLIBRARIES =
32 32
lemon_HEADERS =
33 33
bits_HEADERS =
34 34
concept_HEADERS =
35 35
noinst_HEADERS =
36 36
noinst_PROGRAMS =
37 37
bin_PROGRAMS =
38 38
check_PROGRAMS =
39 39
dist_bin_SCRIPTS =
40 40
TESTS =
41 41
XFAIL_TESTS =
42 42

	
43 43
include lemon/Makefile.am
44 44
include test/Makefile.am
45 45
include doc/Makefile.am
46 46
include tools/Makefile.am
47
include scripts/Makefile.am
47 48

	
48 49
DIST_SUBDIRS = demo
49 50

	
50 51
demo:
51 52
	$(MAKE) $(AM_MAKEFLAGS) -C demo
52 53

	
53 54
MRPROPERFILES = \
54 55
	aclocal.m4 \
55 56
	config.h.in \
56 57
	config.h.in~ \
57 58
	configure \
58 59
	Makefile.in \
59 60
	build-aux/config.guess \
60 61
	build-aux/config.sub \
61 62
	build-aux/depcomp \
62 63
	build-aux/install-sh \
63 64
	build-aux/ltmain.sh \
64 65
	build-aux/missing \
65 66
	doc/doxygen.log
66 67

	
67 68
mrproper:
68 69
	$(MAKE) $(AM_MAKEFLAGS) maintainer-clean
69 70
	-rm -f $(MRPROPERFILES)
70 71

	
71 72
dist-bz2: dist
72 73
	zcat $(PACKAGE)-$(VERSION).tar.gz | \
73 74
	bzip2 --best -c > $(PACKAGE)-$(VERSION).tar.bz2
74 75

	
75 76
distcheck-bz2: distcheck
76 77
	zcat $(PACKAGE)-$(VERSION).tar.gz | \
77 78
	bzip2 --best -c > $(PACKAGE)-$(VERSION).tar.bz2
78 79

	
79 80
.PHONY: demo mrproper dist-bz2 distcheck-bz2
Ignore white space 8388608 line context
1 1
=====================================================================
2 2
LEMON - a Library for Efficient Modeling and Optimization in Networks
3 3
=====================================================================
4 4

	
5 5
LEMON is an open source library written in C++. It provides
6 6
easy-to-use implementations of common data structures and algorithms
7 7
in the area of optimization and helps implementing new ones. The main
8 8
focus is on graphs and graph algorithms, thus it is especially
9 9
suitable for solving design and optimization problems of
10 10
telecommunication networks. To achieve wide usability its data
11 11
structures and algorithms provide generic interfaces.
12 12

	
13 13
Contents
14 14
========
15 15

	
16 16
LICENSE
17 17

	
18 18
   Copying, distribution and modification conditions and terms.
19 19

	
20
NEWS
21

	
22
   News and version history.
23

	
20 24
INSTALL
21 25

	
22 26
   General building and installation instructions.
23 27

	
24 28
lemon/
25 29

	
26 30
   Source code of LEMON library.
27 31

	
28 32
doc/
29 33

	
30 34
   Documentation of LEMON. The starting page is doc/html/index.html.
31 35

	
32 36
demo/
33 37

	
34 38
   Some example programs to make you easier to get familiar with LEMON.
35 39

	
40
scripts/
41

	
42
   Scripts that make it easier to develop LEMON.
43

	
36 44
test/
37 45

	
38 46
   Programs to check the integrity and correctness of LEMON.
39 47

	
40 48
tools/
41 49

	
42 50
   Various utilities related to LEMON.
Ignore white space 6 line context
1 1
dnl Process this file with autoconf to produce a configure script.
2 2

	
3 3
dnl Version information.
4 4
m4_define([lemon_version_number],
5 5
          [m4_normalize(esyscmd([echo ${LEMON_VERSION}]))])
6 6
dnl m4_define([lemon_version_number], [])
7 7
m4_define([lemon_hg_path], [m4_normalize(esyscmd([./scripts/chg-len.py]))])
8 8
m4_define([lemon_hg_revision], [m4_normalize(esyscmd([hg id -i 2> /dev/null]))])
9 9
m4_define([lemon_version], [ifelse(lemon_version_number(),
10 10
                           [],
11 11
                           [ifelse(lemon_hg_revision(),
12 12
                           [],
13 13
                           [hg-tip],
14 14
                           [lemon_hg_path().lemon_hg_revision()])],
15 15
                           [lemon_version_number()])])
16 16

	
17 17
AC_PREREQ([2.59])
18 18
AC_INIT([LEMON], [lemon_version()], [lemon-user@lemon.cs.elte.hu], [lemon])
19 19
AC_CONFIG_AUX_DIR([build-aux])
20 20
AC_CONFIG_MACRO_DIR([m4])
21 21
AM_INIT_AUTOMAKE([-Wall -Werror foreign subdir-objects nostdinc])
22 22
AC_CONFIG_SRCDIR([lemon/list_graph.h])
23 23
AC_CONFIG_HEADERS([config.h lemon/config.h])
24 24

	
25 25
AC_DEFINE([LEMON_VERSION], [lemon_version()], [The version string])
26 26

	
27 27
dnl Do compilation tests using the C++ compiler.
28 28
AC_LANG([C++])
29 29

	
30 30
dnl Check the existence of long long type.
31 31
AC_CHECK_TYPE(long long, [long_long_found=yes], [long_long_found=no])
32 32
if test x"$long_long_found" = x"yes"; then
33 33
  AC_DEFINE([LEMON_HAVE_LONG_LONG], [1], [Define to 1 if you have long long.])
34 34
fi
35 35

	
36 36
dnl Checks for programs.
37 37
AC_PROG_CXX
38 38
AC_PROG_CXXCPP
39 39
AC_PROG_INSTALL
40 40
AC_DISABLE_SHARED
41 41
AC_PROG_LIBTOOL
42 42

	
43 43
AC_CHECK_PROG([doxygen_found],[doxygen],[yes],[no])
44
AC_CHECK_PROG([python_found],[python],[yes],[no])
44 45
AC_CHECK_PROG([gs_found],[gs],[yes],[no])
45 46

	
46 47
dnl Detect Intel compiler.
47 48
AC_MSG_CHECKING([whether we are using the Intel C++ compiler])
48 49
AC_COMPILE_IFELSE([#ifndef __INTEL_COMPILER
49 50
choke me
50 51
#endif], [ICC=[yes]], [ICC=[no]])
51 52
if test x"$ICC" = x"yes"; then
52 53
  AC_MSG_RESULT([yes])
53 54
else
54 55
  AC_MSG_RESULT([no])
55 56
fi
56 57

	
57 58
dnl Set custom compiler flags when using g++.
58 59
if test "$GXX" = yes -a "$ICC" = no; then
59 60
  WARNINGCXXFLAGS="-Wall -W -Wall -W -Wunused -Wformat=2 -Wctor-dtor-privacy -Wnon-virtual-dtor -Wno-char-subscripts -Wwrite-strings -Wno-char-subscripts -Wreturn-type -Wcast-qual -Wcast-align -Wsign-promo -Woverloaded-virtual -ansi -fno-strict-aliasing -Wold-style-cast -Wno-unknown-pragmas"
60 61
fi
61 62
AC_SUBST([WARNINGCXXFLAGS])
62 63

	
63 64
dnl Checks for libraries.
64 65
LX_CHECK_GLPK
65 66
LX_CHECK_CPLEX
66 67
LX_CHECK_SOPLEX
67 68
LX_CHECK_COIN
68 69

	
69 70
AM_CONDITIONAL([HAVE_LP], [test x"$lx_lp_found" = x"yes"])
70 71
AM_CONDITIONAL([HAVE_MIP], [test x"$lx_mip_found" = x"yes"])
71 72

	
72 73
dnl Disable/enable building the binary tools.
73 74
AC_ARG_ENABLE([tools],
74 75
AS_HELP_STRING([--enable-tools], [build additional tools @<:@default@:>@])
75 76
AS_HELP_STRING([--disable-tools], [do not build additional tools]),
76 77
              [], [enable_tools=yes])
77 78
AC_MSG_CHECKING([whether to build the additional tools])
78 79
if test x"$enable_tools" != x"no"; then
79 80
  AC_MSG_RESULT([yes])
80 81
else
81 82
  AC_MSG_RESULT([no])
82 83
fi
83 84
AM_CONDITIONAL([WANT_TOOLS], [test x"$enable_tools" != x"no"])
84 85

	
86
dnl Support for running test cases using valgrind.
87
use_valgrind=no
88
AC_ARG_ENABLE([valgrind],
89
AS_HELP_STRING([--enable-valgrind], [use valgrind when running tests]),
90
              [use_valgrind=yes])
91

	
92
if [[ "$use_valgrind" = "yes" ]]; then
93
  AC_CHECK_PROG(HAVE_VALGRIND, valgrind, yes, no)
94

	
95
  if [[ "$HAVE_VALGRIND" = "no" ]]; then
96
    AC_MSG_ERROR([Valgrind not found in PATH.])
97
  fi
98
fi
99
AM_CONDITIONAL(USE_VALGRIND, [test "$use_valgrind" = "yes"])
100

	
85 101
dnl Checks for header files.
86 102
AC_CHECK_HEADERS(limits.h sys/time.h sys/times.h unistd.h)
87 103

	
88 104
dnl Checks for typedefs, structures, and compiler characteristics.
89 105
AC_C_CONST
90 106
AC_C_INLINE
91 107
AC_TYPE_SIZE_T
92 108
AC_HEADER_TIME
93 109
AC_STRUCT_TM
94 110

	
95 111
dnl Checks for library functions.
96 112
AC_HEADER_STDC
97 113
AC_CHECK_FUNCS(gettimeofday times ctime_r)
98 114

	
99 115
dnl Add dependencies on files generated by configure.
100 116
AC_SUBST([CONFIG_STATUS_DEPENDENCIES],
101 117
  ['$(top_srcdir)/doc/Doxyfile.in $(top_srcdir)/doc/mainpage.dox.in $(top_srcdir)/lemon/lemon.pc.in $(top_srcdir)/cmake/version.cmake.in'])
102 118

	
103 119
AC_CONFIG_FILES([
104 120
Makefile
105 121
demo/Makefile
106 122
cmake/version.cmake
107 123
doc/Doxyfile
108 124
doc/mainpage.dox
109 125
lemon/lemon.pc
110 126
])
111 127

	
112 128
AC_OUTPUT
113 129

	
114 130
echo
115 131
echo '****************************** SUMMARY ******************************'
116 132
echo
117 133
echo Package version............... : $PACKAGE-$VERSION
118 134
echo
119 135
echo C++ compiler.................. : $CXX
120 136
echo C++ compiles flags............ : $WARNINGCXXFLAGS $CXXFLAGS
121 137
echo
122 138
echo Compiler supports long long... : $long_long_found
123 139
echo
124 140
echo GLPK support.................. : $lx_glpk_found
125 141
echo CPLEX support................. : $lx_cplex_found
126 142
echo SOPLEX support................ : $lx_soplex_found
127 143
echo CLP support................... : $lx_clp_found
128 144
echo CBC support................... : $lx_cbc_found
129 145
echo
130 146
echo Build additional tools........ : $enable_tools
147
echo Use valgrind for tests........ : $use_valgrind
131 148
echo
132 149
echo The packace will be installed in
133 150
echo -n '  '
134 151
echo $prefix.
135 152
echo
136 153
echo '*********************************************************************'
137 154

	
138 155
echo
139 156
echo Configure complete, now type \'make\' and then \'make install\'.
140 157
echo
Ignore white space 6 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-2010
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 demos
20 20
///\file
21 21
///\brief Argument parser demo
22 22
///
23 23
/// This example shows how the argument parser can be used.
24 24
///
25 25
/// \include arg_parser_demo.cc
26 26

	
27 27
#include <lemon/arg_parser.h>
28 28

	
29 29
using namespace lemon;
30 30
int main(int argc, char **argv)
31 31
{
32 32
  // Initialize the argument parser
33 33
  ArgParser ap(argc, argv);
34 34
  int i;
35 35
  std::string s;
36 36
  double d = 1.0;
37 37
  bool b, nh;
38 38
  bool g1, g2, g3;
39 39

	
40 40
  // Add a mandatory integer option with storage reference
41 41
  ap.refOption("n", "An integer input.", i, true);
42 42
  // Add a double option with storage reference (the default value is 1.0)
43 43
  ap.refOption("val", "A double input.", d);
44 44
  // Add a double option without storage reference (the default value is 3.14)
45 45
  ap.doubleOption("val2", "A double input.", 3.14);
46 46
  // Set synonym for -val option
47 47
  ap.synonym("vals", "val");
48 48
  // Add a string option
49 49
  ap.refOption("name", "A string input.", s);
50 50
  // Add bool options
51 51
  ap.refOption("f", "A switch.", b)
52 52
    .refOption("nohelp", "", nh)
53 53
    .refOption("gra", "Choice A", g1)
54 54
    .refOption("grb", "Choice B", g2)
55 55
    .refOption("grc", "Choice C", g3);
56 56
  // Bundle -gr* options into a group
57 57
  ap.optionGroup("gr", "gra")
58 58
    .optionGroup("gr", "grb")
59 59
    .optionGroup("gr", "grc");
60 60
  // Set the group mandatory
61 61
  ap.mandatoryGroup("gr");
62 62
  // Set the options of the group exclusive (only one option can be given)
63 63
  ap.onlyOneGroup("gr");
64 64
  // Add non-parsed arguments (e.g. input files)
65 65
  ap.other("infile", "The input file.")
66 66
    .other("...");
67 67

	
68
  // Throw an exception when problems occurs. The default behavior is to
69
  // exit(1) on these cases, but this makes Valgrind falsely warn
70
  // about memory leaks.
71
  ap.throwOnProblems();
72

	
68 73
  // Perform the parsing process
69 74
  // (in case of any error it terminates the program)
70
  ap.parse();
75
  // The try {} construct is necessary only if the ap.trowOnProblems()
76
  // setting is in use.
77
  try {
78
    ap.parse();
79
  } catch (ArgParserException &) { return 1; }
71 80

	
72 81
  // Check each option if it has been given and print its value
73 82
  std::cout << "Parameters of '" << ap.commandName() << "':\n";
74 83

	
75 84
  std::cout << "  Value of -n: " << i << std::endl;
76 85
  if(ap.given("val")) std::cout << "  Value of -val: " << d << std::endl;
77 86
  if(ap.given("val2")) {
78 87
    d = ap["val2"];
79 88
    std::cout << "  Value of -val2: " << d << std::endl;
80 89
  }
81 90
  if(ap.given("name")) std::cout << "  Value of -name: " << s << std::endl;
82 91
  if(ap.given("f")) std::cout << "  -f is given\n";
83 92
  if(ap.given("nohelp")) std::cout << "  Value of -nohelp: " << nh << std::endl;
84 93
  if(ap.given("gra")) std::cout << "  -gra is given\n";
85 94
  if(ap.given("grb")) std::cout << "  -grb is given\n";
86 95
  if(ap.given("grc")) std::cout << "  -grc is given\n";
87 96

	
88 97
  switch(ap.files().size()) {
89 98
  case 0:
90 99
    std::cout << "  No file argument was given.\n";
91 100
    break;
92 101
  case 1:
93 102
    std::cout << "  1 file argument was given. It is:\n";
94 103
    break;
95 104
  default:
96 105
    std::cout << "  "
97 106
              << ap.files().size() << " file arguments were given. They are:\n";
98 107
  }
99 108
  for(unsigned int i=0;i<ap.files().size();++i)
100 109
    std::cout << "    '" << ap.files()[i] << "'\n";
101 110

	
102 111
  return 0;
103 112
}
Ignore white space 6 line context
1 1
SET(PACKAGE_NAME ${PROJECT_NAME})
2 2
SET(PACKAGE_VERSION ${PROJECT_VERSION})
3 3
SET(abs_top_srcdir ${PROJECT_SOURCE_DIR})
4 4
SET(abs_top_builddir ${PROJECT_BINARY_DIR})
5 5

	
6 6
SET(LEMON_DOC_SOURCE_BROWSER "NO" CACHE STRING "Include source into the doc (YES/NO).")
7 7

	
8 8
CONFIGURE_FILE(
9 9
  ${PROJECT_SOURCE_DIR}/doc/Doxyfile.in
10 10
  ${PROJECT_BINARY_DIR}/doc/Doxyfile
11 11
  @ONLY
12 12
)
13 13

	
14 14
CONFIGURE_FILE(
15 15
  ${PROJECT_SOURCE_DIR}/doc/mainpage.dox.in
16 16
  ${PROJECT_BINARY_DIR}/doc/mainpage.dox
17 17
  @ONLY
18 18
)
19 19

	
20
IF(DOXYGEN_EXECUTABLE AND GHOSTSCRIPT_EXECUTABLE)
20
IF(DOXYGEN_EXECUTABLE AND PYTHONINTERP_FOUND AND GHOSTSCRIPT_EXECUTABLE)
21 21
  FILE(MAKE_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/)
22 22
  SET(GHOSTSCRIPT_OPTIONS -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4 -sDEVICE=pngalpha)
23 23
  ADD_CUSTOM_TARGET(html
24 24
    COMMAND ${CMAKE_COMMAND} -E remove_directory gen-images
25 25
    COMMAND ${CMAKE_COMMAND} -E make_directory gen-images
26 26
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/bipartite_matching.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_matching.eps
27 27
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/bipartite_partitions.png ${CMAKE_CURRENT_SOURCE_DIR}/images/bipartite_partitions.eps
28 28
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/connected_components.eps
29 29
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/edge_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/edge_biconnected_components.eps
30 30
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/grid_graph.png ${CMAKE_CURRENT_SOURCE_DIR}/images/grid_graph.eps
31
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/matching.png ${CMAKE_CURRENT_SOURCE_DIR}/images/matching.eps
31 32
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/node_biconnected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/node_biconnected_components.eps
32 33
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_0.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_0.eps
33 34
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_1.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_1.eps
34 35
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_2.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_2.eps
35 36
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_3.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_3.eps
36 37
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/nodeshape_4.png ${CMAKE_CURRENT_SOURCE_DIR}/images/nodeshape_4.eps
38
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/planar.png ${CMAKE_CURRENT_SOURCE_DIR}/images/planar.eps
37 39
    COMMAND ${GHOSTSCRIPT_EXECUTABLE} ${GHOSTSCRIPT_OPTIONS} -r18 -sOutputFile=gen-images/strongly_connected_components.png ${CMAKE_CURRENT_SOURCE_DIR}/images/strongly_connected_components.eps
38 40
    COMMAND ${CMAKE_COMMAND} -E remove_directory html
41
    COMMAND ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/scripts/bib2dox.py ${CMAKE_CURRENT_SOURCE_DIR}/references.bib >references.dox
39 42
    COMMAND ${DOXYGEN_EXECUTABLE} Doxyfile
40 43
    WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
41 44
  )
42 45

	
43 46
  SET_TARGET_PROPERTIES(html PROPERTIES PROJECT_LABEL BUILD_DOC)
44 47

	
45 48
  IF(UNIX)
46 49
    INSTALL(
47 50
      DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
48 51
      DESTINATION share/doc/lemon/html
49 52
      COMPONENT html_documentation
50 53
    )
51 54
  ELSEIF(WIN32)
52 55
    INSTALL(
53 56
      DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}/html/
54 57
      DESTINATION doc
55 58
      COMPONENT html_documentation
56 59
    )
57 60
  ENDIF()
58 61

	
59 62
ENDIF()
60 63

	
61 64
IF(WGET_FOUND)
62 65
ADD_CUSTOM_TARGET(update-external-tags
63 66
  COMMAND ${CMAKE_COMMAND} -E make_directory dl
64 67
  # COMMAND ${CMAKE_COMMAND} -E copy libstdc++.tag dl
65 68
  COMMAND ${WGET_EXECUTABLE} wget -P dl -N libstdc++.tag.tmp http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/libstdc++.tag
66 69
  COMMAND ${CMAKE_COMMAND} -E rename dl/libstdc++.tag libstdc++.tag
67 70
  COMMAND ${CMAKE_COMMAND} -E remove dl/libstdc++.tag
68 71
  COMMAND ${CMAKE_COMMAND} -E remove_directory dl
69 72
  WORKING_DIRECTORY ${CMAKE_CURRENT_BINARY_DIR}
70 73
  )
71 74
ENDIF()
Ignore white space 6 line context
1 1
# Doxyfile 1.7.3
2 2

	
3 3
#---------------------------------------------------------------------------
4 4
# Project related configuration options
5 5
#---------------------------------------------------------------------------
6 6
DOXYFILE_ENCODING      = UTF-8
7 7
PROJECT_NAME           = 
8 8
PROJECT_NUMBER         = 
9 9
PROJECT_BRIEF          =
10 10
PROJECT_LOGO           =
11 11
OUTPUT_DIRECTORY       = 
12 12
CREATE_SUBDIRS         = NO
13 13
OUTPUT_LANGUAGE        = English
14 14
BRIEF_MEMBER_DESC      = YES
15 15
REPEAT_BRIEF           = NO
16 16
ABBREVIATE_BRIEF       = 
17 17
ALWAYS_DETAILED_SEC    = NO
18 18
INLINE_INHERITED_MEMB  = NO
19 19
FULL_PATH_NAMES        = YES
20 20
STRIP_FROM_PATH        = "@abs_top_srcdir@"
21 21
STRIP_FROM_INC_PATH    = "@abs_top_srcdir@"
22 22
SHORT_NAMES            = YES
23 23
JAVADOC_AUTOBRIEF      = NO
24 24
QT_AUTOBRIEF           = NO
25 25
MULTILINE_CPP_IS_BRIEF = NO
26 26
INHERIT_DOCS           = NO
27 27
SEPARATE_MEMBER_PAGES  = NO
28 28
TAB_SIZE               = 8
29 29
ALIASES                = 
30 30
OPTIMIZE_OUTPUT_FOR_C  = NO
31 31
OPTIMIZE_OUTPUT_JAVA   = NO
32 32
OPTIMIZE_FOR_FORTRAN   = NO
33 33
OPTIMIZE_OUTPUT_VHDL   = NO
34 34
EXTENSION_MAPPING      =
35 35
BUILTIN_STL_SUPPORT    = YES
36 36
CPP_CLI_SUPPORT        = NO
37 37
SIP_SUPPORT            = NO
38 38
IDL_PROPERTY_SUPPORT   = YES
39 39
DISTRIBUTE_GROUP_DOC   = NO
40 40
SUBGROUPING            = YES
41 41
TYPEDEF_HIDES_STRUCT   = NO
42 42
SYMBOL_CACHE_SIZE      = 0
43 43
#---------------------------------------------------------------------------
44 44
# Build related configuration options
45 45
#---------------------------------------------------------------------------
46 46
EXTRACT_ALL            = NO
47 47
EXTRACT_PRIVATE        = YES
48 48
EXTRACT_STATIC         = YES
49 49
EXTRACT_LOCAL_CLASSES  = NO
50 50
EXTRACT_LOCAL_METHODS  = NO
51 51
EXTRACT_ANON_NSPACES   = NO
52 52
HIDE_UNDOC_MEMBERS     = YES
53 53
HIDE_UNDOC_CLASSES     = YES
54 54
HIDE_FRIEND_COMPOUNDS  = NO
55 55
HIDE_IN_BODY_DOCS      = NO
56 56
INTERNAL_DOCS          = NO
57 57
CASE_SENSE_NAMES       = YES
58 58
HIDE_SCOPE_NAMES       = YES
59 59
SHOW_INCLUDE_FILES     = YES
60 60
FORCE_LOCAL_INCLUDES   = NO
61 61
INLINE_INFO            = YES
62 62
SORT_MEMBER_DOCS       = NO
63 63
SORT_BRIEF_DOCS        = NO
64 64
SORT_MEMBERS_CTORS_1ST = NO
65 65
SORT_GROUP_NAMES       = NO
66 66
SORT_BY_SCOPE_NAME     = NO
67 67
STRICT_PROTO_MATCHING  = NO
68 68
GENERATE_TODOLIST      = YES
69 69
GENERATE_TESTLIST      = YES
70 70
GENERATE_BUGLIST       = YES
71 71
GENERATE_DEPRECATEDLIST= YES
72 72
ENABLED_SECTIONS       = 
73 73
MAX_INITIALIZER_LINES  = 5
74 74
SHOW_USED_FILES        = NO
75 75
SHOW_DIRECTORIES       = YES
76 76
SHOW_FILES             = YES
77 77
SHOW_NAMESPACES        = YES
78 78
FILE_VERSION_FILTER    = 
79 79
LAYOUT_FILE            = "@abs_top_srcdir@/doc/DoxygenLayout.xml"
80 80
#---------------------------------------------------------------------------
81 81
# configuration options related to warning and progress messages
82 82
#---------------------------------------------------------------------------
83 83
QUIET                  = NO
84 84
WARNINGS               = YES
85 85
WARN_IF_UNDOCUMENTED   = YES
86 86
WARN_IF_DOC_ERROR      = YES
87 87
WARN_NO_PARAMDOC       = NO
88 88
WARN_FORMAT            = "$file:$line: $text"
89 89
WARN_LOGFILE           = doxygen.log
90 90
#---------------------------------------------------------------------------
91 91
# configuration options related to the input files
92 92
#---------------------------------------------------------------------------
93 93
INPUT                  = "@abs_top_srcdir@/doc" \
94 94
                         "@abs_top_srcdir@/lemon" \
95 95
                         "@abs_top_srcdir@/lemon/bits" \
96 96
                         "@abs_top_srcdir@/lemon/concepts" \
97 97
                         "@abs_top_srcdir@/demo" \
98 98
                         "@abs_top_srcdir@/tools" \
99 99
                         "@abs_top_srcdir@/test/test_tools.h" \
100
                         "@abs_top_builddir@/doc/mainpage.dox"
100
                         "@abs_top_builddir@/doc/mainpage.dox" \
101
                         "@abs_top_builddir@/doc/references.dox"
101 102
INPUT_ENCODING         = UTF-8
102 103
FILE_PATTERNS          = *.h \
103 104
                         *.cc \
104 105
                         *.dox
105 106
RECURSIVE              = NO
106 107
EXCLUDE                = 
107 108
EXCLUDE_SYMLINKS       = NO
108 109
EXCLUDE_PATTERNS       = 
109 110
EXCLUDE_SYMBOLS        = 
110 111
EXAMPLE_PATH           = "@abs_top_srcdir@/demo" \
111 112
                         "@abs_top_srcdir@/LICENSE" \
112 113
                         "@abs_top_srcdir@/doc"
113 114
EXAMPLE_PATTERNS       = 
114 115
EXAMPLE_RECURSIVE      = NO
115 116
IMAGE_PATH             = "@abs_top_srcdir@/doc/images" \
116 117
                         "@abs_top_builddir@/doc/gen-images"
117 118
INPUT_FILTER           = 
118 119
FILTER_PATTERNS        = 
119 120
FILTER_SOURCE_FILES    = NO
120 121
FILTER_SOURCE_PATTERNS =
121 122
#---------------------------------------------------------------------------
122 123
# configuration options related to source browsing
123 124
#---------------------------------------------------------------------------
124 125
SOURCE_BROWSER         = @LEMON_DOC_SOURCE_BROWSER@
125 126
INLINE_SOURCES         = NO
126 127
STRIP_CODE_COMMENTS    = YES
127 128
REFERENCED_BY_RELATION = NO
128 129
REFERENCES_RELATION    = NO
129 130
REFERENCES_LINK_SOURCE = YES
130 131
USE_HTAGS              = NO
131 132
VERBATIM_HEADERS       = NO
132 133
#---------------------------------------------------------------------------
133 134
# configuration options related to the alphabetical class index
134 135
#---------------------------------------------------------------------------
135 136
ALPHABETICAL_INDEX     = YES
136 137
COLS_IN_ALPHA_INDEX    = 2
137 138
IGNORE_PREFIX          = 
138 139
#---------------------------------------------------------------------------
139 140
# configuration options related to the HTML output
140 141
#---------------------------------------------------------------------------
141 142
GENERATE_HTML          = YES
142 143
HTML_OUTPUT            = html
143 144
HTML_FILE_EXTENSION    = .html
144 145
HTML_HEADER            = 
145 146
HTML_FOOTER            = 
146 147
HTML_STYLESHEET        = 
147 148
HTML_COLORSTYLE_HUE    = 220
148 149
HTML_COLORSTYLE_SAT    = 100
149 150
HTML_COLORSTYLE_GAMMA  = 80
150 151
HTML_TIMESTAMP         = YES
151 152
HTML_ALIGN_MEMBERS     = YES
152 153
HTML_DYNAMIC_SECTIONS  = YES
153 154
GENERATE_DOCSET        = NO
154 155
DOCSET_FEEDNAME        = "Doxygen generated docs"
155 156
DOCSET_BUNDLE_ID       = org.doxygen.Project
156 157
DOCSET_PUBLISHER_ID    = org.doxygen.Publisher
157 158
DOCSET_PUBLISHER_NAME  = Publisher
158 159
GENERATE_HTMLHELP      = NO
159 160
CHM_FILE               = 
160 161
HHC_LOCATION           = 
161 162
GENERATE_CHI           = NO
162 163
CHM_INDEX_ENCODING     = 
163 164
BINARY_TOC             = NO
164 165
TOC_EXPAND             = NO
165 166
GENERATE_QHP           = NO
166 167
QCH_FILE               = 
167 168
QHP_NAMESPACE          = org.doxygen.Project
168 169
QHP_VIRTUAL_FOLDER     = doc
169 170
QHP_CUST_FILTER_NAME   =
170 171
QHP_CUST_FILTER_ATTRS  =
171 172
QHP_SECT_FILTER_ATTRS  =
172 173
QHG_LOCATION           = 
173 174
GENERATE_ECLIPSEHELP   = NO
174 175
ECLIPSE_DOC_ID         = org.doxygen.Project
175 176
DISABLE_INDEX          = NO
176 177
ENUM_VALUES_PER_LINE   = 4
177 178
GENERATE_TREEVIEW      = NO
178 179
USE_INLINE_TREES       = NO
179 180
TREEVIEW_WIDTH         = 250
180 181
EXT_LINKS_IN_WINDOW    = NO
181 182
FORMULA_FONTSIZE       = 10
182 183
FORMULA_TRANSPARENT    = YES
183 184
USE_MATHJAX            = NO
184 185
MATHJAX_RELPATH        = http://www.mathjax.org/mathjax
185 186
SEARCHENGINE           = YES
186 187
SERVER_BASED_SEARCH    = NO
187 188
#---------------------------------------------------------------------------
188 189
# configuration options related to the LaTeX output
189 190
#---------------------------------------------------------------------------
190 191
GENERATE_LATEX         = NO
191 192
LATEX_OUTPUT           = latex
192 193
LATEX_CMD_NAME         = latex
193 194
MAKEINDEX_CMD_NAME     = makeindex
194 195
COMPACT_LATEX          = YES
195 196
PAPER_TYPE             = a4wide
196 197
EXTRA_PACKAGES         = amsmath \
197 198
                         amssymb
198 199
LATEX_HEADER           = 
199 200
PDF_HYPERLINKS         = YES
200 201
USE_PDFLATEX           = YES
201 202
LATEX_BATCHMODE        = NO
202 203
LATEX_HIDE_INDICES     = NO
203 204
LATEX_SOURCE_CODE      = NO
204 205
#---------------------------------------------------------------------------
205 206
# configuration options related to the RTF output
206 207
#---------------------------------------------------------------------------
207 208
GENERATE_RTF           = NO
208 209
RTF_OUTPUT             = rtf
209 210
COMPACT_RTF            = NO
210 211
RTF_HYPERLINKS         = NO
211 212
RTF_STYLESHEET_FILE    = 
212 213
RTF_EXTENSIONS_FILE    = 
213 214
#---------------------------------------------------------------------------
214 215
# configuration options related to the man page output
215 216
#---------------------------------------------------------------------------
216 217
GENERATE_MAN           = NO
217 218
MAN_OUTPUT             = man
218 219
MAN_EXTENSION          = .3
219 220
MAN_LINKS              = NO
220 221
#---------------------------------------------------------------------------
221 222
# configuration options related to the XML output
222 223
#---------------------------------------------------------------------------
223 224
GENERATE_XML           = NO
224 225
XML_OUTPUT             = xml
225 226
XML_SCHEMA             = 
226 227
XML_DTD                = 
227 228
XML_PROGRAMLISTING     = YES
228 229
#---------------------------------------------------------------------------
229 230
# configuration options for the AutoGen Definitions output
230 231
#---------------------------------------------------------------------------
231 232
GENERATE_AUTOGEN_DEF   = NO
232 233
#---------------------------------------------------------------------------
233 234
# configuration options related to the Perl module output
234 235
#---------------------------------------------------------------------------
235 236
GENERATE_PERLMOD       = NO
236 237
PERLMOD_LATEX          = NO
237 238
PERLMOD_PRETTY         = YES
238 239
PERLMOD_MAKEVAR_PREFIX = 
239 240
#---------------------------------------------------------------------------
240 241
# Configuration options related to the preprocessor   
241 242
#---------------------------------------------------------------------------
242 243
ENABLE_PREPROCESSING   = YES
243 244
MACRO_EXPANSION        = NO
244 245
EXPAND_ONLY_PREDEF     = NO
245 246
SEARCH_INCLUDES        = YES
246 247
INCLUDE_PATH           = 
247 248
INCLUDE_FILE_PATTERNS  = 
248 249
PREDEFINED             = DOXYGEN
249 250
EXPAND_AS_DEFINED      = 
250 251
SKIP_FUNCTION_MACROS   = YES
251 252
#---------------------------------------------------------------------------
252 253
# Configuration::additions related to external references
253 254
#---------------------------------------------------------------------------
254 255
TAGFILES               = "@abs_top_builddir@/doc/libstdc++.tag = http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/  "
255 256
GENERATE_TAGFILE       = html/lemon.tag
256 257
ALLEXTERNALS           = NO
257 258
EXTERNAL_GROUPS        = NO
258 259
PERL_PATH              = /usr/bin/perl
259 260
#---------------------------------------------------------------------------
260 261
# Configuration options related to the dot tool   
261 262
#---------------------------------------------------------------------------
262 263
CLASS_DIAGRAMS         = YES
263 264
MSCGEN_PATH            = 
264 265
HIDE_UNDOC_RELATIONS   = YES
265 266
HAVE_DOT               = YES
266 267
DOT_NUM_THREADS        = 0
267 268
DOT_FONTNAME           = FreeSans
268 269
DOT_FONTSIZE           = 10
269 270
DOT_FONTPATH           = 
270 271
CLASS_GRAPH            = YES
271 272
COLLABORATION_GRAPH    = NO
272 273
GROUP_GRAPHS           = NO
273 274
UML_LOOK               = NO
274 275
TEMPLATE_RELATIONS     = NO
275 276
INCLUDE_GRAPH          = NO
276 277
INCLUDED_BY_GRAPH      = NO
277 278
CALL_GRAPH             = NO
278 279
CALLER_GRAPH           = NO
279 280
GRAPHICAL_HIERARCHY    = NO
280 281
DIRECTORY_GRAPH        = NO
281 282
DOT_IMAGE_FORMAT       = png
282 283
DOT_PATH               = 
283 284
DOTFILE_DIRS           = 
284 285
MSCFILE_DIRS           =
285 286
DOT_GRAPH_MAX_NODES    = 50
286 287
MAX_DOT_GRAPH_DEPTH    = 0
287 288
DOT_TRANSPARENT        = NO
288 289
DOT_MULTI_TARGETS      = NO
289 290
GENERATE_LEGEND        = YES
290 291
DOT_CLEANUP            = YES
Ignore white space 6 line context
1 1
EXTRA_DIST += \
2 2
	doc/Doxyfile.in \
3 3
	doc/DoxygenLayout.xml \
4 4
	doc/coding_style.dox \
5 5
	doc/dirs.dox \
6 6
	doc/groups.dox \
7 7
	doc/lgf.dox \
8 8
	doc/license.dox \
9 9
	doc/mainpage.dox \
10 10
	doc/migration.dox \
11 11
	doc/min_cost_flow.dox \
12 12
	doc/named-param.dox \
13 13
	doc/namespaces.dox \
14 14
	doc/html \
15 15
	doc/CMakeLists.txt
16 16

	
17 17
DOC_EPS_IMAGES18 = \
18 18
	grid_graph.eps \
19 19
	nodeshape_0.eps \
20 20
	nodeshape_1.eps \
21 21
	nodeshape_2.eps \
22 22
	nodeshape_3.eps \
23 23
	nodeshape_4.eps
24 24

	
25 25
DOC_EPS_IMAGES27 = \
26 26
	bipartite_matching.eps \
27 27
	bipartite_partitions.eps \
28 28
	connected_components.eps \
29 29
	edge_biconnected_components.eps \
30
	matching.eps \
30 31
	node_biconnected_components.eps \
32
	planar.eps \
31 33
	strongly_connected_components.eps
32 34

	
33 35
DOC_EPS_IMAGES = \
34 36
	$(DOC_EPS_IMAGES18) \
35 37
	$(DOC_EPS_IMAGES27)
36 38

	
37 39
DOC_PNG_IMAGES = \
38 40
	$(DOC_EPS_IMAGES:%.eps=doc/gen-images/%.png)
39 41

	
40 42
EXTRA_DIST += $(DOC_EPS_IMAGES:%=doc/images/%)
41 43

	
42 44
doc/html:
43 45
	$(MAKE) $(AM_MAKEFLAGS) html
44 46

	
45 47
GS_COMMAND=gs -dNOPAUSE -dBATCH -q -dEPSCrop -dTextAlphaBits=4 -dGraphicsAlphaBits=4
46 48

	
47 49
$(DOC_EPS_IMAGES18:%.eps=doc/gen-images/%.png): doc/gen-images/%.png: doc/images/%.eps
48 50
	-mkdir doc/gen-images
49 51
	if test ${gs_found} = yes; then \
50 52
	  $(GS_COMMAND) -sDEVICE=pngalpha -r18 -sOutputFile=$@ $<; \
51 53
	else \
52 54
	  echo; \
53 55
	  echo "Ghostscript not found."; \
54 56
	  echo; \
55 57
	  exit 1; \
56 58
	fi
57 59

	
58 60
$(DOC_EPS_IMAGES27:%.eps=doc/gen-images/%.png): doc/gen-images/%.png: doc/images/%.eps
59 61
	-mkdir doc/gen-images
60 62
	if test ${gs_found} = yes; then \
61 63
	  $(GS_COMMAND) -sDEVICE=pngalpha -r27 -sOutputFile=$@ $<; \
62 64
	else \
63 65
	  echo; \
64 66
	  echo "Ghostscript not found."; \
65 67
	  echo; \
66 68
	  exit 1; \
67 69
	fi
68 70

	
69
html-local: $(DOC_PNG_IMAGES)
71
references.dox: doc/references.bib
72
	if test ${python_found} = yes; then \
73
	  cd doc; \
74
	  python @abs_top_srcdir@/scripts/bib2dox.py @abs_top_builddir@/$< >$@; \
75
	  cd ..; \
76
	else \
77
	  echo; \
78
	  echo "Python not found."; \
79
	  echo; \
80
	  exit 1; \
81
	fi
82

	
83
html-local: $(DOC_PNG_IMAGES) references.dox
70 84
	if test ${doxygen_found} = yes; then \
71 85
	  cd doc; \
72 86
	  doxygen Doxyfile; \
73 87
	  cd ..; \
74 88
	else \
75 89
	  echo; \
76 90
	  echo "Doxygen not found."; \
77 91
	  echo; \
78 92
	  exit 1; \
79 93
	fi
80 94

	
81 95
clean-local:
82 96
	-rm -rf doc/html
83 97
	-rm -f doc/doxygen.log
84 98
	-rm -f $(DOC_PNG_IMAGES)
85 99
	-rm -rf doc/gen-images
86 100

	
87 101
update-external-tags:
88 102
	wget -O doc/libstdc++.tag.tmp http://gcc.gnu.org/onlinedocs/libstdc++/latest-doxygen/libstdc++.tag && \
89 103
	mv doc/libstdc++.tag.tmp doc/libstdc++.tag || \
90 104
	rm doc/libstdc++.tag.tmp
91 105

	
92 106
install-html-local: doc/html
93 107
	@$(NORMAL_INSTALL)
94 108
	$(mkinstalldirs) $(DESTDIR)$(htmldir)/html
95 109
	for p in doc/html/*.{html,css,png,map,gif,tag} ; do \
96 110
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
97 111
	  echo " $(INSTALL_DATA) $$p $(DESTDIR)$(htmldir)/html/$$f"; \
98 112
	  $(INSTALL_DATA) $$p $(DESTDIR)$(htmldir)/html/$$f; \
99 113
	done
100 114

	
101 115
uninstall-local:
102 116
	@$(NORMAL_UNINSTALL)
103 117
	for p in doc/html/*.{html,css,png,map,gif,tag} ; do \
104 118
	  f="`echo $$p | sed -e 's|^.*/||'`"; \
105 119
	  echo " rm -f $(DESTDIR)$(htmldir)/html/$$f"; \
106 120
	  rm -f $(DESTDIR)$(htmldir)/html/$$f; \
107 121
	done
108 122

	
109 123
.PHONY: update-external-tags
Ignore white space 6 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-2010
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
@defgroup datas Data Structures
23 23
This group contains the several data structures implemented in LEMON.
24 24
*/
25 25

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

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

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

	
45 45
Alteration of standard containers need a very limited number of
46 46
operations, these together satisfy the everyday requirements.
47 47
In the case of graph structures, different operations are needed which do
48 48
not alter the physical graph, but gives another view. If some nodes or
49 49
arcs have to be hidden or the reverse oriented graph have to be used, then
50 50
this is the case. It also may happen that in a flow implementation
51 51
the residual graph can be accessed by another algorithm, or a node-set
52 52
is to be shrunk for another algorithm.
53 53
LEMON also provides a variety of graphs for these requirements called
54 54
\ref graph_adaptors "graph adaptors". Adaptors cannot be used alone but only
55 55
in conjunction with other graph representations.
56 56

	
57 57
You are free to use the graph structure that fit your requirements
58 58
the best, most graph algorithms and auxiliary data structures can be used
59 59
with any graph structure.
60 60

	
61 61
<b>See also:</b> \ref graph_concepts "Graph Structure Concepts".
62 62
*/
63 63

	
64 64
/**
65 65
@defgroup graph_adaptors Adaptor Classes for Graphs
66 66
@ingroup graphs
67 67
\brief Adaptor classes for digraphs and graphs
68 68

	
69 69
This group contains several useful adaptor classes for digraphs and graphs.
70 70

	
71 71
The main parts of LEMON are the different graph structures, generic
72 72
graph algorithms, graph concepts, which couple them, and graph
73 73
adaptors. While the previous notions are more or less clear, the
74 74
latter one needs further explanation. Graph adaptors are graph classes
75 75
which serve for considering graph structures in different ways.
76 76

	
77 77
A short example makes this much clearer.  Suppose that we have an
78 78
instance \c g of a directed graph type, say ListDigraph and an algorithm
79 79
\code
80 80
template <typename Digraph>
81 81
int algorithm(const Digraph&);
82 82
\endcode
83 83
is needed to run on the reverse oriented graph.  It may be expensive
84 84
(in time or in memory usage) to copy \c g with the reversed
85 85
arcs.  In this case, an adaptor class is used, which (according
86 86
to LEMON \ref concepts::Digraph "digraph concepts") works as a digraph.
87 87
The adaptor uses the original digraph structure and digraph operations when
88 88
methods of the reversed oriented graph are called.  This means that the adaptor
89 89
have minor memory usage, and do not perform sophisticated algorithmic
90 90
actions.  The purpose of it is to give a tool for the cases when a
91 91
graph have to be used in a specific alteration.  If this alteration is
92 92
obtained by a usual construction like filtering the node or the arc set or
93 93
considering a new orientation, then an adaptor is worthwhile to use.
94 94
To come back to the reverse oriented graph, in this situation
95 95
\code
96 96
template<typename Digraph> class ReverseDigraph;
97 97
\endcode
98 98
template class can be used. The code looks as follows
99 99
\code
100 100
ListDigraph g;
101 101
ReverseDigraph<ListDigraph> rg(g);
102 102
int result = algorithm(rg);
103 103
\endcode
104 104
During running the algorithm, the original digraph \c g is untouched.
105 105
This techniques give rise to an elegant code, and based on stable
106 106
graph adaptors, complex algorithms can be implemented easily.
107 107

	
108 108
In flow, circulation and matching problems, the residual
109 109
graph is of particular importance. Combining an adaptor implementing
110 110
this with shortest path algorithms or minimum mean cycle algorithms,
111 111
a range of weighted and cardinality optimization algorithms can be
112 112
obtained. For other examples, the interested user is referred to the
113 113
detailed documentation of particular adaptors.
114 114

	
115 115
The behavior of graph adaptors can be very different. Some of them keep
116 116
capabilities of the original graph while in other cases this would be
117 117
meaningless. This means that the concepts that they meet depend
118 118
on the graph adaptor, and the wrapped graph.
119 119
For example, if an arc of a reversed digraph is deleted, this is carried
120 120
out by deleting the corresponding arc of the original digraph, thus the
121 121
adaptor modifies the original digraph.
122 122
However in case of a residual digraph, this operation has no sense.
123 123

	
124 124
Let us stand one more example here to simplify your work.
125 125
ReverseDigraph has constructor
126 126
\code
127 127
ReverseDigraph(Digraph& digraph);
128 128
\endcode
129 129
This means that in a situation, when a <tt>const %ListDigraph&</tt>
130 130
reference to a graph is given, then it have to be instantiated with
131 131
<tt>Digraph=const %ListDigraph</tt>.
132 132
\code
133 133
int algorithm1(const ListDigraph& g) {
134 134
  ReverseDigraph<const ListDigraph> rg(g);
135 135
  return algorithm2(rg);
136 136
}
137 137
\endcode
138 138
*/
139 139

	
140 140
/**
141 141
@defgroup maps Maps
142 142
@ingroup datas
143 143
\brief Map structures implemented in LEMON.
144 144

	
145 145
This group contains the map structures implemented in LEMON.
146 146

	
147 147
LEMON provides several special purpose maps and map adaptors that e.g. combine
148 148
new maps from existing ones.
149 149

	
150 150
<b>See also:</b> \ref map_concepts "Map Concepts".
151 151
*/
152 152

	
153 153
/**
154 154
@defgroup graph_maps Graph Maps
155 155
@ingroup maps
156 156
\brief Special graph-related maps.
157 157

	
158 158
This group contains maps that are specifically designed to assign
159 159
values to the nodes and arcs/edges of graphs.
160 160

	
161 161
If you are looking for the standard graph maps (\c NodeMap, \c ArcMap,
162 162
\c EdgeMap), see the \ref graph_concepts "Graph Structure Concepts".
163 163
*/
164 164

	
165 165
/**
166 166
\defgroup map_adaptors Map Adaptors
167 167
\ingroup maps
168 168
\brief Tools to create new maps from existing ones
169 169

	
170 170
This group contains map adaptors that are used to create "implicit"
171 171
maps from other maps.
172 172

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

	
178 178
The typical usage of this classes is passing implicit maps to
179 179
algorithms.  If a function type algorithm is called then the function
180 180
type map adaptors can be used comfortable. For example let's see the
181 181
usage of map adaptors with the \c graphToEps() function.
182 182
\code
183 183
  Color nodeColor(int deg) {
184 184
    if (deg >= 2) {
185 185
      return Color(0.5, 0.0, 0.5);
186 186
    } else if (deg == 1) {
187 187
      return Color(1.0, 0.5, 1.0);
188 188
    } else {
189 189
      return Color(0.0, 0.0, 0.0);
190 190
    }
191 191
  }
192 192

	
193 193
  Digraph::NodeMap<int> degree_map(graph);
194 194

	
195 195
  graphToEps(graph, "graph.eps")
196 196
    .coords(coords).scaleToA4().undirected()
197 197
    .nodeColors(composeMap(functorToMap(nodeColor), degree_map))
198 198
    .run();
199 199
\endcode
200 200
The \c functorToMap() function makes an \c int to \c Color map from the
201 201
\c nodeColor() function. The \c composeMap() compose the \c degree_map
202 202
and the previously created map. The composed map is a proper function to
203 203
get the color of each node.
204 204

	
205 205
The usage with class type algorithms is little bit harder. In this
206 206
case the function type map adaptors can not be used, because the
207 207
function map adaptors give back temporary objects.
208 208
\code
209 209
  Digraph graph;
210 210

	
211 211
  typedef Digraph::ArcMap<double> DoubleArcMap;
212 212
  DoubleArcMap length(graph);
213 213
  DoubleArcMap speed(graph);
214 214

	
215 215
  typedef DivMap<DoubleArcMap, DoubleArcMap> TimeMap;
216 216
  TimeMap time(length, speed);
217 217

	
218 218
  Dijkstra<Digraph, TimeMap> dijkstra(graph, time);
219 219
  dijkstra.run(source, target);
220 220
\endcode
221 221
We have a length map and a maximum speed map on the arcs of a digraph.
222 222
The minimum time to pass the arc can be calculated as the division of
223 223
the two maps which can be done implicitly with the \c DivMap template
224 224
class. We use the implicit minimum time map as the length map of the
225 225
\c Dijkstra algorithm.
226 226
*/
227 227

	
228 228
/**
229
@defgroup matrices Matrices
230
@ingroup datas
231
\brief Two dimensional data storages implemented in LEMON.
232

	
233
This group contains two dimensional data storages implemented in LEMON.
234
*/
235

	
236
/**
237 229
@defgroup paths Path Structures
238 230
@ingroup datas
239 231
\brief %Path structures implemented in LEMON.
240 232

	
241 233
This group contains the path structures implemented in LEMON.
242 234

	
243 235
LEMON provides flexible data structures to work with paths.
244 236
All of them have similar interfaces and they can be copied easily with
245 237
assignment operators and copy constructors. This makes it easy and
246 238
efficient to have e.g. the Dijkstra algorithm to store its result in
247 239
any kind of path structure.
248 240

	
249
\sa lemon::concepts::Path
241
\sa \ref concepts::Path "Path concept"
242
*/
243

	
244
/**
245
@defgroup heaps Heap Structures
246
@ingroup datas
247
\brief %Heap structures implemented in LEMON.
248

	
249
This group contains the heap structures implemented in LEMON.
250

	
251
LEMON provides several heap classes. They are efficient implementations
252
of the abstract data type \e priority \e queue. They store items with
253
specified values called \e priorities in such a way that finding and
254
removing the item with minimum priority are efficient.
255
The basic operations are adding and erasing items, changing the priority
256
of an item, etc.
257

	
258
Heaps are crucial in several algorithms, such as Dijkstra and Prim.
259
The heap implementations have the same interface, thus any of them can be
260
used easily in such algorithms.
261

	
262
\sa \ref concepts::Heap "Heap concept"
263
*/
264

	
265
/**
266
@defgroup matrices Matrices
267
@ingroup datas
268
\brief Two dimensional data storages implemented in LEMON.
269

	
270
This group contains two dimensional data storages implemented in LEMON.
250 271
*/
251 272

	
252 273
/**
253 274
@defgroup auxdat Auxiliary Data Structures
254 275
@ingroup datas
255 276
\brief Auxiliary data structures implemented in LEMON.
256 277

	
257 278
This group contains some data structures implemented in LEMON in
258 279
order to make it easier to implement combinatorial algorithms.
259 280
*/
260 281

	
261 282
/**
283
@defgroup geomdat Geometric Data Structures
284
@ingroup auxdat
285
\brief Geometric data structures implemented in LEMON.
286

	
287
This group contains geometric data structures implemented in LEMON.
288

	
289
 - \ref lemon::dim2::Point "dim2::Point" implements a two dimensional
290
   vector with the usual operations.
291
 - \ref lemon::dim2::Box "dim2::Box" can be used to determine the
292
   rectangular bounding box of a set of \ref lemon::dim2::Point
293
   "dim2::Point"'s.
294
*/
295

	
296
/**
297
@defgroup matrices Matrices
298
@ingroup auxdat
299
\brief Two dimensional data storages implemented in LEMON.
300

	
301
This group contains two dimensional data storages implemented in LEMON.
302
*/
303

	
304
/**
262 305
@defgroup algs Algorithms
263 306
\brief This group contains the several algorithms
264 307
implemented in LEMON.
265 308

	
266 309
This group contains the several algorithms
267 310
implemented in LEMON.
268 311
*/
269 312

	
270 313
/**
271 314
@defgroup search Graph Search
272 315
@ingroup algs
273 316
\brief Common graph search algorithms.
274 317

	
275 318
This group contains the common graph search algorithms, namely
276
\e breadth-first \e search (BFS) and \e depth-first \e search (DFS).
319
\e breadth-first \e search (BFS) and \e depth-first \e search (DFS)
320
\ref clrs01algorithms.
277 321
*/
278 322

	
279 323
/**
280 324
@defgroup shortest_path Shortest Path Algorithms
281 325
@ingroup algs
282 326
\brief Algorithms for finding shortest paths.
283 327

	
284
This group contains the algorithms for finding shortest paths in digraphs.
328
This group contains the algorithms for finding shortest paths in digraphs
329
\ref clrs01algorithms.
285 330

	
286 331
 - \ref Dijkstra algorithm for finding shortest paths from a source node
287 332
   when all arc lengths are non-negative.
288 333
 - \ref BellmanFord "Bellman-Ford" algorithm for finding shortest paths
289 334
   from a source node when arc lenghts can be either positive or negative,
290 335
   but the digraph should not contain directed cycles with negative total
291 336
   length.
292 337
 - \ref FloydWarshall "Floyd-Warshall" and \ref Johnson "Johnson" algorithms
293 338
   for solving the \e all-pairs \e shortest \e paths \e problem when arc
294 339
   lenghts can be either positive or negative, but the digraph should
295 340
   not contain directed cycles with negative total length.
296 341
 - \ref Suurballe A successive shortest path algorithm for finding
297 342
   arc-disjoint paths between two nodes having minimum total length.
298 343
*/
299 344

	
300 345
/**
346
@defgroup spantree Minimum Spanning Tree Algorithms
347
@ingroup algs
348
\brief Algorithms for finding minimum cost spanning trees and arborescences.
349

	
350
This group contains the algorithms for finding minimum cost spanning
351
trees and arborescences \ref clrs01algorithms.
352
*/
353

	
354
/**
301 355
@defgroup max_flow Maximum Flow Algorithms
302 356
@ingroup algs
303 357
\brief Algorithms for finding maximum flows.
304 358

	
305 359
This group contains the algorithms for finding maximum flows and
306
feasible circulations.
360
feasible circulations \ref clrs01algorithms, \ref amo93networkflows.
307 361

	
308 362
The \e maximum \e flow \e problem is to find a flow of maximum value between
309 363
a single source and a single target. Formally, there is a \f$G=(V,A)\f$
310 364
digraph, a \f$cap: A\rightarrow\mathbf{R}^+_0\f$ capacity function and
311 365
\f$s, t \in V\f$ source and target nodes.
312 366
A maximum flow is an \f$f: A\rightarrow\mathbf{R}^+_0\f$ solution of the
313 367
following optimization problem.
314 368

	
315 369
\f[ \max\sum_{sv\in A} f(sv) - \sum_{vs\in A} f(vs) \f]
316 370
\f[ \sum_{uv\in A} f(uv) = \sum_{vu\in A} f(vu)
317 371
    \quad \forall u\in V\setminus\{s,t\} \f]
318 372
\f[ 0 \leq f(uv) \leq cap(uv) \quad \forall uv\in A \f]
319 373

	
320 374
LEMON contains several algorithms for solving maximum flow problems:
321
- \ref EdmondsKarp Edmonds-Karp algorithm.
322
- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm.
323
- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees.
324
- \ref GoldbergTarjan Preflow push-relabel algorithm with dynamic trees.
375
- \ref EdmondsKarp Edmonds-Karp algorithm
376
  \ref edmondskarp72theoretical.
377
- \ref Preflow Goldberg-Tarjan's preflow push-relabel algorithm
378
  \ref goldberg88newapproach.
379
- \ref DinitzSleatorTarjan Dinitz's blocking flow algorithm with dynamic trees
380
  \ref dinic70algorithm, \ref sleator83dynamic.
381
- \ref GoldbergTarjan !Preflow push-relabel algorithm with dynamic trees
382
  \ref goldberg88newapproach, \ref sleator83dynamic.
325 383

	
326
In most cases the \ref Preflow "Preflow" algorithm provides the
384
In most cases the \ref Preflow algorithm provides the
327 385
fastest method for computing a maximum flow. All implementations
328 386
also provide functions to query the minimum cut, which is the dual
329 387
problem of maximum flow.
330 388

	
331
\ref Circulation is a preflow push-relabel algorithm implemented directly 
389
\ref Circulation is a preflow push-relabel algorithm implemented directly
332 390
for finding feasible circulations, which is a somewhat different problem,
333 391
but it is strongly related to maximum flow.
334 392
For more information, see \ref Circulation.
335 393
*/
336 394

	
337 395
/**
338 396
@defgroup min_cost_flow_algs Minimum Cost Flow Algorithms
339 397
@ingroup algs
340 398

	
341 399
\brief Algorithms for finding minimum cost flows and circulations.
342 400

	
343 401
This group contains the algorithms for finding minimum cost flows and
344
circulations. For more information about this problem and its dual
345
solution see \ref min_cost_flow "Minimum Cost Flow Problem".
402
circulations \ref amo93networkflows. For more information about this
403
problem and its dual solution, see \ref min_cost_flow
404
"Minimum Cost Flow Problem".
346 405

	
347 406
LEMON contains several algorithms for this problem.
348 407
 - \ref NetworkSimplex Primal Network Simplex algorithm with various
349
   pivot strategies.
350
 - \ref CostScaling Push-Relabel and Augment-Relabel algorithms based on
351
   cost scaling.
352
 - \ref CapacityScaling Successive Shortest %Path algorithm with optional
353
   capacity scaling.
354
 - \ref CancelAndTighten The Cancel and Tighten algorithm.
355
 - \ref CycleCanceling Cycle-Canceling algorithms.
408
   pivot strategies \ref dantzig63linearprog, \ref kellyoneill91netsimplex.
409
 - \ref CostScaling Cost Scaling algorithm based on push/augment and
410
   relabel operations \ref goldberg90approximation, \ref goldberg97efficient,
411
   \ref bunnagel98efficient.
412
 - \ref CapacityScaling Capacity Scaling algorithm based on the successive
413
   shortest path method \ref edmondskarp72theoretical.
414
 - \ref CycleCanceling Cycle-Canceling algorithms, two of which are
415
   strongly polynomial \ref klein67primal, \ref goldberg89cyclecanceling.
356 416

	
357 417
In general NetworkSimplex is the most efficient implementation,
358 418
but in special cases other algorithms could be faster.
359 419
For example, if the total supply and/or capacities are rather small,
360 420
CapacityScaling is usually the fastest algorithm (without effective scaling).
361 421
*/
362 422

	
363 423
/**
364 424
@defgroup min_cut Minimum Cut Algorithms
365 425
@ingroup algs
366 426

	
367 427
\brief Algorithms for finding minimum cut in graphs.
368 428

	
369 429
This group contains the algorithms for finding minimum cut in graphs.
370 430

	
371 431
The \e minimum \e cut \e problem is to find a non-empty and non-complete
372 432
\f$X\f$ subset of the nodes with minimum overall capacity on
373 433
outgoing arcs. Formally, there is a \f$G=(V,A)\f$ digraph, a
374 434
\f$cap: A\rightarrow\mathbf{R}^+_0\f$ capacity function. The minimum
375 435
cut is the \f$X\f$ solution of the next optimization problem:
376 436

	
377 437
\f[ \min_{X \subset V, X\not\in \{\emptyset, V\}}
378
    \sum_{uv\in A, u\in X, v\not\in X}cap(uv) \f]
438
    \sum_{uv\in A: u\in X, v\not\in X}cap(uv) \f]
379 439

	
380 440
LEMON contains several algorithms related to minimum cut problems:
381 441

	
382 442
- \ref HaoOrlin "Hao-Orlin algorithm" for calculating minimum cut
383 443
  in directed graphs.
384 444
- \ref NagamochiIbaraki "Nagamochi-Ibaraki algorithm" for
385 445
  calculating minimum cut in undirected graphs.
386 446
- \ref GomoryHu "Gomory-Hu tree computation" for calculating
387 447
  all-pairs minimum cut in undirected graphs.
388 448

	
389 449
If you want to find minimum cut just between two distinict nodes,
390 450
see the \ref max_flow "maximum flow problem".
391 451
*/
392 452

	
393 453
/**
394
@defgroup graph_properties Connectivity and Other Graph Properties
454
@defgroup min_mean_cycle Minimum Mean Cycle Algorithms
395 455
@ingroup algs
396
\brief Algorithms for discovering the graph properties
456
\brief Algorithms for finding minimum mean cycles.
397 457

	
398
This group contains the algorithms for discovering the graph properties
399
like connectivity, bipartiteness, euler property, simplicity etc.
458
This group contains the algorithms for finding minimum mean cycles
459
\ref clrs01algorithms, \ref amo93networkflows.
400 460

	
401
\image html edge_biconnected_components.png
402
\image latex edge_biconnected_components.eps "bi-edge-connected components" width=\textwidth
403
*/
461
The \e minimum \e mean \e cycle \e problem is to find a directed cycle
462
of minimum mean length (cost) in a digraph.
463
The mean length of a cycle is the average length of its arcs, i.e. the
464
ratio between the total length of the cycle and the number of arcs on it.
404 465

	
405
/**
406
@defgroup planar Planarity Embedding and Drawing
407
@ingroup algs
408
\brief Algorithms for planarity checking, embedding and drawing
466
This problem has an important connection to \e conservative \e length
467
\e functions, too. A length function on the arcs of a digraph is called
468
conservative if and only if there is no directed cycle of negative total
469
length. For an arbitrary length function, the negative of the minimum
470
cycle mean is the smallest \f$\epsilon\f$ value so that increasing the
471
arc lengths uniformly by \f$\epsilon\f$ results in a conservative length
472
function.
409 473

	
410
This group contains the algorithms for planarity checking,
411
embedding and drawing.
474
LEMON contains three algorithms for solving the minimum mean cycle problem:
475
- \ref Karp "Karp"'s original algorithm \ref amo93networkflows,
476
  \ref dasdan98minmeancycle.
477
- \ref HartmannOrlin "Hartmann-Orlin"'s algorithm, which is an improved
478
  version of Karp's algorithm \ref dasdan98minmeancycle.
479
- \ref Howard "Howard"'s policy iteration algorithm
480
  \ref dasdan98minmeancycle.
412 481

	
413
\image html planar.png
414
\image latex planar.eps "Plane graph" width=\textwidth
482
In practice, the Howard algorithm proved to be by far the most efficient
483
one, though the best known theoretical bound on its running time is
484
exponential.
485
Both Karp and HartmannOrlin algorithms run in time O(ne) and use space
486
O(n<sup>2</sup>+e), but the latter one is typically faster due to the
487
applied early termination scheme.
415 488
*/
416 489

	
417 490
/**
418 491
@defgroup matching Matching Algorithms
419 492
@ingroup algs
420 493
\brief Algorithms for finding matchings in graphs and bipartite graphs.
421 494

	
422 495
This group contains the algorithms for calculating
423 496
matchings in graphs and bipartite graphs. The general matching problem is
424 497
finding a subset of the edges for which each node has at most one incident
425 498
edge.
426 499

	
427 500
There are several different algorithms for calculate matchings in
428 501
graphs.  The matching problems in bipartite graphs are generally
429 502
easier than in general graphs. The goal of the matching optimization
430 503
can be finding maximum cardinality, maximum weight or minimum cost
431 504
matching. The search can be constrained to find perfect or
432 505
maximum cardinality matching.
433 506

	
434 507
The matching algorithms implemented in LEMON:
435 508
- \ref MaxBipartiteMatching Hopcroft-Karp augmenting path algorithm
436 509
  for calculating maximum cardinality matching in bipartite graphs.
437 510
- \ref PrBipartiteMatching Push-relabel algorithm
438 511
  for calculating maximum cardinality matching in bipartite graphs.
439 512
- \ref MaxWeightedBipartiteMatching
440 513
  Successive shortest path algorithm for calculating maximum weighted
441 514
  matching and maximum weighted bipartite matching in bipartite graphs.
442 515
- \ref MinCostMaxBipartiteMatching
443 516
  Successive shortest path algorithm for calculating minimum cost maximum
444 517
  matching in bipartite graphs.
445 518
- \ref MaxMatching Edmond's blossom shrinking algorithm for calculating
446 519
  maximum cardinality matching in general graphs.
447 520
- \ref MaxWeightedMatching Edmond's blossom shrinking algorithm for calculating
448 521
  maximum weighted matching in general graphs.
449 522
- \ref MaxWeightedPerfectMatching
450 523
  Edmond's blossom shrinking algorithm for calculating maximum weighted
451 524
  perfect matching in general graphs.
525
- \ref MaxFractionalMatching Push-relabel algorithm for calculating
526
  maximum cardinality fractional matching in general graphs.
527
- \ref MaxWeightedFractionalMatching Augmenting path algorithm for calculating
528
  maximum weighted fractional matching in general graphs.
529
- \ref MaxWeightedPerfectFractionalMatching
530
  Augmenting path algorithm for calculating maximum weighted
531
  perfect fractional matching in general graphs.
452 532

	
453
\image html bipartite_matching.png
454
\image latex bipartite_matching.eps "Bipartite Matching" width=\textwidth
533
\image html matching.png
534
\image latex matching.eps "Min Cost Perfect Matching" width=\textwidth
455 535
*/
456 536

	
457 537
/**
458
@defgroup spantree Minimum Spanning Tree Algorithms
538
@defgroup graph_properties Connectivity and Other Graph Properties
459 539
@ingroup algs
460
\brief Algorithms for finding minimum cost spanning trees and arborescences.
540
\brief Algorithms for discovering the graph properties
461 541

	
462
This group contains the algorithms for finding minimum cost spanning
463
trees and arborescences.
542
This group contains the algorithms for discovering the graph properties
543
like connectivity, bipartiteness, euler property, simplicity etc.
544

	
545
\image html connected_components.png
546
\image latex connected_components.eps "Connected components" width=\textwidth
547
*/
548

	
549
/**
550
@defgroup planar Planarity Embedding and Drawing
551
@ingroup algs
552
\brief Algorithms for planarity checking, embedding and drawing
553

	
554
This group contains the algorithms for planarity checking,
555
embedding and drawing.
556

	
557
\image html planar.png
558
\image latex planar.eps "Plane graph" width=\textwidth
559
*/
560

	
561
/**
562
@defgroup approx Approximation Algorithms
563
@ingroup algs
564
\brief Approximation algorithms.
565

	
566
This group contains the approximation and heuristic algorithms
567
implemented in LEMON.
464 568
*/
465 569

	
466 570
/**
467 571
@defgroup auxalg Auxiliary Algorithms
468 572
@ingroup algs
469 573
\brief Auxiliary algorithms implemented in LEMON.
470 574

	
471 575
This group contains some algorithms implemented in LEMON
472 576
in order to make it easier to implement complex algorithms.
473 577
*/
474 578

	
475 579
/**
476
@defgroup approx Approximation Algorithms
477
@ingroup algs
478
\brief Approximation algorithms.
479

	
480
This group contains the approximation and heuristic algorithms
481
implemented in LEMON.
482
*/
483

	
484
/**
485 580
@defgroup gen_opt_group General Optimization Tools
486 581
\brief This group contains some general optimization frameworks
487 582
implemented in LEMON.
488 583

	
489 584
This group contains some general optimization frameworks
490 585
implemented in LEMON.
491 586
*/
492 587

	
493 588
/**
494
@defgroup lp_group Lp and Mip Solvers
589
@defgroup lp_group LP and MIP Solvers
495 590
@ingroup gen_opt_group
496
\brief Lp and Mip solver interfaces for LEMON.
591
\brief LP and MIP solver interfaces for LEMON.
497 592

	
498
This group contains Lp and Mip solver interfaces for LEMON. The
499
various LP solvers could be used in the same manner with this
500
interface.
593
This group contains LP and MIP solver interfaces for LEMON.
594
Various LP solvers could be used in the same manner with this
595
high-level interface.
596

	
597
The currently supported solvers are \ref glpk, \ref clp, \ref cbc,
598
\ref cplex, \ref soplex.
501 599
*/
502 600

	
503 601
/**
504 602
@defgroup lp_utils Tools for Lp and Mip Solvers
505 603
@ingroup lp_group
506 604
\brief Helper tools to the Lp and Mip solvers.
507 605

	
508 606
This group adds some helper tools to general optimization framework
509 607
implemented in LEMON.
510 608
*/
511 609

	
512 610
/**
513 611
@defgroup metah Metaheuristics
514 612
@ingroup gen_opt_group
515 613
\brief Metaheuristics for LEMON library.
516 614

	
517 615
This group contains some metaheuristic optimization tools.
518 616
*/
519 617

	
520 618
/**
521 619
@defgroup utils Tools and Utilities
522 620
\brief Tools and utilities for programming in LEMON
523 621

	
524 622
Tools and utilities for programming in LEMON.
525 623
*/
526 624

	
527 625
/**
528 626
@defgroup gutils Basic Graph Utilities
529 627
@ingroup utils
530 628
\brief Simple basic graph utilities.
531 629

	
532 630
This group contains some simple basic graph utilities.
533 631
*/
534 632

	
535 633
/**
536 634
@defgroup misc Miscellaneous Tools
537 635
@ingroup utils
538 636
\brief Tools for development, debugging and testing.
539 637

	
540 638
This group contains several useful tools for development,
541 639
debugging and testing.
542 640
*/
543 641

	
544 642
/**
545 643
@defgroup timecount Time Measuring and Counting
546 644
@ingroup misc
547 645
\brief Simple tools for measuring the performance of algorithms.
548 646

	
549 647
This group contains simple tools for measuring the performance
550 648
of algorithms.
551 649
*/
552 650

	
553 651
/**
554 652
@defgroup exceptions Exceptions
555 653
@ingroup utils
556 654
\brief Exceptions defined in LEMON.
557 655

	
558 656
This group contains the exceptions defined in LEMON.
559 657
*/
560 658

	
561 659
/**
562 660
@defgroup io_group Input-Output
563 661
\brief Graph Input-Output methods
564 662

	
565 663
This group contains the tools for importing and exporting graphs
566 664
and graph related data. Now it supports the \ref lgf-format
567 665
"LEMON Graph Format", the \c DIMACS format and the encapsulated
568 666
postscript (EPS) format.
569 667
*/
570 668

	
571 669
/**
572 670
@defgroup lemon_io LEMON Graph Format
573 671
@ingroup io_group
574 672
\brief Reading and writing LEMON Graph Format.
575 673

	
576 674
This group contains methods for reading and writing
577 675
\ref lgf-format "LEMON Graph Format".
578 676
*/
579 677

	
580 678
/**
581 679
@defgroup eps_io Postscript Exporting
582 680
@ingroup io_group
583 681
\brief General \c EPS drawer and graph exporter
584 682

	
585 683
This group contains general \c EPS drawing methods and special
586 684
graph exporting tools.
587 685
*/
588 686

	
589 687
/**
590
@defgroup dimacs_group DIMACS format
688
@defgroup dimacs_group DIMACS Format
591 689
@ingroup io_group
592 690
\brief Read and write files in DIMACS format
593 691

	
594 692
Tools to read a digraph from or write it to a file in DIMACS format data.
595 693
*/
596 694

	
597 695
/**
598 696
@defgroup nauty_group NAUTY Format
599 697
@ingroup io_group
600 698
\brief Read \e Nauty format
601 699

	
602 700
Tool to read graphs from \e Nauty format data.
603 701
*/
604 702

	
605 703
/**
606 704
@defgroup concept Concepts
607 705
\brief Skeleton classes and concept checking classes
608 706

	
609 707
This group contains the data/algorithm skeletons and concept checking
610 708
classes implemented in LEMON.
611 709

	
612 710
The purpose of the classes in this group is fourfold.
613 711

	
614 712
- These classes contain the documentations of the %concepts. In order
615 713
  to avoid document multiplications, an implementation of a concept
616 714
  simply refers to the corresponding concept class.
617 715

	
618 716
- These classes declare every functions, <tt>typedef</tt>s etc. an
619 717
  implementation of the %concepts should provide, however completely
620 718
  without implementations and real data structures behind the
621 719
  interface. On the other hand they should provide nothing else. All
622 720
  the algorithms working on a data structure meeting a certain concept
623 721
  should compile with these classes. (Though it will not run properly,
624 722
  of course.) In this way it is easily to check if an algorithm
625 723
  doesn't use any extra feature of a certain implementation.
626 724

	
627 725
- The concept descriptor classes also provide a <em>checker class</em>
628 726
  that makes it possible to check whether a certain implementation of a
629 727
  concept indeed provides all the required features.
630 728

	
631 729
- Finally, They can serve as a skeleton of a new implementation of a concept.
632 730
*/
633 731

	
634 732
/**
635 733
@defgroup graph_concepts Graph Structure Concepts
636 734
@ingroup concept
637 735
\brief Skeleton and concept checking classes for graph structures
638 736

	
639
This group contains the skeletons and concept checking classes of LEMON's
640
graph structures and helper classes used to implement these.
737
This group contains the skeletons and concept checking classes of
738
graph structures.
641 739
*/
642 740

	
643 741
/**
644 742
@defgroup map_concepts Map Concepts
645 743
@ingroup concept
646 744
\brief Skeleton and concept checking classes for maps
647 745

	
648 746
This group contains the skeletons and concept checking classes of maps.
649 747
*/
650 748

	
651 749
/**
750
@defgroup tools Standalone Utility Applications
751

	
752
Some utility applications are listed here.
753

	
754
The standard compilation procedure (<tt>./configure;make</tt>) will compile
755
them, as well.
756
*/
757

	
758
/**
652 759
\anchor demoprograms
653 760

	
654 761
@defgroup demos Demo Programs
655 762

	
656 763
Some demo programs are listed here. Their full source codes can be found in
657 764
the \c demo subdirectory of the source tree.
658 765

	
659 766
In order to compile them, use the <tt>make demo</tt> or the
660 767
<tt>make check</tt> commands.
661 768
*/
662 769

	
663
/**
664
@defgroup tools Standalone Utility Applications
665

	
666
Some utility applications are listed here.
667

	
668
The standard compilation procedure (<tt>./configure;make</tt>) will compile
669
them, as well.
670
*/
671

	
672 770
}
Ignore white space 6 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-2010
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
\mainpage @PACKAGE_NAME@ @PACKAGE_VERSION@ Documentation
21 21

	
22 22
\section intro Introduction
23 23

	
24
\subsection whatis What is LEMON
25

	
26
LEMON stands for <b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling
27
and <b>O</b>ptimization in <b>N</b>etworks.
28
It is a C++ template
29
library aimed at combinatorial optimization tasks which
30
often involve in working
31
with graphs.
24
<b>LEMON</b> stands for <i><b>L</b>ibrary for <b>E</b>fficient <b>M</b>odeling
25
and <b>O</b>ptimization in <b>N</b>etworks</i>.
26
It is a C++ template library providing efficient implementations of common
27
data structures and algorithms with focus on combinatorial optimization
28
tasks connected mainly with graphs and networks.
32 29

	
33 30
<b>
34 31
LEMON is an <a class="el" href="http://opensource.org/">open&nbsp;source</a>
35 32
project.
36 33
You are free to use it in your commercial or
37 34
non-commercial applications under very permissive
38 35
\ref license "license terms".
39 36
</b>
40 37

	
41
\subsection howtoread How to read the documentation
38
The project is maintained by the
39
<a href="http://www.cs.elte.hu/egres/">Egerv&aacute;ry Research Group on
40
Combinatorial Optimization</a> \ref egres
41
at the Operations Research Department of the
42
<a href="http://www.elte.hu/en/">E&ouml;tv&ouml;s Lor&aacute;nd University</a>,
43
Budapest, Hungary.
44
LEMON is also a member of the <a href="http://www.coin-or.org/">COIN-OR</a>
45
initiative \ref coinor.
46

	
47
\section howtoread How to Read the Documentation
42 48

	
43 49
If you would like to get to know the library, see
44 50
<a class="el" href="http://lemon.cs.elte.hu/pub/tutorial/">LEMON Tutorial</a>.
45 51

	
52
If you are interested in starting to use the library, see the <a class="el"
53
href="http://lemon.cs.elte.hu/trac/lemon/wiki/InstallGuide/">Installation
54
Guide</a>.
55

	
46 56
If you know what you are looking for, then try to find it under the
47 57
<a class="el" href="modules.html">Modules</a> section.
48 58

	
49 59
If you are a user of the old (0.x) series of LEMON, please check out the
50 60
\ref migration "Migration Guide" for the backward incompatibilities.
51 61
*/
Ignore white space 6 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-2010
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
\page min_cost_flow Minimum Cost Flow Problem
23 23

	
24 24
\section mcf_def Definition (GEQ form)
25 25

	
26 26
The \e minimum \e cost \e flow \e problem is to find a feasible flow of
27 27
minimum total cost from a set of supply nodes to a set of demand nodes
28 28
in a network with capacity constraints (lower and upper bounds)
29
and arc costs.
29
and arc costs \ref amo93networkflows.
30 30

	
31 31
Formally, let \f$G=(V,A)\f$ be a digraph, \f$lower: A\rightarrow\mathbf{R}\f$,
32 32
\f$upper: A\rightarrow\mathbf{R}\cup\{+\infty\}\f$ denote the lower and
33 33
upper bounds for the flow values on the arcs, for which
34 34
\f$lower(uv) \leq upper(uv)\f$ must hold for all \f$uv\in A\f$,
35 35
\f$cost: A\rightarrow\mathbf{R}\f$ denotes the cost per unit flow
36 36
on the arcs and \f$sup: V\rightarrow\mathbf{R}\f$ denotes the
37 37
signed supply values of the nodes.
38 38
If \f$sup(u)>0\f$, then \f$u\f$ is a supply node with \f$sup(u)\f$
39 39
supply, if \f$sup(u)<0\f$, then \f$u\f$ is a demand node with
40 40
\f$-sup(u)\f$ demand.
41 41
A minimum cost flow is an \f$f: A\rightarrow\mathbf{R}\f$ solution
42 42
of the following optimization problem.
43 43

	
44 44
\f[ \min\sum_{uv\in A} f(uv) \cdot cost(uv) \f]
45 45
\f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \geq
46 46
    sup(u) \quad \forall u\in V \f]
47 47
\f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A \f]
48 48

	
49 49
The sum of the supply values, i.e. \f$\sum_{u\in V} sup(u)\f$ must be
50 50
zero or negative in order to have a feasible solution (since the sum
51 51
of the expressions on the left-hand side of the inequalities is zero).
52 52
It means that the total demand must be greater or equal to the total
53 53
supply and all the supplies have to be carried out from the supply nodes,
54 54
but there could be demands that are not satisfied.
55 55
If \f$\sum_{u\in V} sup(u)\f$ is zero, then all the supply/demand
56 56
constraints have to be satisfied with equality, i.e. all demands
57 57
have to be satisfied and all supplies have to be used.
58 58

	
59 59

	
60 60
\section mcf_algs Algorithms
61 61

	
62 62
LEMON contains several algorithms for solving this problem, for more
63 63
information see \ref min_cost_flow_algs "Minimum Cost Flow Algorithms".
64 64

	
65 65
A feasible solution for this problem can be found using \ref Circulation.
66 66

	
67 67

	
68 68
\section mcf_dual Dual Solution
69 69

	
70 70
The dual solution of the minimum cost flow problem is represented by
71 71
node potentials \f$\pi: V\rightarrow\mathbf{R}\f$.
72 72
An \f$f: A\rightarrow\mathbf{R}\f$ primal feasible solution is optimal
73 73
if and only if for some \f$\pi: V\rightarrow\mathbf{R}\f$ node potentials
74 74
the following \e complementary \e slackness optimality conditions hold.
75 75

	
76 76
 - For all \f$uv\in A\f$ arcs:
77 77
   - if \f$cost^\pi(uv)>0\f$, then \f$f(uv)=lower(uv)\f$;
78 78
   - if \f$lower(uv)<f(uv)<upper(uv)\f$, then \f$cost^\pi(uv)=0\f$;
79 79
   - if \f$cost^\pi(uv)<0\f$, then \f$f(uv)=upper(uv)\f$.
80 80
 - For all \f$u\in V\f$ nodes:
81
   - \f$\pi(u)<=0\f$;
81
   - \f$\pi(u)\leq 0\f$;
82 82
   - if \f$\sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \neq sup(u)\f$,
83 83
     then \f$\pi(u)=0\f$.
84
 
84

	
85 85
Here \f$cost^\pi(uv)\f$ denotes the \e reduced \e cost of the arc
86 86
\f$uv\in A\f$ with respect to the potential function \f$\pi\f$, i.e.
87 87
\f[ cost^\pi(uv) = cost(uv) + \pi(u) - \pi(v).\f]
88 88

	
89 89
All algorithms provide dual solution (node potentials), as well,
90 90
if an optimal flow is found.
91 91

	
92 92

	
93 93
\section mcf_eq Equality Form
94 94

	
95 95
The above \ref mcf_def "definition" is actually more general than the
96 96
usual formulation of the minimum cost flow problem, in which strict
97 97
equalities are required in the supply/demand contraints.
98 98

	
99 99
\f[ \min\sum_{uv\in A} f(uv) \cdot cost(uv) \f]
100 100
\f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) =
101 101
    sup(u) \quad \forall u\in V \f]
102 102
\f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A \f]
103 103

	
104 104
However if the sum of the supply values is zero, then these two problems
105 105
are equivalent.
106 106
The \ref min_cost_flow_algs "algorithms" in LEMON support the general
107 107
form, so if you need the equality form, you have to ensure this additional
108 108
contraint manually.
109 109

	
110 110

	
111 111
\section mcf_leq Opposite Inequalites (LEQ Form)
112 112

	
113 113
Another possible definition of the minimum cost flow problem is
114 114
when there are <em>"less or equal"</em> (LEQ) supply/demand constraints,
115 115
instead of the <em>"greater or equal"</em> (GEQ) constraints.
116 116

	
117 117
\f[ \min\sum_{uv\in A} f(uv) \cdot cost(uv) \f]
118 118
\f[ \sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \leq
119 119
    sup(u) \quad \forall u\in V \f]
120 120
\f[ lower(uv) \leq f(uv) \leq upper(uv) \quad \forall uv\in A \f]
121 121

	
122
It means that the total demand must be less or equal to the 
122
It means that the total demand must be less or equal to the
123 123
total supply (i.e. \f$\sum_{u\in V} sup(u)\f$ must be zero or
124 124
positive) and all the demands have to be satisfied, but there
125 125
could be supplies that are not carried out from the supply
126 126
nodes.
127 127
The equality form is also a special case of this form, of course.
128 128

	
129 129
You could easily transform this case to the \ref mcf_def "GEQ form"
130 130
of the problem by reversing the direction of the arcs and taking the
131 131
negative of the supply values (e.g. using \ref ReverseDigraph and
132 132
\ref NegMap adaptors).
133 133
However \ref NetworkSimplex algorithm also supports this form directly
134 134
for the sake of convenience.
135 135

	
136 136
Note that the optimality conditions for this supply constraint type are
137 137
slightly differ from the conditions that are discussed for the GEQ form,
138 138
namely the potentials have to be non-negative instead of non-positive.
139 139
An \f$f: A\rightarrow\mathbf{R}\f$ feasible solution of this problem
140 140
is optimal if and only if for some \f$\pi: V\rightarrow\mathbf{R}\f$
141 141
node potentials the following conditions hold.
142 142

	
143 143
 - For all \f$uv\in A\f$ arcs:
144 144
   - if \f$cost^\pi(uv)>0\f$, then \f$f(uv)=lower(uv)\f$;
145 145
   - if \f$lower(uv)<f(uv)<upper(uv)\f$, then \f$cost^\pi(uv)=0\f$;
146 146
   - if \f$cost^\pi(uv)<0\f$, then \f$f(uv)=upper(uv)\f$.
147 147
 - For all \f$u\in V\f$ nodes:
148
   - \f$\pi(u)>=0\f$;
148
   - \f$\pi(u)\geq 0\f$;
149 149
   - if \f$\sum_{uv\in A} f(uv) - \sum_{vu\in A} f(vu) \neq sup(u)\f$,
150 150
     then \f$\pi(u)=0\f$.
151 151

	
152 152
*/
153 153
}
Ignore white space 6 line context
1 1
EXTRA_DIST += \
2 2
	lemon/lemon.pc.in \
3 3
	lemon/lemon.pc.cmake \
4 4
	lemon/CMakeLists.txt \
5 5
	lemon/config.h.cmake
6 6

	
7 7
pkgconfig_DATA += lemon/lemon.pc
8 8

	
9 9
lib_LTLIBRARIES += lemon/libemon.la
10 10

	
11 11
lemon_libemon_la_SOURCES = \
12 12
	lemon/arg_parser.cc \
13 13
	lemon/base.cc \
14 14
	lemon/color.cc \
15 15
	lemon/lp_base.cc \
16 16
	lemon/lp_skeleton.cc \
17 17
	lemon/random.cc \
18 18
	lemon/bits/windows.cc
19 19

	
20 20
nodist_lemon_HEADERS = lemon/config.h	
21 21

	
22 22
lemon_libemon_la_CXXFLAGS = \
23 23
	$(AM_CXXFLAGS) \
24 24
	$(GLPK_CFLAGS) \
25 25
	$(CPLEX_CFLAGS) \
26 26
	$(SOPLEX_CXXFLAGS) \
27 27
	$(CLP_CXXFLAGS) \
28 28
	$(CBC_CXXFLAGS)
29 29

	
30 30
lemon_libemon_la_LDFLAGS = \
31 31
	$(GLPK_LIBS) \
32 32
	$(CPLEX_LIBS) \
33 33
	$(SOPLEX_LIBS) \
34 34
	$(CLP_LIBS) \
35 35
	$(CBC_LIBS)
36 36

	
37 37
if HAVE_GLPK
38 38
lemon_libemon_la_SOURCES += lemon/glpk.cc
39 39
endif
40 40

	
41 41
if HAVE_CPLEX
42 42
lemon_libemon_la_SOURCES += lemon/cplex.cc
43 43
endif
44 44

	
45 45
if HAVE_SOPLEX
46 46
lemon_libemon_la_SOURCES += lemon/soplex.cc
47 47
endif
48 48

	
49 49
if HAVE_CLP
50 50
lemon_libemon_la_SOURCES += lemon/clp.cc
51 51
endif
52 52

	
53 53
if HAVE_CBC
54 54
lemon_libemon_la_SOURCES += lemon/cbc.cc
55 55
endif
56 56

	
57 57
lemon_HEADERS += \
58 58
	lemon/adaptors.h \
59 59
	lemon/arg_parser.h \
60 60
	lemon/assert.h \
61
	lemon/bellman_ford.h \
61 62
	lemon/bfs.h \
62 63
	lemon/bin_heap.h \
64
	lemon/binomial_heap.h \
63 65
	lemon/bucket_heap.h \
66
	lemon/capacity_scaling.h \
64 67
	lemon/cbc.h \
65 68
	lemon/circulation.h \
66 69
	lemon/clp.h \
67 70
	lemon/color.h \
68 71
	lemon/concept_check.h \
69 72
	lemon/connectivity.h \
73
	lemon/core.h \
74
	lemon/cost_scaling.h \
70 75
	lemon/counter.h \
71
	lemon/core.h \
72 76
	lemon/cplex.h \
77
	lemon/cycle_canceling.h \
73 78
	lemon/dfs.h \
79
	lemon/dheap.h \
74 80
	lemon/dijkstra.h \
75 81
	lemon/dim2.h \
76 82
	lemon/dimacs.h \
77 83
	lemon/edge_set.h \
78 84
	lemon/elevator.h \
79 85
	lemon/error.h \
80 86
	lemon/euler.h \
81 87
	lemon/fib_heap.h \
88
	lemon/fractional_matching.h \
82 89
	lemon/full_graph.h \
83 90
	lemon/glpk.h \
84 91
	lemon/gomory_hu.h \
85 92
	lemon/graph_to_eps.h \
86 93
	lemon/grid_graph.h \
94
	lemon/hartmann_orlin_mmc.h \
95
	lemon/howard_mmc.h \
87 96
	lemon/hypercube_graph.h \
97
	lemon/karp_mmc.h \
88 98
	lemon/kruskal.h \
89 99
	lemon/hao_orlin.h \
90 100
	lemon/lgf_reader.h \
91 101
	lemon/lgf_writer.h \
92 102
	lemon/list_graph.h \
93 103
	lemon/lp.h \
94 104
	lemon/lp_base.h \
95 105
	lemon/lp_skeleton.h \
96 106
	lemon/maps.h \
97 107
	lemon/matching.h \
98 108
	lemon/math.h \
99 109
	lemon/min_cost_arborescence.h \
100 110
	lemon/nauty_reader.h \
101 111
	lemon/network_simplex.h \
112
	lemon/pairing_heap.h \
102 113
	lemon/path.h \
114
	lemon/planarity.h \
103 115
	lemon/preflow.h \
116
	lemon/quad_heap.h \
104 117
	lemon/radix_heap.h \
105 118
	lemon/radix_sort.h \
106 119
	lemon/random.h \
107 120
	lemon/smart_graph.h \
108 121
	lemon/soplex.h \
122
	lemon/static_graph.h \
109 123
	lemon/suurballe.h \
110 124
	lemon/time_measure.h \
111 125
	lemon/tolerance.h \
112 126
	lemon/unionfind.h \
113 127
	lemon/bits/windows.h
114 128

	
115 129
bits_HEADERS += \
116 130
	lemon/bits/alteration_notifier.h \
117 131
	lemon/bits/array_map.h \
118 132
	lemon/bits/bezier.h \
119 133
	lemon/bits/default_map.h \
120 134
	lemon/bits/edge_set_extender.h \
121 135
	lemon/bits/enable_if.h \
122 136
	lemon/bits/graph_adaptor_extender.h \
123 137
	lemon/bits/graph_extender.h \
124 138
	lemon/bits/map_extender.h \
125 139
	lemon/bits/path_dump.h \
126 140
	lemon/bits/solver_bits.h \
127 141
	lemon/bits/traits.h \
128 142
	lemon/bits/variant.h \
129 143
	lemon/bits/vector_map.h
130 144

	
131 145
concept_HEADERS += \
132 146
	lemon/concepts/digraph.h \
133 147
	lemon/concepts/graph.h \
134 148
	lemon/concepts/graph_components.h \
135 149
	lemon/concepts/heap.h \
136 150
	lemon/concepts/maps.h \
137 151
	lemon/concepts/path.h
Ignore white space 6 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-2010
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_ADAPTORS_H
20 20
#define LEMON_ADAPTORS_H
21 21

	
22 22
/// \ingroup graph_adaptors
23 23
/// \file
24 24
/// \brief Adaptor classes for digraphs and graphs
25 25
///
26 26
/// This file contains several useful adaptors for digraphs and graphs.
27 27

	
28 28
#include <lemon/core.h>
29 29
#include <lemon/maps.h>
30 30
#include <lemon/bits/variant.h>
31 31

	
32 32
#include <lemon/bits/graph_adaptor_extender.h>
33 33
#include <lemon/bits/map_extender.h>
34 34
#include <lemon/tolerance.h>
35 35

	
36 36
#include <algorithm>
37 37

	
38 38
namespace lemon {
39 39

	
40 40
#ifdef _MSC_VER
41 41
#define LEMON_SCOPE_FIX(OUTER, NESTED) OUTER::NESTED
42 42
#else
43 43
#define LEMON_SCOPE_FIX(OUTER, NESTED) typename OUTER::template NESTED
44 44
#endif
45 45

	
46 46
  template<typename DGR>
47 47
  class DigraphAdaptorBase {
48 48
  public:
49 49
    typedef DGR Digraph;
50 50
    typedef DigraphAdaptorBase Adaptor;
51 51

	
52 52
  protected:
53 53
    DGR* _digraph;
54 54
    DigraphAdaptorBase() : _digraph(0) { }
55 55
    void initialize(DGR& digraph) { _digraph = &digraph; }
56 56

	
57 57
  public:
58 58
    DigraphAdaptorBase(DGR& digraph) : _digraph(&digraph) { }
59 59

	
60 60
    typedef typename DGR::Node Node;
61 61
    typedef typename DGR::Arc Arc;
62 62

	
63 63
    void first(Node& i) const { _digraph->first(i); }
64 64
    void first(Arc& i) const { _digraph->first(i); }
65 65
    void firstIn(Arc& i, const Node& n) const { _digraph->firstIn(i, n); }
66 66
    void firstOut(Arc& i, const Node& n ) const { _digraph->firstOut(i, n); }
67 67

	
68 68
    void next(Node& i) const { _digraph->next(i); }
69 69
    void next(Arc& i) const { _digraph->next(i); }
70 70
    void nextIn(Arc& i) const { _digraph->nextIn(i); }
71 71
    void nextOut(Arc& i) const { _digraph->nextOut(i); }
72 72

	
73 73
    Node source(const Arc& a) const { return _digraph->source(a); }
74 74
    Node target(const Arc& a) const { return _digraph->target(a); }
75 75

	
76 76
    typedef NodeNumTagIndicator<DGR> NodeNumTag;
77 77
    int nodeNum() const { return _digraph->nodeNum(); }
78 78

	
79 79
    typedef ArcNumTagIndicator<DGR> ArcNumTag;
80 80
    int arcNum() const { return _digraph->arcNum(); }
81 81

	
82 82
    typedef FindArcTagIndicator<DGR> FindArcTag;
83 83
    Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) const {
84 84
      return _digraph->findArc(u, v, prev);
85 85
    }
86 86

	
87 87
    Node addNode() { return _digraph->addNode(); }
88 88
    Arc addArc(const Node& u, const Node& v) { return _digraph->addArc(u, v); }
89 89

	
90 90
    void erase(const Node& n) { _digraph->erase(n); }
91 91
    void erase(const Arc& a) { _digraph->erase(a); }
92 92

	
93 93
    void clear() { _digraph->clear(); }
94 94

	
95 95
    int id(const Node& n) const { return _digraph->id(n); }
96 96
    int id(const Arc& a) const { return _digraph->id(a); }
97 97

	
98 98
    Node nodeFromId(int ix) const { return _digraph->nodeFromId(ix); }
99 99
    Arc arcFromId(int ix) const { return _digraph->arcFromId(ix); }
100 100

	
101 101
    int maxNodeId() const { return _digraph->maxNodeId(); }
102 102
    int maxArcId() const { return _digraph->maxArcId(); }
103 103

	
104 104
    typedef typename ItemSetTraits<DGR, Node>::ItemNotifier NodeNotifier;
105 105
    NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); }
106 106

	
107 107
    typedef typename ItemSetTraits<DGR, Arc>::ItemNotifier ArcNotifier;
108 108
    ArcNotifier& notifier(Arc) const { return _digraph->notifier(Arc()); }
109 109

	
110 110
    template <typename V>
111 111
    class NodeMap : public DGR::template NodeMap<V> {
112 112
      typedef typename DGR::template NodeMap<V> Parent;
113 113

	
114 114
    public:
115 115
      explicit NodeMap(const Adaptor& adaptor)
116 116
        : Parent(*adaptor._digraph) {}
117 117
      NodeMap(const Adaptor& adaptor, const V& value)
118 118
        : Parent(*adaptor._digraph, value) { }
119 119

	
120 120
    private:
121 121
      NodeMap& operator=(const NodeMap& cmap) {
122 122
        return operator=<NodeMap>(cmap);
123 123
      }
124 124

	
125 125
      template <typename CMap>
126 126
      NodeMap& operator=(const CMap& cmap) {
127 127
        Parent::operator=(cmap);
128 128
        return *this;
129 129
      }
130 130

	
131 131
    };
132 132

	
133 133
    template <typename V>
134 134
    class ArcMap : public DGR::template ArcMap<V> {
135 135
      typedef typename DGR::template ArcMap<V> Parent;
136 136

	
137 137
    public:
138 138
      explicit ArcMap(const DigraphAdaptorBase<DGR>& adaptor)
139 139
        : Parent(*adaptor._digraph) {}
140 140
      ArcMap(const DigraphAdaptorBase<DGR>& adaptor, const V& value)
141 141
        : Parent(*adaptor._digraph, value) {}
142 142

	
143 143
    private:
144 144
      ArcMap& operator=(const ArcMap& cmap) {
145 145
        return operator=<ArcMap>(cmap);
146 146
      }
147 147

	
148 148
      template <typename CMap>
149 149
      ArcMap& operator=(const CMap& cmap) {
150 150
        Parent::operator=(cmap);
151 151
        return *this;
152 152
      }
153 153

	
154 154
    };
155 155

	
156 156
  };
157 157

	
158 158
  template<typename GR>
159 159
  class GraphAdaptorBase {
160 160
  public:
161 161
    typedef GR Graph;
162 162

	
163 163
  protected:
164 164
    GR* _graph;
165 165

	
166 166
    GraphAdaptorBase() : _graph(0) {}
167 167

	
168 168
    void initialize(GR& graph) { _graph = &graph; }
169 169

	
170 170
  public:
171 171
    GraphAdaptorBase(GR& graph) : _graph(&graph) {}
172 172

	
173 173
    typedef typename GR::Node Node;
174 174
    typedef typename GR::Arc Arc;
175 175
    typedef typename GR::Edge Edge;
176 176

	
177 177
    void first(Node& i) const { _graph->first(i); }
178 178
    void first(Arc& i) const { _graph->first(i); }
179 179
    void first(Edge& i) const { _graph->first(i); }
180 180
    void firstIn(Arc& i, const Node& n) const { _graph->firstIn(i, n); }
181 181
    void firstOut(Arc& i, const Node& n ) const { _graph->firstOut(i, n); }
182 182
    void firstInc(Edge &i, bool &d, const Node &n) const {
183 183
      _graph->firstInc(i, d, n);
184 184
    }
185 185

	
186 186
    void next(Node& i) const { _graph->next(i); }
187 187
    void next(Arc& i) const { _graph->next(i); }
188 188
    void next(Edge& i) const { _graph->next(i); }
189 189
    void nextIn(Arc& i) const { _graph->nextIn(i); }
190 190
    void nextOut(Arc& i) const { _graph->nextOut(i); }
191 191
    void nextInc(Edge &i, bool &d) const { _graph->nextInc(i, d); }
192 192

	
193 193
    Node u(const Edge& e) const { return _graph->u(e); }
194 194
    Node v(const Edge& e) const { return _graph->v(e); }
195 195

	
196 196
    Node source(const Arc& a) const { return _graph->source(a); }
197 197
    Node target(const Arc& a) const { return _graph->target(a); }
198 198

	
199 199
    typedef NodeNumTagIndicator<Graph> NodeNumTag;
200 200
    int nodeNum() const { return _graph->nodeNum(); }
201 201

	
202 202
    typedef ArcNumTagIndicator<Graph> ArcNumTag;
203 203
    int arcNum() const { return _graph->arcNum(); }
204 204

	
205 205
    typedef EdgeNumTagIndicator<Graph> EdgeNumTag;
206 206
    int edgeNum() const { return _graph->edgeNum(); }
207 207

	
208 208
    typedef FindArcTagIndicator<Graph> FindArcTag;
209 209
    Arc findArc(const Node& u, const Node& v,
210 210
                const Arc& prev = INVALID) const {
211 211
      return _graph->findArc(u, v, prev);
212 212
    }
213 213

	
214 214
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
215 215
    Edge findEdge(const Node& u, const Node& v,
216 216
                  const Edge& prev = INVALID) const {
217 217
      return _graph->findEdge(u, v, prev);
218 218
    }
219 219

	
220 220
    Node addNode() { return _graph->addNode(); }
221 221
    Edge addEdge(const Node& u, const Node& v) { return _graph->addEdge(u, v); }
222 222

	
223 223
    void erase(const Node& i) { _graph->erase(i); }
224 224
    void erase(const Edge& i) { _graph->erase(i); }
225 225

	
226 226
    void clear() { _graph->clear(); }
227 227

	
228 228
    bool direction(const Arc& a) const { return _graph->direction(a); }
229 229
    Arc direct(const Edge& e, bool d) const { return _graph->direct(e, d); }
230 230

	
231 231
    int id(const Node& v) const { return _graph->id(v); }
232 232
    int id(const Arc& a) const { return _graph->id(a); }
233 233
    int id(const Edge& e) const { return _graph->id(e); }
234 234

	
235 235
    Node nodeFromId(int ix) const { return _graph->nodeFromId(ix); }
236 236
    Arc arcFromId(int ix) const { return _graph->arcFromId(ix); }
237 237
    Edge edgeFromId(int ix) const { return _graph->edgeFromId(ix); }
238 238

	
239 239
    int maxNodeId() const { return _graph->maxNodeId(); }
240 240
    int maxArcId() const { return _graph->maxArcId(); }
241 241
    int maxEdgeId() const { return _graph->maxEdgeId(); }
242 242

	
243 243
    typedef typename ItemSetTraits<GR, Node>::ItemNotifier NodeNotifier;
244 244
    NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
245 245

	
246 246
    typedef typename ItemSetTraits<GR, Arc>::ItemNotifier ArcNotifier;
247 247
    ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
248 248

	
249 249
    typedef typename ItemSetTraits<GR, Edge>::ItemNotifier EdgeNotifier;
250 250
    EdgeNotifier& notifier(Edge) const { return _graph->notifier(Edge()); }
251 251

	
252 252
    template <typename V>
253 253
    class NodeMap : public GR::template NodeMap<V> {
254 254
      typedef typename GR::template NodeMap<V> Parent;
255 255

	
256 256
    public:
257 257
      explicit NodeMap(const GraphAdaptorBase<GR>& adapter)
258 258
        : Parent(*adapter._graph) {}
259 259
      NodeMap(const GraphAdaptorBase<GR>& adapter, const V& value)
260 260
        : Parent(*adapter._graph, value) {}
261 261

	
262 262
    private:
263 263
      NodeMap& operator=(const NodeMap& cmap) {
264 264
        return operator=<NodeMap>(cmap);
265 265
      }
266 266

	
267 267
      template <typename CMap>
268 268
      NodeMap& operator=(const CMap& cmap) {
269 269
        Parent::operator=(cmap);
270 270
        return *this;
271 271
      }
272 272

	
273 273
    };
274 274

	
275 275
    template <typename V>
276 276
    class ArcMap : public GR::template ArcMap<V> {
277 277
      typedef typename GR::template ArcMap<V> Parent;
278 278

	
279 279
    public:
280 280
      explicit ArcMap(const GraphAdaptorBase<GR>& adapter)
281 281
        : Parent(*adapter._graph) {}
282 282
      ArcMap(const GraphAdaptorBase<GR>& adapter, const V& value)
283 283
        : Parent(*adapter._graph, value) {}
284 284

	
285 285
    private:
286 286
      ArcMap& operator=(const ArcMap& cmap) {
287 287
        return operator=<ArcMap>(cmap);
288 288
      }
289 289

	
290 290
      template <typename CMap>
291 291
      ArcMap& operator=(const CMap& cmap) {
292 292
        Parent::operator=(cmap);
293 293
        return *this;
294 294
      }
295 295
    };
296 296

	
297 297
    template <typename V>
298 298
    class EdgeMap : public GR::template EdgeMap<V> {
299 299
      typedef typename GR::template EdgeMap<V> Parent;
300 300

	
301 301
    public:
302 302
      explicit EdgeMap(const GraphAdaptorBase<GR>& adapter)
303 303
        : Parent(*adapter._graph) {}
304 304
      EdgeMap(const GraphAdaptorBase<GR>& adapter, const V& value)
305 305
        : Parent(*adapter._graph, value) {}
306 306

	
307 307
    private:
308 308
      EdgeMap& operator=(const EdgeMap& cmap) {
309 309
        return operator=<EdgeMap>(cmap);
310 310
      }
311 311

	
312 312
      template <typename CMap>
313 313
      EdgeMap& operator=(const CMap& cmap) {
314 314
        Parent::operator=(cmap);
315 315
        return *this;
316 316
      }
317 317
    };
318 318

	
319 319
  };
320 320

	
321 321
  template <typename DGR>
322 322
  class ReverseDigraphBase : public DigraphAdaptorBase<DGR> {
323 323
    typedef DigraphAdaptorBase<DGR> Parent;
324 324
  public:
325 325
    typedef DGR Digraph;
326 326
  protected:
327 327
    ReverseDigraphBase() : Parent() { }
328 328
  public:
329 329
    typedef typename Parent::Node Node;
330 330
    typedef typename Parent::Arc Arc;
331 331

	
332 332
    void firstIn(Arc& a, const Node& n) const { Parent::firstOut(a, n); }
333 333
    void firstOut(Arc& a, const Node& n ) const { Parent::firstIn(a, n); }
334 334

	
335 335
    void nextIn(Arc& a) const { Parent::nextOut(a); }
336 336
    void nextOut(Arc& a) const { Parent::nextIn(a); }
337 337

	
338 338
    Node source(const Arc& a) const { return Parent::target(a); }
339 339
    Node target(const Arc& a) const { return Parent::source(a); }
340 340

	
341 341
    Arc addArc(const Node& u, const Node& v) { return Parent::addArc(v, u); }
342 342

	
343 343
    typedef FindArcTagIndicator<DGR> FindArcTag;
344 344
    Arc findArc(const Node& u, const Node& v,
345 345
                const Arc& prev = INVALID) const {
346 346
      return Parent::findArc(v, u, prev);
347 347
    }
348 348

	
349 349
  };
350 350

	
351 351
  /// \ingroup graph_adaptors
352 352
  ///
353 353
  /// \brief Adaptor class for reversing the orientation of the arcs in
354 354
  /// a digraph.
355 355
  ///
356 356
  /// ReverseDigraph can be used for reversing the arcs in a digraph.
357 357
  /// It conforms to the \ref concepts::Digraph "Digraph" concept.
358 358
  ///
359 359
  /// The adapted digraph can also be modified through this adaptor
360 360
  /// by adding or removing nodes or arcs, unless the \c GR template
361 361
  /// parameter is set to be \c const.
362 362
  ///
363
  /// This class provides item counting in the same time as the adapted
364
  /// digraph structure.
365
  ///
363 366
  /// \tparam DGR The type of the adapted digraph.
364 367
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
365 368
  /// It can also be specified to be \c const.
366 369
  ///
367 370
  /// \note The \c Node and \c Arc types of this adaptor and the adapted
368 371
  /// digraph are convertible to each other.
369 372
  template<typename DGR>
370 373
#ifdef DOXYGEN
371 374
  class ReverseDigraph {
372 375
#else
373 376
  class ReverseDigraph :
374 377
    public DigraphAdaptorExtender<ReverseDigraphBase<DGR> > {
375 378
#endif
376 379
    typedef DigraphAdaptorExtender<ReverseDigraphBase<DGR> > Parent;
377 380
  public:
378 381
    /// The type of the adapted digraph.
379 382
    typedef DGR Digraph;
380 383
  protected:
381 384
    ReverseDigraph() { }
382 385
  public:
383 386

	
384 387
    /// \brief Constructor
385 388
    ///
386 389
    /// Creates a reverse digraph adaptor for the given digraph.
387 390
    explicit ReverseDigraph(DGR& digraph) {
388 391
      Parent::initialize(digraph);
389 392
    }
390 393
  };
391 394

	
392 395
  /// \brief Returns a read-only ReverseDigraph adaptor
393 396
  ///
394 397
  /// This function just returns a read-only \ref ReverseDigraph adaptor.
395 398
  /// \ingroup graph_adaptors
396 399
  /// \relates ReverseDigraph
397 400
  template<typename DGR>
398 401
  ReverseDigraph<const DGR> reverseDigraph(const DGR& digraph) {
399 402
    return ReverseDigraph<const DGR>(digraph);
400 403
  }
401 404

	
402 405

	
403 406
  template <typename DGR, typename NF, typename AF, bool ch = true>
404 407
  class SubDigraphBase : public DigraphAdaptorBase<DGR> {
405 408
    typedef DigraphAdaptorBase<DGR> Parent;
406 409
  public:
407 410
    typedef DGR Digraph;
408 411
    typedef NF NodeFilterMap;
409 412
    typedef AF ArcFilterMap;
410 413

	
411 414
    typedef SubDigraphBase Adaptor;
412 415
  protected:
413 416
    NF* _node_filter;
414 417
    AF* _arc_filter;
415 418
    SubDigraphBase()
416 419
      : Parent(), _node_filter(0), _arc_filter(0) { }
417 420

	
418 421
    void initialize(DGR& digraph, NF& node_filter, AF& arc_filter) {
419 422
      Parent::initialize(digraph);
420 423
      _node_filter = &node_filter;
421
      _arc_filter = &arc_filter;      
424
      _arc_filter = &arc_filter;
422 425
    }
423 426

	
424 427
  public:
425 428

	
426 429
    typedef typename Parent::Node Node;
427 430
    typedef typename Parent::Arc Arc;
428 431

	
429 432
    void first(Node& i) const {
430 433
      Parent::first(i);
431 434
      while (i != INVALID && !(*_node_filter)[i]) Parent::next(i);
432 435
    }
433 436

	
434 437
    void first(Arc& i) const {
435 438
      Parent::first(i);
436 439
      while (i != INVALID && (!(*_arc_filter)[i]
437 440
                              || !(*_node_filter)[Parent::source(i)]
438 441
                              || !(*_node_filter)[Parent::target(i)]))
439 442
        Parent::next(i);
440 443
    }
441 444

	
442 445
    void firstIn(Arc& i, const Node& n) const {
443 446
      Parent::firstIn(i, n);
444 447
      while (i != INVALID && (!(*_arc_filter)[i]
445 448
                              || !(*_node_filter)[Parent::source(i)]))
446 449
        Parent::nextIn(i);
447 450
    }
448 451

	
449 452
    void firstOut(Arc& i, const Node& n) const {
450 453
      Parent::firstOut(i, n);
451 454
      while (i != INVALID && (!(*_arc_filter)[i]
452 455
                              || !(*_node_filter)[Parent::target(i)]))
453 456
        Parent::nextOut(i);
454 457
    }
455 458

	
456 459
    void next(Node& i) const {
457 460
      Parent::next(i);
458 461
      while (i != INVALID && !(*_node_filter)[i]) Parent::next(i);
459 462
    }
460 463

	
461 464
    void next(Arc& i) const {
462 465
      Parent::next(i);
463 466
      while (i != INVALID && (!(*_arc_filter)[i]
464 467
                              || !(*_node_filter)[Parent::source(i)]
465 468
                              || !(*_node_filter)[Parent::target(i)]))
466 469
        Parent::next(i);
467 470
    }
468 471

	
469 472
    void nextIn(Arc& i) const {
470 473
      Parent::nextIn(i);
471 474
      while (i != INVALID && (!(*_arc_filter)[i]
472 475
                              || !(*_node_filter)[Parent::source(i)]))
473 476
        Parent::nextIn(i);
474 477
    }
475 478

	
476 479
    void nextOut(Arc& i) const {
477 480
      Parent::nextOut(i);
478 481
      while (i != INVALID && (!(*_arc_filter)[i]
479 482
                              || !(*_node_filter)[Parent::target(i)]))
480 483
        Parent::nextOut(i);
481 484
    }
482 485

	
483 486
    void status(const Node& n, bool v) const { _node_filter->set(n, v); }
484 487
    void status(const Arc& a, bool v) const { _arc_filter->set(a, v); }
485 488

	
486 489
    bool status(const Node& n) const { return (*_node_filter)[n]; }
487 490
    bool status(const Arc& a) const { return (*_arc_filter)[a]; }
488 491

	
489 492
    typedef False NodeNumTag;
490 493
    typedef False ArcNumTag;
491 494

	
492 495
    typedef FindArcTagIndicator<DGR> FindArcTag;
493 496
    Arc findArc(const Node& source, const Node& target,
494 497
                const Arc& prev = INVALID) const {
495 498
      if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
496 499
        return INVALID;
497 500
      }
498 501
      Arc arc = Parent::findArc(source, target, prev);
499 502
      while (arc != INVALID && !(*_arc_filter)[arc]) {
500 503
        arc = Parent::findArc(source, target, arc);
501 504
      }
502 505
      return arc;
503 506
    }
504 507

	
505 508
  public:
506 509

	
507 510
    template <typename V>
508
    class NodeMap 
509
      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>, 
510
	      LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> {
511
    class NodeMap
512
      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
513
              LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> {
511 514
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
512
	LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
515
        LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
513 516

	
514 517
    public:
515 518
      typedef V Value;
516 519

	
517 520
      NodeMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor)
518 521
        : Parent(adaptor) {}
519 522
      NodeMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor, const V& value)
520 523
        : Parent(adaptor, value) {}
521 524

	
522 525
    private:
523 526
      NodeMap& operator=(const NodeMap& cmap) {
524 527
        return operator=<NodeMap>(cmap);
525 528
      }
526 529

	
527 530
      template <typename CMap>
528 531
      NodeMap& operator=(const CMap& cmap) {
529 532
        Parent::operator=(cmap);
530 533
        return *this;
531 534
      }
532 535
    };
533 536

	
534 537
    template <typename V>
535
    class ArcMap 
538
    class ArcMap
536 539
      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
537
	      LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> {
540
              LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> {
538 541
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, ch>,
539 542
        LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent;
540 543

	
541 544
    public:
542 545
      typedef V Value;
543 546

	
544 547
      ArcMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor)
545 548
        : Parent(adaptor) {}
546 549
      ArcMap(const SubDigraphBase<DGR, NF, AF, ch>& adaptor, const V& value)
547 550
        : Parent(adaptor, value) {}
548 551

	
549 552
    private:
550 553
      ArcMap& operator=(const ArcMap& cmap) {
551 554
        return operator=<ArcMap>(cmap);
552 555
      }
553 556

	
554 557
      template <typename CMap>
555 558
      ArcMap& operator=(const CMap& cmap) {
556 559
        Parent::operator=(cmap);
557 560
        return *this;
558 561
      }
559 562
    };
560 563

	
561 564
  };
562 565

	
563 566
  template <typename DGR, typename NF, typename AF>
564 567
  class SubDigraphBase<DGR, NF, AF, false>
565 568
    : public DigraphAdaptorBase<DGR> {
566 569
    typedef DigraphAdaptorBase<DGR> Parent;
567 570
  public:
568 571
    typedef DGR Digraph;
569 572
    typedef NF NodeFilterMap;
570 573
    typedef AF ArcFilterMap;
571 574

	
572 575
    typedef SubDigraphBase Adaptor;
573 576
  protected:
574 577
    NF* _node_filter;
575 578
    AF* _arc_filter;
576 579
    SubDigraphBase()
577 580
      : Parent(), _node_filter(0), _arc_filter(0) { }
578 581

	
579 582
    void initialize(DGR& digraph, NF& node_filter, AF& arc_filter) {
580 583
      Parent::initialize(digraph);
581 584
      _node_filter = &node_filter;
582
      _arc_filter = &arc_filter;      
585
      _arc_filter = &arc_filter;
583 586
    }
584 587

	
585 588
  public:
586 589

	
587 590
    typedef typename Parent::Node Node;
588 591
    typedef typename Parent::Arc Arc;
589 592

	
590 593
    void first(Node& i) const {
591 594
      Parent::first(i);
592 595
      while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i);
593 596
    }
594 597

	
595 598
    void first(Arc& i) const {
596 599
      Parent::first(i);
597 600
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::next(i);
598 601
    }
599 602

	
600 603
    void firstIn(Arc& i, const Node& n) const {
601 604
      Parent::firstIn(i, n);
602 605
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextIn(i);
603 606
    }
604 607

	
605 608
    void firstOut(Arc& i, const Node& n) const {
606 609
      Parent::firstOut(i, n);
607 610
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextOut(i);
608 611
    }
609 612

	
610 613
    void next(Node& i) const {
611 614
      Parent::next(i);
612 615
      while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i);
613 616
    }
614 617
    void next(Arc& i) const {
615 618
      Parent::next(i);
616 619
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::next(i);
617 620
    }
618 621
    void nextIn(Arc& i) const {
619 622
      Parent::nextIn(i);
620 623
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextIn(i);
621 624
    }
622 625

	
623 626
    void nextOut(Arc& i) const {
624 627
      Parent::nextOut(i);
625 628
      while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextOut(i);
626 629
    }
627 630

	
628 631
    void status(const Node& n, bool v) const { _node_filter->set(n, v); }
629 632
    void status(const Arc& a, bool v) const { _arc_filter->set(a, v); }
630 633

	
631 634
    bool status(const Node& n) const { return (*_node_filter)[n]; }
632 635
    bool status(const Arc& a) const { return (*_arc_filter)[a]; }
633 636

	
634 637
    typedef False NodeNumTag;
635 638
    typedef False ArcNumTag;
636 639

	
637 640
    typedef FindArcTagIndicator<DGR> FindArcTag;
638 641
    Arc findArc(const Node& source, const Node& target,
639 642
                const Arc& prev = INVALID) const {
640 643
      if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
641 644
        return INVALID;
642 645
      }
643 646
      Arc arc = Parent::findArc(source, target, prev);
644 647
      while (arc != INVALID && !(*_arc_filter)[arc]) {
645 648
        arc = Parent::findArc(source, target, arc);
646 649
      }
647 650
      return arc;
648 651
    }
649 652

	
650 653
    template <typename V>
651
    class NodeMap 
654
    class NodeMap
652 655
      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
653 656
          LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> {
654
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>, 
657
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
655 658
        LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, NodeMap<V>)> Parent;
656 659

	
657 660
    public:
658 661
      typedef V Value;
659 662

	
660 663
      NodeMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor)
661 664
        : Parent(adaptor) {}
662 665
      NodeMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor, const V& value)
663 666
        : Parent(adaptor, value) {}
664 667

	
665 668
    private:
666 669
      NodeMap& operator=(const NodeMap& cmap) {
667 670
        return operator=<NodeMap>(cmap);
668 671
      }
669 672

	
670 673
      template <typename CMap>
671 674
      NodeMap& operator=(const CMap& cmap) {
672 675
        Parent::operator=(cmap);
673 676
        return *this;
674 677
      }
675 678
    };
676 679

	
677 680
    template <typename V>
678
    class ArcMap 
681
    class ArcMap
679 682
      : public SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
680 683
          LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> {
681 684
      typedef SubMapExtender<SubDigraphBase<DGR, NF, AF, false>,
682 685
        LEMON_SCOPE_FIX(DigraphAdaptorBase<DGR>, ArcMap<V>)> Parent;
683 686

	
684 687
    public:
685 688
      typedef V Value;
686 689

	
687 690
      ArcMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor)
688 691
        : Parent(adaptor) {}
689 692
      ArcMap(const SubDigraphBase<DGR, NF, AF, false>& adaptor, const V& value)
690 693
        : Parent(adaptor, value) {}
691 694

	
692 695
    private:
693 696
      ArcMap& operator=(const ArcMap& cmap) {
694 697
        return operator=<ArcMap>(cmap);
695 698
      }
696 699

	
697 700
      template <typename CMap>
698 701
      ArcMap& operator=(const CMap& cmap) {
699 702
        Parent::operator=(cmap);
700 703
        return *this;
701 704
      }
702 705
    };
703 706

	
704 707
  };
705 708

	
706 709
  /// \ingroup graph_adaptors
707 710
  ///
708 711
  /// \brief Adaptor class for hiding nodes and arcs in a digraph
709 712
  ///
710 713
  /// SubDigraph can be used for hiding nodes and arcs in a digraph.
711 714
  /// A \c bool node map and a \c bool arc map must be specified, which
712 715
  /// define the filters for nodes and arcs.
713 716
  /// Only the nodes and arcs with \c true filter value are
714 717
  /// shown in the subdigraph. The arcs that are incident to hidden
715 718
  /// nodes are also filtered out.
716 719
  /// This adaptor conforms to the \ref concepts::Digraph "Digraph" concept.
717 720
  ///
718 721
  /// The adapted digraph can also be modified through this adaptor
719 722
  /// by adding or removing nodes or arcs, unless the \c GR template
720 723
  /// parameter is set to be \c const.
721 724
  ///
725
  /// This class provides only linear time counting for nodes and arcs.
726
  ///
722 727
  /// \tparam DGR The type of the adapted digraph.
723 728
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
724 729
  /// It can also be specified to be \c const.
725 730
  /// \tparam NF The type of the node filter map.
726 731
  /// It must be a \c bool (or convertible) node map of the
727 732
  /// adapted digraph. The default type is
728 733
  /// \ref concepts::Digraph::NodeMap "DGR::NodeMap<bool>".
729 734
  /// \tparam AF The type of the arc filter map.
730 735
  /// It must be \c bool (or convertible) arc map of the
731 736
  /// adapted digraph. The default type is
732 737
  /// \ref concepts::Digraph::ArcMap "DGR::ArcMap<bool>".
733 738
  ///
734 739
  /// \note The \c Node and \c Arc types of this adaptor and the adapted
735 740
  /// digraph are convertible to each other.
736 741
  ///
737 742
  /// \see FilterNodes
738 743
  /// \see FilterArcs
739 744
#ifdef DOXYGEN
740 745
  template<typename DGR, typename NF, typename AF>
741 746
  class SubDigraph {
742 747
#else
743 748
  template<typename DGR,
744 749
           typename NF = typename DGR::template NodeMap<bool>,
745 750
           typename AF = typename DGR::template ArcMap<bool> >
746 751
  class SubDigraph :
747 752
    public DigraphAdaptorExtender<SubDigraphBase<DGR, NF, AF, true> > {
748 753
#endif
749 754
  public:
750 755
    /// The type of the adapted digraph.
751 756
    typedef DGR Digraph;
752 757
    /// The type of the node filter map.
753 758
    typedef NF NodeFilterMap;
754 759
    /// The type of the arc filter map.
755 760
    typedef AF ArcFilterMap;
756 761

	
757 762
    typedef DigraphAdaptorExtender<SubDigraphBase<DGR, NF, AF, true> >
758 763
      Parent;
759 764

	
760 765
    typedef typename Parent::Node Node;
761 766
    typedef typename Parent::Arc Arc;
762 767

	
763 768
  protected:
764 769
    SubDigraph() { }
765 770
  public:
766 771

	
767 772
    /// \brief Constructor
768 773
    ///
769 774
    /// Creates a subdigraph for the given digraph with the
770 775
    /// given node and arc filter maps.
771 776
    SubDigraph(DGR& digraph, NF& node_filter, AF& arc_filter) {
772 777
      Parent::initialize(digraph, node_filter, arc_filter);
773 778
    }
774 779

	
775 780
    /// \brief Sets the status of the given node
776 781
    ///
777 782
    /// This function sets the status of the given node.
778 783
    /// It is done by simply setting the assigned value of \c n
779 784
    /// to \c v in the node filter map.
780 785
    void status(const Node& n, bool v) const { Parent::status(n, v); }
781 786

	
782 787
    /// \brief Sets the status of the given arc
783 788
    ///
784 789
    /// This function sets the status of the given arc.
785 790
    /// It is done by simply setting the assigned value of \c a
786 791
    /// to \c v in the arc filter map.
787 792
    void status(const Arc& a, bool v) const { Parent::status(a, v); }
788 793

	
789 794
    /// \brief Returns the status of the given node
790 795
    ///
791 796
    /// This function returns the status of the given node.
792 797
    /// It is \c true if the given node is enabled (i.e. not hidden).
793 798
    bool status(const Node& n) const { return Parent::status(n); }
794 799

	
795 800
    /// \brief Returns the status of the given arc
796 801
    ///
797 802
    /// This function returns the status of the given arc.
798 803
    /// It is \c true if the given arc is enabled (i.e. not hidden).
799 804
    bool status(const Arc& a) const { return Parent::status(a); }
800 805

	
801 806
    /// \brief Disables the given node
802 807
    ///
803 808
    /// This function disables the given node in the subdigraph,
804 809
    /// so the iteration jumps over it.
805 810
    /// It is the same as \ref status() "status(n, false)".
806 811
    void disable(const Node& n) const { Parent::status(n, false); }
807 812

	
808 813
    /// \brief Disables the given arc
809 814
    ///
810 815
    /// This function disables the given arc in the subdigraph,
811 816
    /// so the iteration jumps over it.
812 817
    /// It is the same as \ref status() "status(a, false)".
813 818
    void disable(const Arc& a) const { Parent::status(a, false); }
814 819

	
815 820
    /// \brief Enables the given node
816 821
    ///
817 822
    /// This function enables the given node in the subdigraph.
818 823
    /// It is the same as \ref status() "status(n, true)".
819 824
    void enable(const Node& n) const { Parent::status(n, true); }
820 825

	
821 826
    /// \brief Enables the given arc
822 827
    ///
823 828
    /// This function enables the given arc in the subdigraph.
824 829
    /// It is the same as \ref status() "status(a, true)".
825 830
    void enable(const Arc& a) const { Parent::status(a, true); }
826 831

	
827 832
  };
828 833

	
829 834
  /// \brief Returns a read-only SubDigraph adaptor
830 835
  ///
831 836
  /// This function just returns a read-only \ref SubDigraph adaptor.
832 837
  /// \ingroup graph_adaptors
833 838
  /// \relates SubDigraph
834 839
  template<typename DGR, typename NF, typename AF>
835 840
  SubDigraph<const DGR, NF, AF>
836 841
  subDigraph(const DGR& digraph,
837 842
             NF& node_filter, AF& arc_filter) {
838 843
    return SubDigraph<const DGR, NF, AF>
839 844
      (digraph, node_filter, arc_filter);
840 845
  }
841 846

	
842 847
  template<typename DGR, typename NF, typename AF>
843 848
  SubDigraph<const DGR, const NF, AF>
844 849
  subDigraph(const DGR& digraph,
845 850
             const NF& node_filter, AF& arc_filter) {
846 851
    return SubDigraph<const DGR, const NF, AF>
847 852
      (digraph, node_filter, arc_filter);
848 853
  }
849 854

	
850 855
  template<typename DGR, typename NF, typename AF>
851 856
  SubDigraph<const DGR, NF, const AF>
852 857
  subDigraph(const DGR& digraph,
853 858
             NF& node_filter, const AF& arc_filter) {
854 859
    return SubDigraph<const DGR, NF, const AF>
855 860
      (digraph, node_filter, arc_filter);
856 861
  }
857 862

	
858 863
  template<typename DGR, typename NF, typename AF>
859 864
  SubDigraph<const DGR, const NF, const AF>
860 865
  subDigraph(const DGR& digraph,
861 866
             const NF& node_filter, const AF& arc_filter) {
862 867
    return SubDigraph<const DGR, const NF, const AF>
863 868
      (digraph, node_filter, arc_filter);
864 869
  }
865 870

	
866 871

	
867 872
  template <typename GR, typename NF, typename EF, bool ch = true>
868 873
  class SubGraphBase : public GraphAdaptorBase<GR> {
869 874
    typedef GraphAdaptorBase<GR> Parent;
870 875
  public:
871 876
    typedef GR Graph;
872 877
    typedef NF NodeFilterMap;
873 878
    typedef EF EdgeFilterMap;
874 879

	
875 880
    typedef SubGraphBase Adaptor;
876 881
  protected:
877 882

	
878 883
    NF* _node_filter;
879 884
    EF* _edge_filter;
880 885

	
881 886
    SubGraphBase()
882 887
      : Parent(), _node_filter(0), _edge_filter(0) { }
883 888

	
884 889
    void initialize(GR& graph, NF& node_filter, EF& edge_filter) {
885 890
      Parent::initialize(graph);
886 891
      _node_filter = &node_filter;
887 892
      _edge_filter = &edge_filter;
888 893
    }
889 894

	
890 895
  public:
891 896

	
892 897
    typedef typename Parent::Node Node;
893 898
    typedef typename Parent::Arc Arc;
894 899
    typedef typename Parent::Edge Edge;
895 900

	
896 901
    void first(Node& i) const {
897 902
      Parent::first(i);
898 903
      while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i);
899 904
    }
900 905

	
901 906
    void first(Arc& i) const {
902 907
      Parent::first(i);
903 908
      while (i!=INVALID && (!(*_edge_filter)[i]
904 909
                            || !(*_node_filter)[Parent::source(i)]
905 910
                            || !(*_node_filter)[Parent::target(i)]))
906 911
        Parent::next(i);
907 912
    }
908 913

	
909 914
    void first(Edge& i) const {
910 915
      Parent::first(i);
911 916
      while (i!=INVALID && (!(*_edge_filter)[i]
912 917
                            || !(*_node_filter)[Parent::u(i)]
913 918
                            || !(*_node_filter)[Parent::v(i)]))
914 919
        Parent::next(i);
915 920
    }
916 921

	
917 922
    void firstIn(Arc& i, const Node& n) const {
918 923
      Parent::firstIn(i, n);
919 924
      while (i!=INVALID && (!(*_edge_filter)[i]
920 925
                            || !(*_node_filter)[Parent::source(i)]))
921 926
        Parent::nextIn(i);
922 927
    }
923 928

	
924 929
    void firstOut(Arc& i, const Node& n) const {
925 930
      Parent::firstOut(i, n);
926 931
      while (i!=INVALID && (!(*_edge_filter)[i]
927 932
                            || !(*_node_filter)[Parent::target(i)]))
928 933
        Parent::nextOut(i);
929 934
    }
930 935

	
931 936
    void firstInc(Edge& i, bool& d, const Node& n) const {
932 937
      Parent::firstInc(i, d, n);
933 938
      while (i!=INVALID && (!(*_edge_filter)[i]
934 939
                            || !(*_node_filter)[Parent::u(i)]
935 940
                            || !(*_node_filter)[Parent::v(i)]))
936 941
        Parent::nextInc(i, d);
937 942
    }
938 943

	
939 944
    void next(Node& i) const {
940 945
      Parent::next(i);
941 946
      while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i);
942 947
    }
943 948

	
944 949
    void next(Arc& i) const {
945 950
      Parent::next(i);
946 951
      while (i!=INVALID && (!(*_edge_filter)[i]
947 952
                            || !(*_node_filter)[Parent::source(i)]
948 953
                            || !(*_node_filter)[Parent::target(i)]))
949 954
        Parent::next(i);
950 955
    }
951 956

	
952 957
    void next(Edge& i) const {
953 958
      Parent::next(i);
954 959
      while (i!=INVALID && (!(*_edge_filter)[i]
955 960
                            || !(*_node_filter)[Parent::u(i)]
956 961
                            || !(*_node_filter)[Parent::v(i)]))
957 962
        Parent::next(i);
958 963
    }
959 964

	
960 965
    void nextIn(Arc& i) const {
961 966
      Parent::nextIn(i);
962 967
      while (i!=INVALID && (!(*_edge_filter)[i]
963 968
                            || !(*_node_filter)[Parent::source(i)]))
964 969
        Parent::nextIn(i);
965 970
    }
966 971

	
967 972
    void nextOut(Arc& i) const {
968 973
      Parent::nextOut(i);
969 974
      while (i!=INVALID && (!(*_edge_filter)[i]
970 975
                            || !(*_node_filter)[Parent::target(i)]))
971 976
        Parent::nextOut(i);
972 977
    }
973 978

	
974 979
    void nextInc(Edge& i, bool& d) const {
975 980
      Parent::nextInc(i, d);
976 981
      while (i!=INVALID && (!(*_edge_filter)[i]
977 982
                            || !(*_node_filter)[Parent::u(i)]
978 983
                            || !(*_node_filter)[Parent::v(i)]))
979 984
        Parent::nextInc(i, d);
980 985
    }
981 986

	
982 987
    void status(const Node& n, bool v) const { _node_filter->set(n, v); }
983 988
    void status(const Edge& e, bool v) const { _edge_filter->set(e, v); }
984 989

	
985 990
    bool status(const Node& n) const { return (*_node_filter)[n]; }
986 991
    bool status(const Edge& e) const { return (*_edge_filter)[e]; }
987 992

	
988 993
    typedef False NodeNumTag;
989 994
    typedef False ArcNumTag;
990 995
    typedef False EdgeNumTag;
991 996

	
992 997
    typedef FindArcTagIndicator<Graph> FindArcTag;
993 998
    Arc findArc(const Node& u, const Node& v,
994 999
                const Arc& prev = INVALID) const {
995 1000
      if (!(*_node_filter)[u] || !(*_node_filter)[v]) {
996 1001
        return INVALID;
997 1002
      }
998 1003
      Arc arc = Parent::findArc(u, v, prev);
999 1004
      while (arc != INVALID && !(*_edge_filter)[arc]) {
1000 1005
        arc = Parent::findArc(u, v, arc);
1001 1006
      }
1002 1007
      return arc;
1003 1008
    }
1004 1009

	
1005 1010
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
1006 1011
    Edge findEdge(const Node& u, const Node& v,
1007 1012
                  const Edge& prev = INVALID) const {
1008 1013
      if (!(*_node_filter)[u] || !(*_node_filter)[v]) {
1009 1014
        return INVALID;
1010 1015
      }
1011 1016
      Edge edge = Parent::findEdge(u, v, prev);
1012 1017
      while (edge != INVALID && !(*_edge_filter)[edge]) {
1013 1018
        edge = Parent::findEdge(u, v, edge);
1014 1019
      }
1015 1020
      return edge;
1016 1021
    }
1017 1022

	
1018 1023
    template <typename V>
1019
    class NodeMap 
1024
    class NodeMap
1020 1025
      : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
1021 1026
          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> {
1022
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
1027
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
1023 1028
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent;
1024 1029

	
1025 1030
    public:
1026 1031
      typedef V Value;
1027 1032

	
1028 1033
      NodeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor)
1029 1034
        : Parent(adaptor) {}
1030 1035
      NodeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value)
1031 1036
        : Parent(adaptor, value) {}
1032 1037

	
1033 1038
    private:
1034 1039
      NodeMap& operator=(const NodeMap& cmap) {
1035 1040
        return operator=<NodeMap>(cmap);
1036 1041
      }
1037 1042

	
1038 1043
      template <typename CMap>
1039 1044
      NodeMap& operator=(const CMap& cmap) {
1040 1045
        Parent::operator=(cmap);
1041 1046
        return *this;
1042 1047
      }
1043 1048
    };
1044 1049

	
1045 1050
    template <typename V>
1046
    class ArcMap 
1051
    class ArcMap
1047 1052
      : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
1048 1053
          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> {
1049
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
1054
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
1050 1055
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent;
1051 1056

	
1052 1057
    public:
1053 1058
      typedef V Value;
1054 1059

	
1055 1060
      ArcMap(const SubGraphBase<GR, NF, EF, ch>& adaptor)
1056 1061
        : Parent(adaptor) {}
1057 1062
      ArcMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value)
1058 1063
        : Parent(adaptor, value) {}
1059 1064

	
1060 1065
    private:
1061 1066
      ArcMap& operator=(const ArcMap& cmap) {
1062 1067
        return operator=<ArcMap>(cmap);
1063 1068
      }
1064 1069

	
1065 1070
      template <typename CMap>
1066 1071
      ArcMap& operator=(const CMap& cmap) {
1067 1072
        Parent::operator=(cmap);
1068 1073
        return *this;
1069 1074
      }
1070 1075
    };
1071 1076

	
1072 1077
    template <typename V>
1073
    class EdgeMap 
1078
    class EdgeMap
1074 1079
      : public SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
1075 1080
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> {
1076
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>, 
1081
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, ch>,
1077 1082
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
1078 1083

	
1079 1084
    public:
1080 1085
      typedef V Value;
1081 1086

	
1082 1087
      EdgeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor)
1083 1088
        : Parent(adaptor) {}
1084 1089

	
1085 1090
      EdgeMap(const SubGraphBase<GR, NF, EF, ch>& adaptor, const V& value)
1086 1091
        : Parent(adaptor, value) {}
1087 1092

	
1088 1093
    private:
1089 1094
      EdgeMap& operator=(const EdgeMap& cmap) {
1090 1095
        return operator=<EdgeMap>(cmap);
1091 1096
      }
1092 1097

	
1093 1098
      template <typename CMap>
1094 1099
      EdgeMap& operator=(const CMap& cmap) {
1095 1100
        Parent::operator=(cmap);
1096 1101
        return *this;
1097 1102
      }
1098 1103
    };
1099 1104

	
1100 1105
  };
1101 1106

	
1102 1107
  template <typename GR, typename NF, typename EF>
1103 1108
  class SubGraphBase<GR, NF, EF, false>
1104 1109
    : public GraphAdaptorBase<GR> {
1105 1110
    typedef GraphAdaptorBase<GR> Parent;
1106 1111
  public:
1107 1112
    typedef GR Graph;
1108 1113
    typedef NF NodeFilterMap;
1109 1114
    typedef EF EdgeFilterMap;
1110 1115

	
1111 1116
    typedef SubGraphBase Adaptor;
1112 1117
  protected:
1113 1118
    NF* _node_filter;
1114 1119
    EF* _edge_filter;
1115
    SubGraphBase() 
1116
	  : Parent(), _node_filter(0), _edge_filter(0) { }
1120
    SubGraphBase()
1121
          : Parent(), _node_filter(0), _edge_filter(0) { }
1117 1122

	
1118 1123
    void initialize(GR& graph, NF& node_filter, EF& edge_filter) {
1119 1124
      Parent::initialize(graph);
1120 1125
      _node_filter = &node_filter;
1121 1126
      _edge_filter = &edge_filter;
1122 1127
    }
1123 1128

	
1124 1129
  public:
1125 1130

	
1126 1131
    typedef typename Parent::Node Node;
1127 1132
    typedef typename Parent::Arc Arc;
1128 1133
    typedef typename Parent::Edge Edge;
1129 1134

	
1130 1135
    void first(Node& i) const {
1131 1136
      Parent::first(i);
1132 1137
      while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i);
1133 1138
    }
1134 1139

	
1135 1140
    void first(Arc& i) const {
1136 1141
      Parent::first(i);
1137 1142
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::next(i);
1138 1143
    }
1139 1144

	
1140 1145
    void first(Edge& i) const {
1141 1146
      Parent::first(i);
1142 1147
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::next(i);
1143 1148
    }
1144 1149

	
1145 1150
    void firstIn(Arc& i, const Node& n) const {
1146 1151
      Parent::firstIn(i, n);
1147 1152
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::nextIn(i);
1148 1153
    }
1149 1154

	
1150 1155
    void firstOut(Arc& i, const Node& n) const {
1151 1156
      Parent::firstOut(i, n);
1152 1157
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::nextOut(i);
1153 1158
    }
1154 1159

	
1155 1160
    void firstInc(Edge& i, bool& d, const Node& n) const {
1156 1161
      Parent::firstInc(i, d, n);
1157 1162
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::nextInc(i, d);
1158 1163
    }
1159 1164

	
1160 1165
    void next(Node& i) const {
1161 1166
      Parent::next(i);
1162 1167
      while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i);
1163 1168
    }
1164 1169
    void next(Arc& i) const {
1165 1170
      Parent::next(i);
1166 1171
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::next(i);
1167 1172
    }
1168 1173
    void next(Edge& i) const {
1169 1174
      Parent::next(i);
1170 1175
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::next(i);
1171 1176
    }
1172 1177
    void nextIn(Arc& i) const {
1173 1178
      Parent::nextIn(i);
1174 1179
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::nextIn(i);
1175 1180
    }
1176 1181

	
1177 1182
    void nextOut(Arc& i) const {
1178 1183
      Parent::nextOut(i);
1179 1184
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::nextOut(i);
1180 1185
    }
1181 1186
    void nextInc(Edge& i, bool& d) const {
1182 1187
      Parent::nextInc(i, d);
1183 1188
      while (i!=INVALID && !(*_edge_filter)[i]) Parent::nextInc(i, d);
1184 1189
    }
1185 1190

	
1186 1191
    void status(const Node& n, bool v) const { _node_filter->set(n, v); }
1187 1192
    void status(const Edge& e, bool v) const { _edge_filter->set(e, v); }
1188 1193

	
1189 1194
    bool status(const Node& n) const { return (*_node_filter)[n]; }
1190 1195
    bool status(const Edge& e) const { return (*_edge_filter)[e]; }
1191 1196

	
1192 1197
    typedef False NodeNumTag;
1193 1198
    typedef False ArcNumTag;
1194 1199
    typedef False EdgeNumTag;
1195 1200

	
1196 1201
    typedef FindArcTagIndicator<Graph> FindArcTag;
1197 1202
    Arc findArc(const Node& u, const Node& v,
1198 1203
                const Arc& prev = INVALID) const {
1199 1204
      Arc arc = Parent::findArc(u, v, prev);
1200 1205
      while (arc != INVALID && !(*_edge_filter)[arc]) {
1201 1206
        arc = Parent::findArc(u, v, arc);
1202 1207
      }
1203 1208
      return arc;
1204 1209
    }
1205 1210

	
1206 1211
    typedef FindEdgeTagIndicator<Graph> FindEdgeTag;
1207 1212
    Edge findEdge(const Node& u, const Node& v,
1208 1213
                  const Edge& prev = INVALID) const {
1209 1214
      Edge edge = Parent::findEdge(u, v, prev);
1210 1215
      while (edge != INVALID && !(*_edge_filter)[edge]) {
1211 1216
        edge = Parent::findEdge(u, v, edge);
1212 1217
      }
1213 1218
      return edge;
1214 1219
    }
1215 1220

	
1216 1221
    template <typename V>
1217
    class NodeMap 
1222
    class NodeMap
1218 1223
      : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
1219 1224
          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> {
1220
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
1225
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>,
1221 1226
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, NodeMap<V>)> Parent;
1222 1227

	
1223 1228
    public:
1224 1229
      typedef V Value;
1225 1230

	
1226 1231
      NodeMap(const SubGraphBase<GR, NF, EF, false>& adaptor)
1227 1232
        : Parent(adaptor) {}
1228 1233
      NodeMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value)
1229 1234
        : Parent(adaptor, value) {}
1230 1235

	
1231 1236
    private:
1232 1237
      NodeMap& operator=(const NodeMap& cmap) {
1233 1238
        return operator=<NodeMap>(cmap);
1234 1239
      }
1235 1240

	
1236 1241
      template <typename CMap>
1237 1242
      NodeMap& operator=(const CMap& cmap) {
1238 1243
        Parent::operator=(cmap);
1239 1244
        return *this;
1240 1245
      }
1241 1246
    };
1242 1247

	
1243 1248
    template <typename V>
1244
    class ArcMap 
1249
    class ArcMap
1245 1250
      : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
1246 1251
          LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> {
1247
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
1252
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>,
1248 1253
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, ArcMap<V>)> Parent;
1249 1254

	
1250 1255
    public:
1251 1256
      typedef V Value;
1252 1257

	
1253 1258
      ArcMap(const SubGraphBase<GR, NF, EF, false>& adaptor)
1254 1259
        : Parent(adaptor) {}
1255 1260
      ArcMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value)
1256 1261
        : Parent(adaptor, value) {}
1257 1262

	
1258 1263
    private:
1259 1264
      ArcMap& operator=(const ArcMap& cmap) {
1260 1265
        return operator=<ArcMap>(cmap);
1261 1266
      }
1262 1267

	
1263 1268
      template <typename CMap>
1264 1269
      ArcMap& operator=(const CMap& cmap) {
1265 1270
        Parent::operator=(cmap);
1266 1271
        return *this;
1267 1272
      }
1268 1273
    };
1269 1274

	
1270 1275
    template <typename V>
1271
    class EdgeMap 
1276
    class EdgeMap
1272 1277
      : public SubMapExtender<SubGraphBase<GR, NF, EF, false>,
1273 1278
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> {
1274
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>, 
1275
	LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
1279
      typedef SubMapExtender<SubGraphBase<GR, NF, EF, false>,
1280
        LEMON_SCOPE_FIX(GraphAdaptorBase<GR>, EdgeMap<V>)> Parent;
1276 1281

	
1277 1282
    public:
1278 1283
      typedef V Value;
1279 1284

	
1280 1285
      EdgeMap(const SubGraphBase<GR, NF, EF, false>& adaptor)
1281 1286
        : Parent(adaptor) {}
1282 1287

	
1283 1288
      EdgeMap(const SubGraphBase<GR, NF, EF, false>& adaptor, const V& value)
1284 1289
        : Parent(adaptor, value) {}
1285 1290

	
1286 1291
    private:
1287 1292
      EdgeMap& operator=(const EdgeMap& cmap) {
1288 1293
        return operator=<EdgeMap>(cmap);
1289 1294
      }
1290 1295

	
1291 1296
      template <typename CMap>
1292 1297
      EdgeMap& operator=(const CMap& cmap) {
1293 1298
        Parent::operator=(cmap);
1294 1299
        return *this;
1295 1300
      }
1296 1301
    };
1297 1302

	
1298 1303
  };
1299 1304

	
1300 1305
  /// \ingroup graph_adaptors
1301 1306
  ///
1302 1307
  /// \brief Adaptor class for hiding nodes and edges in an undirected
1303 1308
  /// graph.
1304 1309
  ///
1305 1310
  /// SubGraph can be used for hiding nodes and edges in a graph.
1306 1311
  /// A \c bool node map and a \c bool edge map must be specified, which
1307 1312
  /// define the filters for nodes and edges.
1308 1313
  /// Only the nodes and edges with \c true filter value are
1309 1314
  /// shown in the subgraph. The edges that are incident to hidden
1310 1315
  /// nodes are also filtered out.
1311 1316
  /// This adaptor conforms to the \ref concepts::Graph "Graph" concept.
1312 1317
  ///
1313 1318
  /// The adapted graph can also be modified through this adaptor
1314 1319
  /// by adding or removing nodes or edges, unless the \c GR template
1315 1320
  /// parameter is set to be \c const.
1316 1321
  ///
1322
  /// This class provides only linear time counting for nodes, edges and arcs.
1323
  ///
1317 1324
  /// \tparam GR The type of the adapted graph.
1318 1325
  /// It must conform to the \ref concepts::Graph "Graph" concept.
1319 1326
  /// It can also be specified to be \c const.
1320 1327
  /// \tparam NF The type of the node filter map.
1321 1328
  /// It must be a \c bool (or convertible) node map of the
1322 1329
  /// adapted graph. The default type is
1323 1330
  /// \ref concepts::Graph::NodeMap "GR::NodeMap<bool>".
1324 1331
  /// \tparam EF The type of the edge filter map.
1325 1332
  /// It must be a \c bool (or convertible) edge map of the
1326 1333
  /// adapted graph. The default type is
1327 1334
  /// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>".
1328 1335
  ///
1329 1336
  /// \note The \c Node, \c Edge and \c Arc types of this adaptor and the
1330 1337
  /// adapted graph are convertible to each other.
1331 1338
  ///
1332 1339
  /// \see FilterNodes
1333 1340
  /// \see FilterEdges
1334 1341
#ifdef DOXYGEN
1335 1342
  template<typename GR, typename NF, typename EF>
1336 1343
  class SubGraph {
1337 1344
#else
1338 1345
  template<typename GR,
1339 1346
           typename NF = typename GR::template NodeMap<bool>,
1340 1347
           typename EF = typename GR::template EdgeMap<bool> >
1341 1348
  class SubGraph :
1342 1349
    public GraphAdaptorExtender<SubGraphBase<GR, NF, EF, true> > {
1343 1350
#endif
1344 1351
  public:
1345 1352
    /// The type of the adapted graph.
1346 1353
    typedef GR Graph;
1347 1354
    /// The type of the node filter map.
1348 1355
    typedef NF NodeFilterMap;
1349 1356
    /// The type of the edge filter map.
1350 1357
    typedef EF EdgeFilterMap;
1351 1358

	
1352 1359
    typedef GraphAdaptorExtender<SubGraphBase<GR, NF, EF, true> >
1353 1360
      Parent;
1354 1361

	
1355 1362
    typedef typename Parent::Node Node;
1356 1363
    typedef typename Parent::Edge Edge;
1357 1364

	
1358 1365
  protected:
1359 1366
    SubGraph() { }
1360 1367
  public:
1361 1368

	
1362 1369
    /// \brief Constructor
1363 1370
    ///
1364 1371
    /// Creates a subgraph for the given graph with the given node
1365 1372
    /// and edge filter maps.
1366 1373
    SubGraph(GR& graph, NF& node_filter, EF& edge_filter) {
1367 1374
      initialize(graph, node_filter, edge_filter);
1368 1375
    }
1369 1376

	
1370 1377
    /// \brief Sets the status of the given node
1371 1378
    ///
1372 1379
    /// This function sets the status of the given node.
1373 1380
    /// It is done by simply setting the assigned value of \c n
1374 1381
    /// to \c v in the node filter map.
1375 1382
    void status(const Node& n, bool v) const { Parent::status(n, v); }
1376 1383

	
1377 1384
    /// \brief Sets the status of the given edge
1378 1385
    ///
1379 1386
    /// This function sets the status of the given edge.
1380 1387
    /// It is done by simply setting the assigned value of \c e
1381 1388
    /// to \c v in the edge filter map.
1382 1389
    void status(const Edge& e, bool v) const { Parent::status(e, v); }
1383 1390

	
1384 1391
    /// \brief Returns the status of the given node
1385 1392
    ///
1386 1393
    /// This function returns the status of the given node.
1387 1394
    /// It is \c true if the given node is enabled (i.e. not hidden).
1388 1395
    bool status(const Node& n) const { return Parent::status(n); }
1389 1396

	
1390 1397
    /// \brief Returns the status of the given edge
1391 1398
    ///
1392 1399
    /// This function returns the status of the given edge.
1393 1400
    /// It is \c true if the given edge is enabled (i.e. not hidden).
1394 1401
    bool status(const Edge& e) const { return Parent::status(e); }
1395 1402

	
1396 1403
    /// \brief Disables the given node
1397 1404
    ///
1398 1405
    /// This function disables the given node in the subdigraph,
1399 1406
    /// so the iteration jumps over it.
1400 1407
    /// It is the same as \ref status() "status(n, false)".
1401 1408
    void disable(const Node& n) const { Parent::status(n, false); }
1402 1409

	
1403 1410
    /// \brief Disables the given edge
1404 1411
    ///
1405 1412
    /// This function disables the given edge in the subgraph,
1406 1413
    /// so the iteration jumps over it.
1407 1414
    /// It is the same as \ref status() "status(e, false)".
1408 1415
    void disable(const Edge& e) const { Parent::status(e, false); }
1409 1416

	
1410 1417
    /// \brief Enables the given node
1411 1418
    ///
1412 1419
    /// This function enables the given node in the subdigraph.
1413 1420
    /// It is the same as \ref status() "status(n, true)".
1414 1421
    void enable(const Node& n) const { Parent::status(n, true); }
1415 1422

	
1416 1423
    /// \brief Enables the given edge
1417 1424
    ///
1418 1425
    /// This function enables the given edge in the subgraph.
1419 1426
    /// It is the same as \ref status() "status(e, true)".
1420 1427
    void enable(const Edge& e) const { Parent::status(e, true); }
1421 1428

	
1422 1429
  };
1423 1430

	
1424 1431
  /// \brief Returns a read-only SubGraph adaptor
1425 1432
  ///
1426 1433
  /// This function just returns a read-only \ref SubGraph adaptor.
1427 1434
  /// \ingroup graph_adaptors
1428 1435
  /// \relates SubGraph
1429 1436
  template<typename GR, typename NF, typename EF>
1430 1437
  SubGraph<const GR, NF, EF>
1431 1438
  subGraph(const GR& graph, NF& node_filter, EF& edge_filter) {
1432 1439
    return SubGraph<const GR, NF, EF>
1433 1440
      (graph, node_filter, edge_filter);
1434 1441
  }
1435 1442

	
1436 1443
  template<typename GR, typename NF, typename EF>
1437 1444
  SubGraph<const GR, const NF, EF>
1438 1445
  subGraph(const GR& graph, const NF& node_filter, EF& edge_filter) {
1439 1446
    return SubGraph<const GR, const NF, EF>
1440 1447
      (graph, node_filter, edge_filter);
1441 1448
  }
1442 1449

	
1443 1450
  template<typename GR, typename NF, typename EF>
1444 1451
  SubGraph<const GR, NF, const EF>
1445 1452
  subGraph(const GR& graph, NF& node_filter, const EF& edge_filter) {
1446 1453
    return SubGraph<const GR, NF, const EF>
1447 1454
      (graph, node_filter, edge_filter);
1448 1455
  }
1449 1456

	
1450 1457
  template<typename GR, typename NF, typename EF>
1451 1458
  SubGraph<const GR, const NF, const EF>
1452 1459
  subGraph(const GR& graph, const NF& node_filter, const EF& edge_filter) {
1453 1460
    return SubGraph<const GR, const NF, const EF>
1454 1461
      (graph, node_filter, edge_filter);
1455 1462
  }
1456 1463

	
1457 1464

	
1458 1465
  /// \ingroup graph_adaptors
1459 1466
  ///
1460 1467
  /// \brief Adaptor class for hiding nodes in a digraph or a graph.
1461 1468
  ///
1462 1469
  /// FilterNodes adaptor can be used for hiding nodes in a digraph or a
1463 1470
  /// graph. A \c bool node map must be specified, which defines the filter
1464 1471
  /// for the nodes. Only the nodes with \c true filter value and the
1465 1472
  /// arcs/edges incident to nodes both with \c true filter value are shown
1466 1473
  /// in the subgraph. This adaptor conforms to the \ref concepts::Digraph
1467 1474
  /// "Digraph" concept or the \ref concepts::Graph "Graph" concept
1468 1475
  /// depending on the \c GR template parameter.
1469 1476
  ///
1470 1477
  /// The adapted (di)graph can also be modified through this adaptor
1471 1478
  /// by adding or removing nodes or arcs/edges, unless the \c GR template
1472 1479
  /// parameter is set to be \c const.
1473 1480
  ///
1481
  /// This class provides only linear time item counting.
1482
  ///
1474 1483
  /// \tparam GR The type of the adapted digraph or graph.
1475 1484
  /// It must conform to the \ref concepts::Digraph "Digraph" concept
1476 1485
  /// or the \ref concepts::Graph "Graph" concept.
1477 1486
  /// It can also be specified to be \c const.
1478 1487
  /// \tparam NF The type of the node filter map.
1479 1488
  /// It must be a \c bool (or convertible) node map of the
1480 1489
  /// adapted (di)graph. The default type is
1481 1490
  /// \ref concepts::Graph::NodeMap "GR::NodeMap<bool>".
1482 1491
  ///
1483 1492
  /// \note The \c Node and <tt>Arc/Edge</tt> types of this adaptor and the
1484 1493
  /// adapted (di)graph are convertible to each other.
1485 1494
#ifdef DOXYGEN
1486 1495
  template<typename GR, typename NF>
1487 1496
  class FilterNodes {
1488 1497
#else
1489 1498
  template<typename GR,
1490 1499
           typename NF = typename GR::template NodeMap<bool>,
1491 1500
           typename Enable = void>
1492 1501
  class FilterNodes :
1493 1502
    public DigraphAdaptorExtender<
1494 1503
      SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >,
1495 1504
                     true> > {
1496 1505
#endif
1497 1506
    typedef DigraphAdaptorExtender<
1498
      SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >, 
1507
      SubDigraphBase<GR, NF, ConstMap<typename GR::Arc, Const<bool, true> >,
1499 1508
                     true> > Parent;
1500 1509

	
1501 1510
  public:
1502 1511

	
1503 1512
    typedef GR Digraph;
1504 1513
    typedef NF NodeFilterMap;
1505 1514

	
1506 1515
    typedef typename Parent::Node Node;
1507 1516

	
1508 1517
  protected:
1509 1518
    ConstMap<typename Digraph::Arc, Const<bool, true> > const_true_map;
1510 1519

	
1511 1520
    FilterNodes() : const_true_map() {}
1512 1521

	
1513 1522
  public:
1514 1523

	
1515 1524
    /// \brief Constructor
1516 1525
    ///
1517 1526
    /// Creates a subgraph for the given digraph or graph with the
1518 1527
    /// given node filter map.
1519
    FilterNodes(GR& graph, NF& node_filter) 
1528
    FilterNodes(GR& graph, NF& node_filter)
1520 1529
      : Parent(), const_true_map()
1521 1530
    {
1522 1531
      Parent::initialize(graph, node_filter, const_true_map);
1523 1532
    }
1524 1533

	
1525 1534
    /// \brief Sets the status of the given node
1526 1535
    ///
1527 1536
    /// This function sets the status of the given node.
1528 1537
    /// It is done by simply setting the assigned value of \c n
1529 1538
    /// to \c v in the node filter map.
1530 1539
    void status(const Node& n, bool v) const { Parent::status(n, v); }
1531 1540

	
1532 1541
    /// \brief Returns the status of the given node
1533 1542
    ///
1534 1543
    /// This function returns the status of the given node.
1535 1544
    /// It is \c true if the given node is enabled (i.e. not hidden).
1536 1545
    bool status(const Node& n) const { return Parent::status(n); }
1537 1546

	
1538 1547
    /// \brief Disables the given node
1539 1548
    ///
1540 1549
    /// This function disables the given node, so the iteration
1541 1550
    /// jumps over it.
1542 1551
    /// It is the same as \ref status() "status(n, false)".
1543 1552
    void disable(const Node& n) const { Parent::status(n, false); }
1544 1553

	
1545 1554
    /// \brief Enables the given node
1546 1555
    ///
1547 1556
    /// This function enables the given node.
1548 1557
    /// It is the same as \ref status() "status(n, true)".
1549 1558
    void enable(const Node& n) const { Parent::status(n, true); }
1550 1559

	
1551 1560
  };
1552 1561

	
1553 1562
  template<typename GR, typename NF>
1554 1563
  class FilterNodes<GR, NF,
1555 1564
                    typename enable_if<UndirectedTagIndicator<GR> >::type> :
1556 1565
    public GraphAdaptorExtender<
1557
      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 
1566
      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >,
1558 1567
                   true> > {
1559 1568

	
1560 1569
    typedef GraphAdaptorExtender<
1561
      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >, 
1570
      SubGraphBase<GR, NF, ConstMap<typename GR::Edge, Const<bool, true> >,
1562 1571
                   true> > Parent;
1563 1572

	
1564 1573
  public:
1565 1574

	
1566 1575
    typedef GR Graph;
1567 1576
    typedef NF NodeFilterMap;
1568 1577

	
1569 1578
    typedef typename Parent::Node Node;
1570 1579

	
1571 1580
  protected:
1572 1581
    ConstMap<typename GR::Edge, Const<bool, true> > const_true_map;
1573 1582

	
1574 1583
    FilterNodes() : const_true_map() {}
1575 1584

	
1576 1585
  public:
1577 1586

	
1578 1587
    FilterNodes(GR& graph, NodeFilterMap& node_filter) :
1579 1588
      Parent(), const_true_map() {
1580 1589
      Parent::initialize(graph, node_filter, const_true_map);
1581 1590
    }
1582 1591

	
1583 1592
    void status(const Node& n, bool v) const { Parent::status(n, v); }
1584 1593
    bool status(const Node& n) const { return Parent::status(n); }
1585 1594
    void disable(const Node& n) const { Parent::status(n, false); }
1586 1595
    void enable(const Node& n) const { Parent::status(n, true); }
1587 1596

	
1588 1597
  };
1589 1598

	
1590 1599

	
1591 1600
  /// \brief Returns a read-only FilterNodes adaptor
1592 1601
  ///
1593 1602
  /// This function just returns a read-only \ref FilterNodes adaptor.
1594 1603
  /// \ingroup graph_adaptors
1595 1604
  /// \relates FilterNodes
1596 1605
  template<typename GR, typename NF>
1597 1606
  FilterNodes<const GR, NF>
1598 1607
  filterNodes(const GR& graph, NF& node_filter) {
1599 1608
    return FilterNodes<const GR, NF>(graph, node_filter);
1600 1609
  }
1601 1610

	
1602 1611
  template<typename GR, typename NF>
1603 1612
  FilterNodes<const GR, const NF>
1604 1613
  filterNodes(const GR& graph, const NF& node_filter) {
1605 1614
    return FilterNodes<const GR, const NF>(graph, node_filter);
1606 1615
  }
1607 1616

	
1608 1617
  /// \ingroup graph_adaptors
1609 1618
  ///
1610 1619
  /// \brief Adaptor class for hiding arcs in a digraph.
1611 1620
  ///
1612 1621
  /// FilterArcs adaptor can be used for hiding arcs in a digraph.
1613 1622
  /// A \c bool arc map must be specified, which defines the filter for
1614 1623
  /// the arcs. Only the arcs with \c true filter value are shown in the
1615 1624
  /// subdigraph. This adaptor conforms to the \ref concepts::Digraph
1616 1625
  /// "Digraph" concept.
1617 1626
  ///
1618 1627
  /// The adapted digraph can also be modified through this adaptor
1619 1628
  /// by adding or removing nodes or arcs, unless the \c GR template
1620 1629
  /// parameter is set to be \c const.
1621 1630
  ///
1631
  /// This class provides only linear time counting for nodes and arcs.
1632
  ///
1622 1633
  /// \tparam DGR The type of the adapted digraph.
1623 1634
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
1624 1635
  /// It can also be specified to be \c const.
1625 1636
  /// \tparam AF The type of the arc filter map.
1626 1637
  /// It must be a \c bool (or convertible) arc map of the
1627 1638
  /// adapted digraph. The default type is
1628 1639
  /// \ref concepts::Digraph::ArcMap "DGR::ArcMap<bool>".
1629 1640
  ///
1630 1641
  /// \note The \c Node and \c Arc types of this adaptor and the adapted
1631 1642
  /// digraph are convertible to each other.
1632 1643
#ifdef DOXYGEN
1633 1644
  template<typename DGR,
1634 1645
           typename AF>
1635 1646
  class FilterArcs {
1636 1647
#else
1637 1648
  template<typename DGR,
1638 1649
           typename AF = typename DGR::template ArcMap<bool> >
1639 1650
  class FilterArcs :
1640 1651
    public DigraphAdaptorExtender<
1641 1652
      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >,
1642 1653
                     AF, false> > {
1643 1654
#endif
1644 1655
    typedef DigraphAdaptorExtender<
1645
      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >, 
1656
      SubDigraphBase<DGR, ConstMap<typename DGR::Node, Const<bool, true> >,
1646 1657
                     AF, false> > Parent;
1647 1658

	
1648 1659
  public:
1649 1660

	
1650 1661
    /// The type of the adapted digraph.
1651 1662
    typedef DGR Digraph;
1652 1663
    /// The type of the arc filter map.
1653 1664
    typedef AF ArcFilterMap;
1654 1665

	
1655 1666
    typedef typename Parent::Arc Arc;
1656 1667

	
1657 1668
  protected:
1658 1669
    ConstMap<typename DGR::Node, Const<bool, true> > const_true_map;
1659 1670

	
1660 1671
    FilterArcs() : const_true_map() {}
1661 1672

	
1662 1673
  public:
1663 1674

	
1664 1675
    /// \brief Constructor
1665 1676
    ///
1666 1677
    /// Creates a subdigraph for the given digraph with the given arc
1667 1678
    /// filter map.
1668 1679
    FilterArcs(DGR& digraph, ArcFilterMap& arc_filter)
1669 1680
      : Parent(), const_true_map() {
1670 1681
      Parent::initialize(digraph, const_true_map, arc_filter);
1671 1682
    }
1672 1683

	
1673 1684
    /// \brief Sets the status of the given arc
1674 1685
    ///
1675 1686
    /// This function sets the status of the given arc.
1676 1687
    /// It is done by simply setting the assigned value of \c a
1677 1688
    /// to \c v in the arc filter map.
1678 1689
    void status(const Arc& a, bool v) const { Parent::status(a, v); }
1679 1690

	
1680 1691
    /// \brief Returns the status of the given arc
1681 1692
    ///
1682 1693
    /// This function returns the status of the given arc.
1683 1694
    /// It is \c true if the given arc is enabled (i.e. not hidden).
1684 1695
    bool status(const Arc& a) const { return Parent::status(a); }
1685 1696

	
1686 1697
    /// \brief Disables the given arc
1687 1698
    ///
1688 1699
    /// This function disables the given arc in the subdigraph,
1689 1700
    /// so the iteration jumps over it.
1690 1701
    /// It is the same as \ref status() "status(a, false)".
1691 1702
    void disable(const Arc& a) const { Parent::status(a, false); }
1692 1703

	
1693 1704
    /// \brief Enables the given arc
1694 1705
    ///
1695 1706
    /// This function enables the given arc in the subdigraph.
1696 1707
    /// It is the same as \ref status() "status(a, true)".
1697 1708
    void enable(const Arc& a) const { Parent::status(a, true); }
1698 1709

	
1699 1710
  };
1700 1711

	
1701 1712
  /// \brief Returns a read-only FilterArcs adaptor
1702 1713
  ///
1703 1714
  /// This function just returns a read-only \ref FilterArcs adaptor.
1704 1715
  /// \ingroup graph_adaptors
1705 1716
  /// \relates FilterArcs
1706 1717
  template<typename DGR, typename AF>
1707 1718
  FilterArcs<const DGR, AF>
1708 1719
  filterArcs(const DGR& digraph, AF& arc_filter) {
1709 1720
    return FilterArcs<const DGR, AF>(digraph, arc_filter);
1710 1721
  }
1711 1722

	
1712 1723
  template<typename DGR, typename AF>
1713 1724
  FilterArcs<const DGR, const AF>
1714 1725
  filterArcs(const DGR& digraph, const AF& arc_filter) {
1715 1726
    return FilterArcs<const DGR, const AF>(digraph, arc_filter);
1716 1727
  }
1717 1728

	
1718 1729
  /// \ingroup graph_adaptors
1719 1730
  ///
1720 1731
  /// \brief Adaptor class for hiding edges in a graph.
1721 1732
  ///
1722 1733
  /// FilterEdges adaptor can be used for hiding edges in a graph.
1723 1734
  /// A \c bool edge map must be specified, which defines the filter for
1724 1735
  /// the edges. Only the edges with \c true filter value are shown in the
1725 1736
  /// subgraph. This adaptor conforms to the \ref concepts::Graph
1726 1737
  /// "Graph" concept.
1727 1738
  ///
1728 1739
  /// The adapted graph can also be modified through this adaptor
1729 1740
  /// by adding or removing nodes or edges, unless the \c GR template
1730 1741
  /// parameter is set to be \c const.
1731 1742
  ///
1743
  /// This class provides only linear time counting for nodes, edges and arcs.
1744
  ///
1732 1745
  /// \tparam GR The type of the adapted graph.
1733 1746
  /// It must conform to the \ref concepts::Graph "Graph" concept.
1734 1747
  /// It can also be specified to be \c const.
1735 1748
  /// \tparam EF The type of the edge filter map.
1736 1749
  /// It must be a \c bool (or convertible) edge map of the
1737 1750
  /// adapted graph. The default type is
1738 1751
  /// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>".
1739 1752
  ///
1740 1753
  /// \note The \c Node, \c Edge and \c Arc types of this adaptor and the
1741 1754
  /// adapted graph are convertible to each other.
1742 1755
#ifdef DOXYGEN
1743 1756
  template<typename GR,
1744 1757
           typename EF>
1745 1758
  class FilterEdges {
1746 1759
#else
1747 1760
  template<typename GR,
1748 1761
           typename EF = typename GR::template EdgeMap<bool> >
1749 1762
  class FilterEdges :
1750 1763
    public GraphAdaptorExtender<
1751
      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >, 
1764
      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true> >,
1752 1765
                   EF, false> > {
1753 1766
#endif
1754 1767
    typedef GraphAdaptorExtender<
1755
      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >, 
1768
      SubGraphBase<GR, ConstMap<typename GR::Node, Const<bool, true > >,
1756 1769
                   EF, false> > Parent;
1757 1770

	
1758 1771
  public:
1759 1772

	
1760 1773
    /// The type of the adapted graph.
1761 1774
    typedef GR Graph;
1762 1775
    /// The type of the edge filter map.
1763 1776
    typedef EF EdgeFilterMap;
1764 1777

	
1765 1778
    typedef typename Parent::Edge Edge;
1766 1779

	
1767 1780
  protected:
1768 1781
    ConstMap<typename GR::Node, Const<bool, true> > const_true_map;
1769 1782

	
1770 1783
    FilterEdges() : const_true_map(true) {
1771 1784
      Parent::setNodeFilterMap(const_true_map);
1772 1785
    }
1773 1786

	
1774 1787
  public:
1775 1788

	
1776 1789
    /// \brief Constructor
1777 1790
    ///
1778 1791
    /// Creates a subgraph for the given graph with the given edge
1779 1792
    /// filter map.
1780
    FilterEdges(GR& graph, EF& edge_filter) 
1793
    FilterEdges(GR& graph, EF& edge_filter)
1781 1794
      : Parent(), const_true_map() {
1782 1795
      Parent::initialize(graph, const_true_map, edge_filter);
1783 1796
    }
1784 1797

	
1785 1798
    /// \brief Sets the status of the given edge
1786 1799
    ///
1787 1800
    /// This function sets the status of the given edge.
1788 1801
    /// It is done by simply setting the assigned value of \c e
1789 1802
    /// to \c v in the edge filter map.
1790 1803
    void status(const Edge& e, bool v) const { Parent::status(e, v); }
1791 1804

	
1792 1805
    /// \brief Returns the status of the given edge
1793 1806
    ///
1794 1807
    /// This function returns the status of the given edge.
1795 1808
    /// It is \c true if the given edge is enabled (i.e. not hidden).
1796 1809
    bool status(const Edge& e) const { return Parent::status(e); }
1797 1810

	
1798 1811
    /// \brief Disables the given edge
1799 1812
    ///
1800 1813
    /// This function disables the given edge in the subgraph,
1801 1814
    /// so the iteration jumps over it.
1802 1815
    /// It is the same as \ref status() "status(e, false)".
1803 1816
    void disable(const Edge& e) const { Parent::status(e, false); }
1804 1817

	
1805 1818
    /// \brief Enables the given edge
1806 1819
    ///
1807 1820
    /// This function enables the given edge in the subgraph.
1808 1821
    /// It is the same as \ref status() "status(e, true)".
1809 1822
    void enable(const Edge& e) const { Parent::status(e, true); }
1810 1823

	
1811 1824
  };
1812 1825

	
1813 1826
  /// \brief Returns a read-only FilterEdges adaptor
1814 1827
  ///
1815 1828
  /// This function just returns a read-only \ref FilterEdges adaptor.
1816 1829
  /// \ingroup graph_adaptors
1817 1830
  /// \relates FilterEdges
1818 1831
  template<typename GR, typename EF>
1819 1832
  FilterEdges<const GR, EF>
1820 1833
  filterEdges(const GR& graph, EF& edge_filter) {
1821 1834
    return FilterEdges<const GR, EF>(graph, edge_filter);
1822 1835
  }
1823 1836

	
1824 1837
  template<typename GR, typename EF>
1825 1838
  FilterEdges<const GR, const EF>
1826 1839
  filterEdges(const GR& graph, const EF& edge_filter) {
1827 1840
    return FilterEdges<const GR, const EF>(graph, edge_filter);
1828 1841
  }
1829 1842

	
1830 1843

	
1831 1844
  template <typename DGR>
1832 1845
  class UndirectorBase {
1833 1846
  public:
1834 1847
    typedef DGR Digraph;
1835 1848
    typedef UndirectorBase Adaptor;
1836 1849

	
1837 1850
    typedef True UndirectedTag;
1838 1851

	
1839 1852
    typedef typename Digraph::Arc Edge;
1840 1853
    typedef typename Digraph::Node Node;
1841 1854

	
1842 1855
    class Arc {
1843 1856
      friend class UndirectorBase;
1844 1857
    protected:
1845 1858
      Edge _edge;
1846 1859
      bool _forward;
1847 1860

	
1848
      Arc(const Edge& edge, bool forward) 
1861
      Arc(const Edge& edge, bool forward)
1849 1862
        : _edge(edge), _forward(forward) {}
1850 1863

	
1851 1864
    public:
1852 1865
      Arc() {}
1853 1866

	
1854 1867
      Arc(Invalid) : _edge(INVALID), _forward(true) {}
1855 1868

	
1856 1869
      operator const Edge&() const { return _edge; }
1857 1870

	
1858 1871
      bool operator==(const Arc &other) const {
1859 1872
        return _forward == other._forward && _edge == other._edge;
1860 1873
      }
1861 1874
      bool operator!=(const Arc &other) const {
1862 1875
        return _forward != other._forward || _edge != other._edge;
1863 1876
      }
1864 1877
      bool operator<(const Arc &other) const {
1865 1878
        return _forward < other._forward ||
1866 1879
          (_forward == other._forward && _edge < other._edge);
1867 1880
      }
1868 1881
    };
1869 1882

	
1870 1883
    void first(Node& n) const {
1871 1884
      _digraph->first(n);
1872 1885
    }
1873 1886

	
1874 1887
    void next(Node& n) const {
1875 1888
      _digraph->next(n);
1876 1889
    }
1877 1890

	
1878 1891
    void first(Arc& a) const {
1879 1892
      _digraph->first(a._edge);
1880 1893
      a._forward = true;
1881 1894
    }
1882 1895

	
1883 1896
    void next(Arc& a) const {
1884 1897
      if (a._forward) {
1885 1898
        a._forward = false;
1886 1899
      } else {
1887 1900
        _digraph->next(a._edge);
1888 1901
        a._forward = true;
1889 1902
      }
1890 1903
    }
1891 1904

	
1892 1905
    void first(Edge& e) const {
1893 1906
      _digraph->first(e);
1894 1907
    }
1895 1908

	
1896 1909
    void next(Edge& e) const {
1897 1910
      _digraph->next(e);
1898 1911
    }
1899 1912

	
1900 1913
    void firstOut(Arc& a, const Node& n) const {
1901 1914
      _digraph->firstIn(a._edge, n);
1902 1915
      if (a._edge != INVALID ) {
1903 1916
        a._forward = false;
1904 1917
      } else {
1905 1918
        _digraph->firstOut(a._edge, n);
1906 1919
        a._forward = true;
1907 1920
      }
1908 1921
    }
1909 1922
    void nextOut(Arc &a) const {
1910 1923
      if (!a._forward) {
1911 1924
        Node n = _digraph->target(a._edge);
1912 1925
        _digraph->nextIn(a._edge);
1913 1926
        if (a._edge == INVALID) {
1914 1927
          _digraph->firstOut(a._edge, n);
1915 1928
          a._forward = true;
1916 1929
        }
1917 1930
      }
1918 1931
      else {
1919 1932
        _digraph->nextOut(a._edge);
1920 1933
      }
1921 1934
    }
1922 1935

	
1923 1936
    void firstIn(Arc &a, const Node &n) const {
1924 1937
      _digraph->firstOut(a._edge, n);
1925 1938
      if (a._edge != INVALID ) {
1926 1939
        a._forward = false;
1927 1940
      } else {
1928 1941
        _digraph->firstIn(a._edge, n);
1929 1942
        a._forward = true;
1930 1943
      }
1931 1944
    }
1932 1945
    void nextIn(Arc &a) const {
1933 1946
      if (!a._forward) {
1934 1947
        Node n = _digraph->source(a._edge);
1935 1948
        _digraph->nextOut(a._edge);
1936 1949
        if (a._edge == INVALID ) {
1937 1950
          _digraph->firstIn(a._edge, n);
1938 1951
          a._forward = true;
1939 1952
        }
1940 1953
      }
1941 1954
      else {
1942 1955
        _digraph->nextIn(a._edge);
1943 1956
      }
1944 1957
    }
1945 1958

	
1946 1959
    void firstInc(Edge &e, bool &d, const Node &n) const {
1947 1960
      d = true;
1948 1961
      _digraph->firstOut(e, n);
1949 1962
      if (e != INVALID) return;
1950 1963
      d = false;
1951 1964
      _digraph->firstIn(e, n);
1952 1965
    }
1953 1966

	
1954 1967
    void nextInc(Edge &e, bool &d) const {
1955 1968
      if (d) {
1956 1969
        Node s = _digraph->source(e);
1957 1970
        _digraph->nextOut(e);
1958 1971
        if (e != INVALID) return;
1959 1972
        d = false;
1960 1973
        _digraph->firstIn(e, s);
1961 1974
      } else {
1962 1975
        _digraph->nextIn(e);
1963 1976
      }
1964 1977
    }
1965 1978

	
1966 1979
    Node u(const Edge& e) const {
1967 1980
      return _digraph->source(e);
1968 1981
    }
1969 1982

	
1970 1983
    Node v(const Edge& e) const {
1971 1984
      return _digraph->target(e);
1972 1985
    }
1973 1986

	
1974 1987
    Node source(const Arc &a) const {
1975 1988
      return a._forward ? _digraph->source(a._edge) : _digraph->target(a._edge);
1976 1989
    }
1977 1990

	
1978 1991
    Node target(const Arc &a) const {
1979 1992
      return a._forward ? _digraph->target(a._edge) : _digraph->source(a._edge);
1980 1993
    }
1981 1994

	
1982 1995
    static Arc direct(const Edge &e, bool d) {
1983 1996
      return Arc(e, d);
1984 1997
    }
1985 1998

	
1986 1999
    static bool direction(const Arc &a) { return a._forward; }
1987 2000

	
1988 2001
    Node nodeFromId(int ix) const { return _digraph->nodeFromId(ix); }
1989 2002
    Arc arcFromId(int ix) const {
1990 2003
      return direct(_digraph->arcFromId(ix >> 1), bool(ix & 1));
1991 2004
    }
1992 2005
    Edge edgeFromId(int ix) const { return _digraph->arcFromId(ix); }
1993 2006

	
1994 2007
    int id(const Node &n) const { return _digraph->id(n); }
1995 2008
    int id(const Arc &a) const {
1996 2009
      return  (_digraph->id(a) << 1) | (a._forward ? 1 : 0);
1997 2010
    }
1998 2011
    int id(const Edge &e) const { return _digraph->id(e); }
1999 2012

	
2000 2013
    int maxNodeId() const { return _digraph->maxNodeId(); }
2001 2014
    int maxArcId() const { return (_digraph->maxArcId() << 1) | 1; }
2002 2015
    int maxEdgeId() const { return _digraph->maxArcId(); }
2003 2016

	
2004 2017
    Node addNode() { return _digraph->addNode(); }
2005 2018
    Edge addEdge(const Node& u, const Node& v) {
2006 2019
      return _digraph->addArc(u, v);
2007 2020
    }
2008 2021

	
2009 2022
    void erase(const Node& i) { _digraph->erase(i); }
2010 2023
    void erase(const Edge& i) { _digraph->erase(i); }
2011 2024

	
2012 2025
    void clear() { _digraph->clear(); }
2013 2026

	
2014 2027
    typedef NodeNumTagIndicator<Digraph> NodeNumTag;
2015 2028
    int nodeNum() const { return _digraph->nodeNum(); }
2016 2029

	
2017 2030
    typedef ArcNumTagIndicator<Digraph> ArcNumTag;
2018 2031
    int arcNum() const { return 2 * _digraph->arcNum(); }
2019 2032

	
2020 2033
    typedef ArcNumTag EdgeNumTag;
2021 2034
    int edgeNum() const { return _digraph->arcNum(); }
2022 2035

	
2023 2036
    typedef FindArcTagIndicator<Digraph> FindArcTag;
2024 2037
    Arc findArc(Node s, Node t, Arc p = INVALID) const {
2025 2038
      if (p == INVALID) {
2026 2039
        Edge arc = _digraph->findArc(s, t);
2027 2040
        if (arc != INVALID) return direct(arc, true);
2028 2041
        arc = _digraph->findArc(t, s);
2029 2042
        if (arc != INVALID) return direct(arc, false);
2030 2043
      } else if (direction(p)) {
2031 2044
        Edge arc = _digraph->findArc(s, t, p);
2032 2045
        if (arc != INVALID) return direct(arc, true);
2033 2046
        arc = _digraph->findArc(t, s);
2034 2047
        if (arc != INVALID) return direct(arc, false);
2035 2048
      } else {
2036 2049
        Edge arc = _digraph->findArc(t, s, p);
2037 2050
        if (arc != INVALID) return direct(arc, false);
2038 2051
      }
2039 2052
      return INVALID;
2040 2053
    }
2041 2054

	
2042 2055
    typedef FindArcTag FindEdgeTag;
2043 2056
    Edge findEdge(Node s, Node t, Edge p = INVALID) const {
2044 2057
      if (s != t) {
2045 2058
        if (p == INVALID) {
2046 2059
          Edge arc = _digraph->findArc(s, t);
2047 2060
          if (arc != INVALID) return arc;
2048 2061
          arc = _digraph->findArc(t, s);
2049 2062
          if (arc != INVALID) return arc;
2050 2063
        } else if (_digraph->source(p) == s) {
2051 2064
          Edge arc = _digraph->findArc(s, t, p);
2052 2065
          if (arc != INVALID) return arc;
2053 2066
          arc = _digraph->findArc(t, s);
2054 2067
          if (arc != INVALID) return arc;
2055 2068
        } else {
2056 2069
          Edge arc = _digraph->findArc(t, s, p);
2057 2070
          if (arc != INVALID) return arc;
2058 2071
        }
2059 2072
      } else {
2060 2073
        return _digraph->findArc(s, t, p);
2061 2074
      }
2062 2075
      return INVALID;
2063 2076
    }
2064 2077

	
2065 2078
  private:
2066 2079

	
2067 2080
    template <typename V>
2068 2081
    class ArcMapBase {
2069 2082
    private:
2070 2083

	
2071 2084
      typedef typename DGR::template ArcMap<V> MapImpl;
2072 2085

	
2073 2086
    public:
2074 2087

	
2075 2088
      typedef typename MapTraits<MapImpl>::ReferenceMapTag ReferenceMapTag;
2076 2089

	
2077 2090
      typedef V Value;
2078 2091
      typedef Arc Key;
2079 2092
      typedef typename MapTraits<MapImpl>::ConstReturnValue ConstReturnValue;
2080 2093
      typedef typename MapTraits<MapImpl>::ReturnValue ReturnValue;
2081 2094
      typedef typename MapTraits<MapImpl>::ConstReturnValue ConstReference;
2082 2095
      typedef typename MapTraits<MapImpl>::ReturnValue Reference;
2083 2096

	
2084 2097
      ArcMapBase(const UndirectorBase<DGR>& adaptor) :
2085 2098
        _forward(*adaptor._digraph), _backward(*adaptor._digraph) {}
2086 2099

	
2087 2100
      ArcMapBase(const UndirectorBase<DGR>& adaptor, const V& value)
2088
        : _forward(*adaptor._digraph, value), 
2101
        : _forward(*adaptor._digraph, value),
2089 2102
          _backward(*adaptor._digraph, value) {}
2090 2103

	
2091 2104
      void set(const Arc& a, const V& value) {
2092 2105
        if (direction(a)) {
2093 2106
          _forward.set(a, value);
2094 2107
        } else {
2095 2108
          _backward.set(a, value);
2096 2109
        }
2097 2110
      }
2098 2111

	
2099 2112
      ConstReturnValue operator[](const Arc& a) const {
2100 2113
        if (direction(a)) {
2101 2114
          return _forward[a];
2102 2115
        } else {
2103 2116
          return _backward[a];
2104 2117
        }
2105 2118
      }
2106 2119

	
2107 2120
      ReturnValue operator[](const Arc& a) {
2108 2121
        if (direction(a)) {
2109 2122
          return _forward[a];
2110 2123
        } else {
2111 2124
          return _backward[a];
2112 2125
        }
2113 2126
      }
2114 2127

	
2115 2128
    protected:
2116 2129

	
2117 2130
      MapImpl _forward, _backward;
2118 2131

	
2119 2132
    };
2120 2133

	
2121 2134
  public:
2122 2135

	
2123 2136
    template <typename V>
2124 2137
    class NodeMap : public DGR::template NodeMap<V> {
2125 2138
      typedef typename DGR::template NodeMap<V> Parent;
2126 2139

	
2127 2140
    public:
2128 2141
      typedef V Value;
2129 2142

	
2130 2143
      explicit NodeMap(const UndirectorBase<DGR>& adaptor)
2131 2144
        : Parent(*adaptor._digraph) {}
2132 2145

	
2133 2146
      NodeMap(const UndirectorBase<DGR>& adaptor, const V& value)
2134 2147
        : Parent(*adaptor._digraph, value) { }
2135 2148

	
2136 2149
    private:
2137 2150
      NodeMap& operator=(const NodeMap& cmap) {
2138 2151
        return operator=<NodeMap>(cmap);
2139 2152
      }
2140 2153

	
2141 2154
      template <typename CMap>
2142 2155
      NodeMap& operator=(const CMap& cmap) {
2143 2156
        Parent::operator=(cmap);
2144 2157
        return *this;
2145 2158
      }
2146 2159

	
2147 2160
    };
2148 2161

	
2149 2162
    template <typename V>
2150 2163
    class ArcMap
2151 2164
      : public SubMapExtender<UndirectorBase<DGR>, ArcMapBase<V> > {
2152 2165
      typedef SubMapExtender<UndirectorBase<DGR>, ArcMapBase<V> > Parent;
2153 2166

	
2154 2167
    public:
2155 2168
      typedef V Value;
2156 2169

	
2157 2170
      explicit ArcMap(const UndirectorBase<DGR>& adaptor)
2158 2171
        : Parent(adaptor) {}
2159 2172

	
2160 2173
      ArcMap(const UndirectorBase<DGR>& adaptor, const V& value)
2161 2174
        : Parent(adaptor, value) {}
2162 2175

	
2163 2176
    private:
2164 2177
      ArcMap& operator=(const ArcMap& cmap) {
2165 2178
        return operator=<ArcMap>(cmap);
2166 2179
      }
2167 2180

	
2168 2181
      template <typename CMap>
2169 2182
      ArcMap& operator=(const CMap& cmap) {
2170 2183
        Parent::operator=(cmap);
2171 2184
        return *this;
2172 2185
      }
2173 2186
    };
2174 2187

	
2175 2188
    template <typename V>
2176 2189
    class EdgeMap : public Digraph::template ArcMap<V> {
2177 2190
      typedef typename Digraph::template ArcMap<V> Parent;
2178 2191

	
2179 2192
    public:
2180 2193
      typedef V Value;
2181 2194

	
2182 2195
      explicit EdgeMap(const UndirectorBase<DGR>& adaptor)
2183 2196
        : Parent(*adaptor._digraph) {}
2184 2197

	
2185 2198
      EdgeMap(const UndirectorBase<DGR>& adaptor, const V& value)
2186 2199
        : Parent(*adaptor._digraph, value) {}
2187 2200

	
2188 2201
    private:
2189 2202
      EdgeMap& operator=(const EdgeMap& cmap) {
2190 2203
        return operator=<EdgeMap>(cmap);
2191 2204
      }
2192 2205

	
2193 2206
      template <typename CMap>
2194 2207
      EdgeMap& operator=(const CMap& cmap) {
2195 2208
        Parent::operator=(cmap);
2196 2209
        return *this;
2197 2210
      }
2198 2211

	
2199 2212
    };
2200 2213

	
2201 2214
    typedef typename ItemSetTraits<DGR, Node>::ItemNotifier NodeNotifier;
2202 2215
    NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); }
2203 2216

	
2204 2217
    typedef typename ItemSetTraits<DGR, Edge>::ItemNotifier EdgeNotifier;
2205 2218
    EdgeNotifier& notifier(Edge) const { return _digraph->notifier(Edge()); }
2206
    
2219

	
2207 2220
    typedef EdgeNotifier ArcNotifier;
2208 2221
    ArcNotifier& notifier(Arc) const { return _digraph->notifier(Edge()); }
2209 2222

	
2210 2223
  protected:
2211 2224

	
2212 2225
    UndirectorBase() : _digraph(0) {}
2213 2226

	
2214 2227
    DGR* _digraph;
2215 2228

	
2216 2229
    void initialize(DGR& digraph) {
2217 2230
      _digraph = &digraph;
2218 2231
    }
2219 2232

	
2220 2233
  };
2221 2234

	
2222 2235
  /// \ingroup graph_adaptors
2223 2236
  ///
2224 2237
  /// \brief Adaptor class for viewing a digraph as an undirected graph.
2225 2238
  ///
2226 2239
  /// Undirector adaptor can be used for viewing a digraph as an undirected
2227 2240
  /// graph. All arcs of the underlying digraph are showed in the
2228 2241
  /// adaptor as an edge (and also as a pair of arcs, of course).
2229 2242
  /// This adaptor conforms to the \ref concepts::Graph "Graph" concept.
2230 2243
  ///
2231 2244
  /// The adapted digraph can also be modified through this adaptor
2232 2245
  /// by adding or removing nodes or edges, unless the \c GR template
2233 2246
  /// parameter is set to be \c const.
2234 2247
  ///
2248
  /// This class provides item counting in the same time as the adapted
2249
  /// digraph structure.
2250
  ///
2235 2251
  /// \tparam DGR The type of the adapted digraph.
2236 2252
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
2237 2253
  /// It can also be specified to be \c const.
2238 2254
  ///
2239 2255
  /// \note The \c Node type of this adaptor and the adapted digraph are
2240 2256
  /// convertible to each other, moreover the \c Edge type of the adaptor
2241 2257
  /// and the \c Arc type of the adapted digraph are also convertible to
2242 2258
  /// each other.
2243 2259
  /// (Thus the \c Arc type of the adaptor is convertible to the \c Arc type
2244 2260
  /// of the adapted digraph.)
2245 2261
  template<typename DGR>
2246 2262
#ifdef DOXYGEN
2247 2263
  class Undirector {
2248 2264
#else
2249 2265
  class Undirector :
2250 2266
    public GraphAdaptorExtender<UndirectorBase<DGR> > {
2251 2267
#endif
2252 2268
    typedef GraphAdaptorExtender<UndirectorBase<DGR> > Parent;
2253 2269
  public:
2254 2270
    /// The type of the adapted digraph.
2255 2271
    typedef DGR Digraph;
2256 2272
  protected:
2257 2273
    Undirector() { }
2258 2274
  public:
2259 2275

	
2260 2276
    /// \brief Constructor
2261 2277
    ///
2262 2278
    /// Creates an undirected graph from the given digraph.
2263 2279
    Undirector(DGR& digraph) {
2264 2280
      initialize(digraph);
2265 2281
    }
2266 2282

	
2267 2283
    /// \brief Arc map combined from two original arc maps
2268 2284
    ///
2269 2285
    /// This map adaptor class adapts two arc maps of the underlying
2270 2286
    /// digraph to get an arc map of the undirected graph.
2271 2287
    /// Its value type is inherited from the first arc map type (\c FW).
2272 2288
    /// \tparam FW The type of the "foward" arc map.
2273 2289
    /// \tparam BK The type of the "backward" arc map.
2274 2290
    template <typename FW, typename BK>
2275 2291
    class CombinedArcMap {
2276 2292
    public:
2277 2293

	
2278 2294
      /// The key type of the map
2279 2295
      typedef typename Parent::Arc Key;
2280 2296
      /// The value type of the map
2281 2297
      typedef typename FW::Value Value;
2282 2298

	
2283 2299
      typedef typename MapTraits<FW>::ReferenceMapTag ReferenceMapTag;
2284 2300

	
2285 2301
      typedef typename MapTraits<FW>::ReturnValue ReturnValue;
2286 2302
      typedef typename MapTraits<FW>::ConstReturnValue ConstReturnValue;
2287 2303
      typedef typename MapTraits<FW>::ReturnValue Reference;
2288 2304
      typedef typename MapTraits<FW>::ConstReturnValue ConstReference;
2289 2305

	
2290 2306
      /// Constructor
2291 2307
      CombinedArcMap(FW& forward, BK& backward)
2292 2308
        : _forward(&forward), _backward(&backward) {}
2293 2309

	
2294 2310
      /// Sets the value associated with the given key.
2295 2311
      void set(const Key& e, const Value& a) {
2296 2312
        if (Parent::direction(e)) {
2297 2313
          _forward->set(e, a);
2298 2314
        } else {
2299 2315
          _backward->set(e, a);
2300 2316
        }
2301 2317
      }
2302 2318

	
2303 2319
      /// Returns the value associated with the given key.
2304 2320
      ConstReturnValue operator[](const Key& e) const {
2305 2321
        if (Parent::direction(e)) {
2306 2322
          return (*_forward)[e];
2307 2323
        } else {
2308 2324
          return (*_backward)[e];
2309 2325
        }
2310 2326
      }
2311 2327

	
2312 2328
      /// Returns a reference to the value associated with the given key.
2313 2329
      ReturnValue operator[](const Key& e) {
2314 2330
        if (Parent::direction(e)) {
2315 2331
          return (*_forward)[e];
2316 2332
        } else {
2317 2333
          return (*_backward)[e];
2318 2334
        }
2319 2335
      }
2320 2336

	
2321 2337
    protected:
2322 2338

	
2323 2339
      FW* _forward;
2324 2340
      BK* _backward;
2325 2341

	
2326 2342
    };
2327 2343

	
2328 2344
    /// \brief Returns a combined arc map
2329 2345
    ///
2330 2346
    /// This function just returns a combined arc map.
2331 2347
    template <typename FW, typename BK>
2332 2348
    static CombinedArcMap<FW, BK>
2333 2349
    combinedArcMap(FW& forward, BK& backward) {
2334 2350
      return CombinedArcMap<FW, BK>(forward, backward);
2335 2351
    }
2336 2352

	
2337 2353
    template <typename FW, typename BK>
2338 2354
    static CombinedArcMap<const FW, BK>
2339 2355
    combinedArcMap(const FW& forward, BK& backward) {
2340 2356
      return CombinedArcMap<const FW, BK>(forward, backward);
2341 2357
    }
2342 2358

	
2343 2359
    template <typename FW, typename BK>
2344 2360
    static CombinedArcMap<FW, const BK>
2345 2361
    combinedArcMap(FW& forward, const BK& backward) {
2346 2362
      return CombinedArcMap<FW, const BK>(forward, backward);
2347 2363
    }
2348 2364

	
2349 2365
    template <typename FW, typename BK>
2350 2366
    static CombinedArcMap<const FW, const BK>
2351 2367
    combinedArcMap(const FW& forward, const BK& backward) {
2352 2368
      return CombinedArcMap<const FW, const BK>(forward, backward);
2353 2369
    }
2354 2370

	
2355 2371
  };
2356 2372

	
2357 2373
  /// \brief Returns a read-only Undirector adaptor
2358 2374
  ///
2359 2375
  /// This function just returns a read-only \ref Undirector adaptor.
2360 2376
  /// \ingroup graph_adaptors
2361 2377
  /// \relates Undirector
2362 2378
  template<typename DGR>
2363 2379
  Undirector<const DGR> undirector(const DGR& digraph) {
2364 2380
    return Undirector<const DGR>(digraph);
2365 2381
  }
2366 2382

	
2367 2383

	
2368 2384
  template <typename GR, typename DM>
2369 2385
  class OrienterBase {
2370 2386
  public:
2371 2387

	
2372 2388
    typedef GR Graph;
2373 2389
    typedef DM DirectionMap;
2374 2390

	
2375 2391
    typedef typename GR::Node Node;
2376 2392
    typedef typename GR::Edge Arc;
2377 2393

	
2378 2394
    void reverseArc(const Arc& arc) {
2379 2395
      _direction->set(arc, !(*_direction)[arc]);
2380 2396
    }
2381 2397

	
2382 2398
    void first(Node& i) const { _graph->first(i); }
2383 2399
    void first(Arc& i) const { _graph->first(i); }
2384 2400
    void firstIn(Arc& i, const Node& n) const {
2385 2401
      bool d = true;
2386 2402
      _graph->firstInc(i, d, n);
2387 2403
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2388 2404
    }
2389 2405
    void firstOut(Arc& i, const Node& n ) const {
2390 2406
      bool d = true;
2391 2407
      _graph->firstInc(i, d, n);
2392 2408
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2393 2409
    }
2394 2410

	
2395 2411
    void next(Node& i) const { _graph->next(i); }
2396 2412
    void next(Arc& i) const { _graph->next(i); }
2397 2413
    void nextIn(Arc& i) const {
2398 2414
      bool d = !(*_direction)[i];
2399 2415
      _graph->nextInc(i, d);
2400 2416
      while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d);
2401 2417
    }
2402 2418
    void nextOut(Arc& i) const {
2403 2419
      bool d = (*_direction)[i];
2404 2420
      _graph->nextInc(i, d);
2405 2421
      while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d);
2406 2422
    }
2407 2423

	
2408 2424
    Node source(const Arc& e) const {
2409 2425
      return (*_direction)[e] ? _graph->u(e) : _graph->v(e);
2410 2426
    }
2411 2427
    Node target(const Arc& e) const {
2412 2428
      return (*_direction)[e] ? _graph->v(e) : _graph->u(e);
2413 2429
    }
2414 2430

	
2415 2431
    typedef NodeNumTagIndicator<Graph> NodeNumTag;
2416 2432
    int nodeNum() const { return _graph->nodeNum(); }
2417 2433

	
2418 2434
    typedef EdgeNumTagIndicator<Graph> ArcNumTag;
2419 2435
    int arcNum() const { return _graph->edgeNum(); }
2420 2436

	
2421 2437
    typedef FindEdgeTagIndicator<Graph> FindArcTag;
2422 2438
    Arc findArc(const Node& u, const Node& v,
2423 2439
                const Arc& prev = INVALID) const {
2424 2440
      Arc arc = _graph->findEdge(u, v, prev);
2425 2441
      while (arc != INVALID && source(arc) != u) {
2426 2442
        arc = _graph->findEdge(u, v, arc);
2427 2443
      }
2428 2444
      return arc;
2429 2445
    }
2430 2446

	
2431 2447
    Node addNode() {
2432 2448
      return Node(_graph->addNode());
2433 2449
    }
2434 2450

	
2435 2451
    Arc addArc(const Node& u, const Node& v) {
2436 2452
      Arc arc = _graph->addEdge(u, v);
2437 2453
      _direction->set(arc, _graph->u(arc) == u);
2438 2454
      return arc;
2439 2455
    }
2440 2456

	
2441 2457
    void erase(const Node& i) { _graph->erase(i); }
2442 2458
    void erase(const Arc& i) { _graph->erase(i); }
2443 2459

	
2444 2460
    void clear() { _graph->clear(); }
2445 2461

	
2446 2462
    int id(const Node& v) const { return _graph->id(v); }
2447 2463
    int id(const Arc& e) const { return _graph->id(e); }
2448 2464

	
2449 2465
    Node nodeFromId(int idx) const { return _graph->nodeFromId(idx); }
2450 2466
    Arc arcFromId(int idx) const { return _graph->edgeFromId(idx); }
2451 2467

	
2452 2468
    int maxNodeId() const { return _graph->maxNodeId(); }
2453 2469
    int maxArcId() const { return _graph->maxEdgeId(); }
2454 2470

	
2455 2471
    typedef typename ItemSetTraits<GR, Node>::ItemNotifier NodeNotifier;
2456 2472
    NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
2457 2473

	
2458 2474
    typedef typename ItemSetTraits<GR, Arc>::ItemNotifier ArcNotifier;
2459 2475
    ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
2460 2476

	
2461 2477
    template <typename V>
2462 2478
    class NodeMap : public GR::template NodeMap<V> {
2463 2479
      typedef typename GR::template NodeMap<V> Parent;
2464 2480

	
2465 2481
    public:
2466 2482

	
2467 2483
      explicit NodeMap(const OrienterBase<GR, DM>& adapter)
2468 2484
        : Parent(*adapter._graph) {}
2469 2485

	
2470 2486
      NodeMap(const OrienterBase<GR, DM>& adapter, const V& value)
2471 2487
        : Parent(*adapter._graph, value) {}
2472 2488

	
2473 2489
    private:
2474 2490
      NodeMap& operator=(const NodeMap& cmap) {
2475 2491
        return operator=<NodeMap>(cmap);
2476 2492
      }
2477 2493

	
2478 2494
      template <typename CMap>
2479 2495
      NodeMap& operator=(const CMap& cmap) {
2480 2496
        Parent::operator=(cmap);
2481 2497
        return *this;
2482 2498
      }
2483 2499

	
2484 2500
    };
2485 2501

	
2486 2502
    template <typename V>
2487 2503
    class ArcMap : public GR::template EdgeMap<V> {
2488 2504
      typedef typename Graph::template EdgeMap<V> Parent;
2489 2505

	
2490 2506
    public:
2491 2507

	
2492 2508
      explicit ArcMap(const OrienterBase<GR, DM>& adapter)
2493 2509
        : Parent(*adapter._graph) { }
2494 2510

	
2495 2511
      ArcMap(const OrienterBase<GR, DM>& adapter, const V& value)
2496 2512
        : Parent(*adapter._graph, value) { }
2497 2513

	
2498 2514
    private:
2499 2515
      ArcMap& operator=(const ArcMap& cmap) {
2500 2516
        return operator=<ArcMap>(cmap);
2501 2517
      }
2502 2518

	
2503 2519
      template <typename CMap>
2504 2520
      ArcMap& operator=(const CMap& cmap) {
2505 2521
        Parent::operator=(cmap);
2506 2522
        return *this;
2507 2523
      }
2508 2524
    };
2509 2525

	
2510 2526

	
2511 2527

	
2512 2528
  protected:
2513 2529
    Graph* _graph;
2514 2530
    DM* _direction;
2515 2531

	
2516 2532
    void initialize(GR& graph, DM& direction) {
2517 2533
      _graph = &graph;
2518 2534
      _direction = &direction;
2519 2535
    }
2520 2536

	
2521 2537
  };
2522 2538

	
2523 2539
  /// \ingroup graph_adaptors
2524 2540
  ///
2525 2541
  /// \brief Adaptor class for orienting the edges of a graph to get a digraph
2526 2542
  ///
2527 2543
  /// Orienter adaptor can be used for orienting the edges of a graph to
2528 2544
  /// get a digraph. A \c bool edge map of the underlying graph must be
2529 2545
  /// specified, which define the direction of the arcs in the adaptor.
2530 2546
  /// The arcs can be easily reversed by the \c reverseArc() member function
2531 2547
  /// of the adaptor.
2532 2548
  /// This class conforms to the \ref concepts::Digraph "Digraph" concept.
2533 2549
  ///
2534 2550
  /// The adapted graph can also be modified through this adaptor
2535 2551
  /// by adding or removing nodes or arcs, unless the \c GR template
2536 2552
  /// parameter is set to be \c const.
2537 2553
  ///
2554
  /// This class provides item counting in the same time as the adapted
2555
  /// graph structure.
2556
  ///
2538 2557
  /// \tparam GR The type of the adapted graph.
2539 2558
  /// It must conform to the \ref concepts::Graph "Graph" concept.
2540 2559
  /// It can also be specified to be \c const.
2541 2560
  /// \tparam DM The type of the direction map.
2542 2561
  /// It must be a \c bool (or convertible) edge map of the
2543 2562
  /// adapted graph. The default type is
2544 2563
  /// \ref concepts::Graph::EdgeMap "GR::EdgeMap<bool>".
2545 2564
  ///
2546 2565
  /// \note The \c Node type of this adaptor and the adapted graph are
2547 2566
  /// convertible to each other, moreover the \c Arc type of the adaptor
2548 2567
  /// and the \c Edge type of the adapted graph are also convertible to
2549 2568
  /// each other.
2550 2569
#ifdef DOXYGEN
2551 2570
  template<typename GR,
2552 2571
           typename DM>
2553 2572
  class Orienter {
2554 2573
#else
2555 2574
  template<typename GR,
2556 2575
           typename DM = typename GR::template EdgeMap<bool> >
2557 2576
  class Orienter :
2558 2577
    public DigraphAdaptorExtender<OrienterBase<GR, DM> > {
2559 2578
#endif
2560 2579
    typedef DigraphAdaptorExtender<OrienterBase<GR, DM> > Parent;
2561 2580
  public:
2562 2581

	
2563 2582
    /// The type of the adapted graph.
2564 2583
    typedef GR Graph;
2565 2584
    /// The type of the direction edge map.
2566 2585
    typedef DM DirectionMap;
2567 2586

	
2568 2587
    typedef typename Parent::Arc Arc;
2569 2588

	
2570 2589
  protected:
2571 2590
    Orienter() { }
2572 2591

	
2573 2592
  public:
2574 2593

	
2575 2594
    /// \brief Constructor
2576 2595
    ///
2577 2596
    /// Constructor of the adaptor.
2578 2597
    Orienter(GR& graph, DM& direction) {
2579 2598
      Parent::initialize(graph, direction);
2580 2599
    }
2581 2600

	
2582 2601
    /// \brief Reverses the given arc
2583 2602
    ///
2584 2603
    /// This function reverses the given arc.
2585 2604
    /// It is done by simply negate the assigned value of \c a
2586 2605
    /// in the direction map.
2587 2606
    void reverseArc(const Arc& a) {
2588 2607
      Parent::reverseArc(a);
2589 2608
    }
2590 2609
  };
2591 2610

	
2592 2611
  /// \brief Returns a read-only Orienter adaptor
2593 2612
  ///
2594 2613
  /// This function just returns a read-only \ref Orienter adaptor.
2595 2614
  /// \ingroup graph_adaptors
2596 2615
  /// \relates Orienter
2597 2616
  template<typename GR, typename DM>
2598 2617
  Orienter<const GR, DM>
2599 2618
  orienter(const GR& graph, DM& direction) {
2600 2619
    return Orienter<const GR, DM>(graph, direction);
2601 2620
  }
2602 2621

	
2603 2622
  template<typename GR, typename DM>
2604 2623
  Orienter<const GR, const DM>
2605 2624
  orienter(const GR& graph, const DM& direction) {
2606 2625
    return Orienter<const GR, const DM>(graph, direction);
2607 2626
  }
2608 2627

	
2609 2628
  namespace _adaptor_bits {
2610 2629

	
2611 2630
    template <typename DGR, typename CM, typename FM, typename TL>
2612 2631
    class ResForwardFilter {
2613 2632
    public:
2614 2633

	
2615 2634
      typedef typename DGR::Arc Key;
2616 2635
      typedef bool Value;
2617 2636

	
2618 2637
    private:
2619 2638

	
2620 2639
      const CM* _capacity;
2621 2640
      const FM* _flow;
2622 2641
      TL _tolerance;
2623 2642

	
2624 2643
    public:
2625 2644

	
2626 2645
      ResForwardFilter(const CM& capacity, const FM& flow,
2627 2646
                       const TL& tolerance = TL())
2628 2647
        : _capacity(&capacity), _flow(&flow), _tolerance(tolerance) { }
2629 2648

	
2630 2649
      bool operator[](const typename DGR::Arc& a) const {
2631 2650
        return _tolerance.positive((*_capacity)[a] - (*_flow)[a]);
2632 2651
      }
2633 2652
    };
2634 2653

	
2635 2654
    template<typename DGR,typename CM, typename FM, typename TL>
2636 2655
    class ResBackwardFilter {
2637 2656
    public:
2638 2657

	
2639 2658
      typedef typename DGR::Arc Key;
2640 2659
      typedef bool Value;
2641 2660

	
2642 2661
    private:
2643 2662

	
2644 2663
      const CM* _capacity;
2645 2664
      const FM* _flow;
2646 2665
      TL _tolerance;
2647 2666

	
2648 2667
    public:
2649 2668

	
2650 2669
      ResBackwardFilter(const CM& capacity, const FM& flow,
2651 2670
                        const TL& tolerance = TL())
2652 2671
        : _capacity(&capacity), _flow(&flow), _tolerance(tolerance) { }
2653 2672

	
2654 2673
      bool operator[](const typename DGR::Arc& a) const {
2655 2674
        return _tolerance.positive((*_flow)[a]);
2656 2675
      }
2657 2676
    };
2658 2677

	
2659 2678
  }
2660 2679

	
2661 2680
  /// \ingroup graph_adaptors
2662 2681
  ///
2663 2682
  /// \brief Adaptor class for composing the residual digraph for directed
2664 2683
  /// flow and circulation problems.
2665 2684
  ///
2666 2685
  /// ResidualDigraph can be used for composing the \e residual digraph
2667 2686
  /// for directed flow and circulation problems. Let \f$ G=(V, A) \f$
2668 2687
  /// be a directed graph and let \f$ F \f$ be a number type.
2669 2688
  /// Let \f$ flow, cap: A\to F \f$ be functions on the arcs.
2670 2689
  /// This adaptor implements a digraph structure with node set \f$ V \f$
2671 2690
  /// and arc set \f$ A_{forward}\cup A_{backward} \f$,
2672 2691
  /// where \f$ A_{forward}=\{uv : uv\in A, flow(uv)<cap(uv)\} \f$ and
2673 2692
  /// \f$ A_{backward}=\{vu : uv\in A, flow(uv)>0\} \f$, i.e. the so
2674 2693
  /// called residual digraph.
2675 2694
  /// When the union \f$ A_{forward}\cup A_{backward} \f$ is taken,
2676 2695
  /// multiplicities are counted, i.e. the adaptor has exactly
2677 2696
  /// \f$ |A_{forward}| + |A_{backward}|\f$ arcs (it may have parallel
2678 2697
  /// arcs).
2679 2698
  /// This class conforms to the \ref concepts::Digraph "Digraph" concept.
2680 2699
  ///
2700
  /// This class provides only linear time counting for nodes and arcs.
2701
  ///
2681 2702
  /// \tparam DGR The type of the adapted digraph.
2682 2703
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
2683 2704
  /// It is implicitly \c const.
2684 2705
  /// \tparam CM The type of the capacity map.
2685 2706
  /// It must be an arc map of some numerical type, which defines
2686 2707
  /// the capacities in the flow problem. It is implicitly \c const.
2687 2708
  /// The default type is
2688 2709
  /// \ref concepts::Digraph::ArcMap "GR::ArcMap<int>".
2689 2710
  /// \tparam FM The type of the flow map.
2690 2711
  /// It must be an arc map of some numerical type, which defines
2691 2712
  /// the flow values in the flow problem. The default type is \c CM.
2692 2713
  /// \tparam TL The tolerance type for handling inexact computation.
2693 2714
  /// The default tolerance type depends on the value type of the
2694 2715
  /// capacity map.
2695 2716
  ///
2696 2717
  /// \note This adaptor is implemented using Undirector and FilterArcs
2697 2718
  /// adaptors.
2698 2719
  ///
2699 2720
  /// \note The \c Node type of this adaptor and the adapted digraph are
2700 2721
  /// convertible to each other, moreover the \c Arc type of the adaptor
2701 2722
  /// is convertible to the \c Arc type of the adapted digraph.
2702 2723
#ifdef DOXYGEN
2703 2724
  template<typename DGR, typename CM, typename FM, typename TL>
2704 2725
  class ResidualDigraph
2705 2726
#else
2706 2727
  template<typename DGR,
2707 2728
           typename CM = typename DGR::template ArcMap<int>,
2708 2729
           typename FM = CM,
2709 2730
           typename TL = Tolerance<typename CM::Value> >
2710
  class ResidualDigraph 
2731
  class ResidualDigraph
2711 2732
    : public SubDigraph<
2712 2733
        Undirector<const DGR>,
2713 2734
        ConstMap<typename DGR::Node, Const<bool, true> >,
2714 2735
        typename Undirector<const DGR>::template CombinedArcMap<
2715 2736
          _adaptor_bits::ResForwardFilter<const DGR, CM, FM, TL>,
2716 2737
          _adaptor_bits::ResBackwardFilter<const DGR, CM, FM, TL> > >
2717 2738
#endif
2718 2739
  {
2719 2740
  public:
2720 2741

	
2721 2742
    /// The type of the underlying digraph.
2722 2743
    typedef DGR Digraph;
2723 2744
    /// The type of the capacity map.
2724 2745
    typedef CM CapacityMap;
2725 2746
    /// The type of the flow map.
2726 2747
    typedef FM FlowMap;
2727 2748
    /// The tolerance type.
2728 2749
    typedef TL Tolerance;
2729 2750

	
2730 2751
    typedef typename CapacityMap::Value Value;
2731 2752
    typedef ResidualDigraph Adaptor;
2732 2753

	
2733 2754
  protected:
2734 2755

	
2735 2756
    typedef Undirector<const Digraph> Undirected;
2736 2757

	
2737 2758
    typedef ConstMap<typename DGR::Node, Const<bool, true> > NodeFilter;
2738 2759

	
2739 2760
    typedef _adaptor_bits::ResForwardFilter<const DGR, CM,
2740 2761
                                            FM, TL> ForwardFilter;
2741 2762

	
2742 2763
    typedef _adaptor_bits::ResBackwardFilter<const DGR, CM,
2743 2764
                                             FM, TL> BackwardFilter;
2744 2765

	
2745 2766
    typedef typename Undirected::
2746 2767
      template CombinedArcMap<ForwardFilter, BackwardFilter> ArcFilter;
2747 2768

	
2748 2769
    typedef SubDigraph<Undirected, NodeFilter, ArcFilter> Parent;
2749 2770

	
2750 2771
    const CapacityMap* _capacity;
2751 2772
    FlowMap* _flow;
2752 2773

	
2753 2774
    Undirected _graph;
2754 2775
    NodeFilter _node_filter;
2755 2776
    ForwardFilter _forward_filter;
2756 2777
    BackwardFilter _backward_filter;
2757 2778
    ArcFilter _arc_filter;
2758 2779

	
2759 2780
  public:
2760 2781

	
2761 2782
    /// \brief Constructor
2762 2783
    ///
2763 2784
    /// Constructor of the residual digraph adaptor. The parameters are the
2764 2785
    /// digraph, the capacity map, the flow map, and a tolerance object.
2765 2786
    ResidualDigraph(const DGR& digraph, const CM& capacity,
2766 2787
                    FM& flow, const TL& tolerance = Tolerance())
2767
      : Parent(), _capacity(&capacity), _flow(&flow), 
2788
      : Parent(), _capacity(&capacity), _flow(&flow),
2768 2789
        _graph(digraph), _node_filter(),
2769 2790
        _forward_filter(capacity, flow, tolerance),
2770 2791
        _backward_filter(capacity, flow, tolerance),
2771 2792
        _arc_filter(_forward_filter, _backward_filter)
2772 2793
    {
2773 2794
      Parent::initialize(_graph, _node_filter, _arc_filter);
2774 2795
    }
2775 2796

	
2776 2797
    typedef typename Parent::Arc Arc;
2777 2798

	
2778 2799
    /// \brief Returns the residual capacity of the given arc.
2779 2800
    ///
2780 2801
    /// Returns the residual capacity of the given arc.
2781 2802
    Value residualCapacity(const Arc& a) const {
2782 2803
      if (Undirected::direction(a)) {
2783 2804
        return (*_capacity)[a] - (*_flow)[a];
2784 2805
      } else {
2785 2806
        return (*_flow)[a];
2786 2807
      }
2787 2808
    }
2788 2809

	
2789 2810
    /// \brief Augments on the given arc in the residual digraph.
2790 2811
    ///
2791 2812
    /// Augments on the given arc in the residual digraph. It increases
2792 2813
    /// or decreases the flow value on the original arc according to the
2793 2814
    /// direction of the residual arc.
2794 2815
    void augment(const Arc& a, const Value& v) const {
2795 2816
      if (Undirected::direction(a)) {
2796 2817
        _flow->set(a, (*_flow)[a] + v);
2797 2818
      } else {
2798 2819
        _flow->set(a, (*_flow)[a] - v);
2799 2820
      }
2800 2821
    }
2801 2822

	
2802 2823
    /// \brief Returns \c true if the given residual arc is a forward arc.
2803 2824
    ///
2804 2825
    /// Returns \c true if the given residual arc has the same orientation
2805 2826
    /// as the original arc, i.e. it is a so called forward arc.
2806 2827
    static bool forward(const Arc& a) {
2807 2828
      return Undirected::direction(a);
2808 2829
    }
2809 2830

	
2810 2831
    /// \brief Returns \c true if the given residual arc is a backward arc.
2811 2832
    ///
2812 2833
    /// Returns \c true if the given residual arc has the opposite orientation
2813 2834
    /// than the original arc, i.e. it is a so called backward arc.
2814 2835
    static bool backward(const Arc& a) {
2815 2836
      return !Undirected::direction(a);
2816 2837
    }
2817 2838

	
2818 2839
    /// \brief Returns the forward oriented residual arc.
2819 2840
    ///
2820 2841
    /// Returns the forward oriented residual arc related to the given
2821 2842
    /// arc of the underlying digraph.
2822 2843
    static Arc forward(const typename Digraph::Arc& a) {
2823 2844
      return Undirected::direct(a, true);
2824 2845
    }
2825 2846

	
2826 2847
    /// \brief Returns the backward oriented residual arc.
2827 2848
    ///
2828 2849
    /// Returns the backward oriented residual arc related to the given
2829 2850
    /// arc of the underlying digraph.
2830 2851
    static Arc backward(const typename Digraph::Arc& a) {
2831 2852
      return Undirected::direct(a, false);
2832 2853
    }
2833 2854

	
2834 2855
    /// \brief Residual capacity map.
2835 2856
    ///
2836 2857
    /// This map adaptor class can be used for obtaining the residual
2837 2858
    /// capacities as an arc map of the residual digraph.
2838 2859
    /// Its value type is inherited from the capacity map.
2839 2860
    class ResidualCapacity {
2840 2861
    protected:
2841 2862
      const Adaptor* _adaptor;
2842 2863
    public:
2843 2864
      /// The key type of the map
2844 2865
      typedef Arc Key;
2845 2866
      /// The value type of the map
2846 2867
      typedef typename CapacityMap::Value Value;
2847 2868

	
2848 2869
      /// Constructor
2849
      ResidualCapacity(const ResidualDigraph<DGR, CM, FM, TL>& adaptor) 
2870
      ResidualCapacity(const ResidualDigraph<DGR, CM, FM, TL>& adaptor)
2850 2871
        : _adaptor(&adaptor) {}
2851 2872

	
2852 2873
      /// Returns the value associated with the given residual arc
2853 2874
      Value operator[](const Arc& a) const {
2854 2875
        return _adaptor->residualCapacity(a);
2855 2876
      }
2856 2877

	
2857 2878
    };
2858 2879

	
2859 2880
    /// \brief Returns a residual capacity map
2860 2881
    ///
2861 2882
    /// This function just returns a residual capacity map.
2862 2883
    ResidualCapacity residualCapacity() const {
2863 2884
      return ResidualCapacity(*this);
2864 2885
    }
2865 2886

	
2866 2887
  };
2867 2888

	
2868 2889
  /// \brief Returns a (read-only) Residual adaptor
2869 2890
  ///
2870 2891
  /// This function just returns a (read-only) \ref ResidualDigraph adaptor.
2871 2892
  /// \ingroup graph_adaptors
2872 2893
  /// \relates ResidualDigraph
2873 2894
    template<typename DGR, typename CM, typename FM>
2874 2895
  ResidualDigraph<DGR, CM, FM>
2875 2896
  residualDigraph(const DGR& digraph, const CM& capacity_map, FM& flow_map) {
2876 2897
    return ResidualDigraph<DGR, CM, FM> (digraph, capacity_map, flow_map);
2877 2898
  }
2878 2899

	
2879 2900

	
2880 2901
  template <typename DGR>
2881 2902
  class SplitNodesBase {
2882 2903
    typedef DigraphAdaptorBase<const DGR> Parent;
2883 2904

	
2884 2905
  public:
2885 2906

	
2886 2907
    typedef DGR Digraph;
2887 2908
    typedef SplitNodesBase Adaptor;
2888 2909

	
2889 2910
    typedef typename DGR::Node DigraphNode;
2890 2911
    typedef typename DGR::Arc DigraphArc;
2891 2912

	
2892 2913
    class Node;
2893 2914
    class Arc;
2894 2915

	
2895 2916
  private:
2896 2917

	
2897 2918
    template <typename T> class NodeMapBase;
2898 2919
    template <typename T> class ArcMapBase;
2899 2920

	
2900 2921
  public:
2901 2922

	
2902 2923
    class Node : public DigraphNode {
2903 2924
      friend class SplitNodesBase;
2904 2925
      template <typename T> friend class NodeMapBase;
2905 2926
    private:
2906 2927

	
2907 2928
      bool _in;
2908 2929
      Node(DigraphNode node, bool in)
2909 2930
        : DigraphNode(node), _in(in) {}
2910 2931

	
2911 2932
    public:
2912 2933

	
2913 2934
      Node() {}
2914 2935
      Node(Invalid) : DigraphNode(INVALID), _in(true) {}
2915 2936

	
2916 2937
      bool operator==(const Node& node) const {
2917 2938
        return DigraphNode::operator==(node) && _in == node._in;
2918 2939
      }
2919 2940

	
2920 2941
      bool operator!=(const Node& node) const {
2921 2942
        return !(*this == node);
2922 2943
      }
2923 2944

	
2924 2945
      bool operator<(const Node& node) const {
2925 2946
        return DigraphNode::operator<(node) ||
2926 2947
          (DigraphNode::operator==(node) && _in < node._in);
2927 2948
      }
2928 2949
    };
2929 2950

	
2930 2951
    class Arc {
2931 2952
      friend class SplitNodesBase;
2932 2953
      template <typename T> friend class ArcMapBase;
2933 2954
    private:
2934 2955
      typedef BiVariant<DigraphArc, DigraphNode> ArcImpl;
2935 2956

	
2936 2957
      explicit Arc(const DigraphArc& arc) : _item(arc) {}
2937 2958
      explicit Arc(const DigraphNode& node) : _item(node) {}
2938 2959

	
2939 2960
      ArcImpl _item;
2940 2961

	
2941 2962
    public:
2942 2963
      Arc() {}
2943 2964
      Arc(Invalid) : _item(DigraphArc(INVALID)) {}
2944 2965

	
2945 2966
      bool operator==(const Arc& arc) const {
2946 2967
        if (_item.firstState()) {
2947 2968
          if (arc._item.firstState()) {
2948 2969
            return _item.first() == arc._item.first();
2949 2970
          }
2950 2971
        } else {
2951 2972
          if (arc._item.secondState()) {
2952 2973
            return _item.second() == arc._item.second();
2953 2974
          }
2954 2975
        }
2955 2976
        return false;
2956 2977
      }
2957 2978

	
2958 2979
      bool operator!=(const Arc& arc) const {
2959 2980
        return !(*this == arc);
2960 2981
      }
2961 2982

	
2962 2983
      bool operator<(const Arc& arc) const {
2963 2984
        if (_item.firstState()) {
2964 2985
          if (arc._item.firstState()) {
2965 2986
            return _item.first() < arc._item.first();
2966 2987
          }
2967 2988
          return false;
2968 2989
        } else {
2969 2990
          if (arc._item.secondState()) {
2970 2991
            return _item.second() < arc._item.second();
2971 2992
          }
2972 2993
          return true;
2973 2994
        }
2974 2995
      }
2975 2996

	
2976 2997
      operator DigraphArc() const { return _item.first(); }
2977 2998
      operator DigraphNode() const { return _item.second(); }
2978 2999

	
2979 3000
    };
2980 3001

	
2981 3002
    void first(Node& n) const {
2982 3003
      _digraph->first(n);
2983 3004
      n._in = true;
2984 3005
    }
2985 3006

	
2986 3007
    void next(Node& n) const {
2987 3008
      if (n._in) {
2988 3009
        n._in = false;
2989 3010
      } else {
2990 3011
        n._in = true;
2991 3012
        _digraph->next(n);
2992 3013
      }
2993 3014
    }
2994 3015

	
2995 3016
    void first(Arc& e) const {
2996 3017
      e._item.setSecond();
2997 3018
      _digraph->first(e._item.second());
2998 3019
      if (e._item.second() == INVALID) {
2999 3020
        e._item.setFirst();
3000 3021
        _digraph->first(e._item.first());
3001 3022
      }
3002 3023
    }
3003 3024

	
3004 3025
    void next(Arc& e) const {
3005 3026
      if (e._item.secondState()) {
3006 3027
        _digraph->next(e._item.second());
3007 3028
        if (e._item.second() == INVALID) {
3008 3029
          e._item.setFirst();
3009 3030
          _digraph->first(e._item.first());
3010 3031
        }
3011 3032
      } else {
3012 3033
        _digraph->next(e._item.first());
3013 3034
      }
3014 3035
    }
3015 3036

	
3016 3037
    void firstOut(Arc& e, const Node& n) const {
3017 3038
      if (n._in) {
3018 3039
        e._item.setSecond(n);
3019 3040
      } else {
3020 3041
        e._item.setFirst();
3021 3042
        _digraph->firstOut(e._item.first(), n);
3022 3043
      }
3023 3044
    }
3024 3045

	
3025 3046
    void nextOut(Arc& e) const {
3026 3047
      if (!e._item.firstState()) {
3027 3048
        e._item.setFirst(INVALID);
3028 3049
      } else {
3029 3050
        _digraph->nextOut(e._item.first());
3030 3051
      }
3031 3052
    }
3032 3053

	
3033 3054
    void firstIn(Arc& e, const Node& n) const {
3034 3055
      if (!n._in) {
3035 3056
        e._item.setSecond(n);
3036 3057
      } else {
3037 3058
        e._item.setFirst();
3038 3059
        _digraph->firstIn(e._item.first(), n);
3039 3060
      }
3040 3061
    }
3041 3062

	
3042 3063
    void nextIn(Arc& e) const {
3043 3064
      if (!e._item.firstState()) {
3044 3065
        e._item.setFirst(INVALID);
3045 3066
      } else {
3046 3067
        _digraph->nextIn(e._item.first());
3047 3068
      }
3048 3069
    }
3049 3070

	
3050 3071
    Node source(const Arc& e) const {
3051 3072
      if (e._item.firstState()) {
3052 3073
        return Node(_digraph->source(e._item.first()), false);
3053 3074
      } else {
3054 3075
        return Node(e._item.second(), true);
3055 3076
      }
3056 3077
    }
3057 3078

	
3058 3079
    Node target(const Arc& e) const {
3059 3080
      if (e._item.firstState()) {
3060 3081
        return Node(_digraph->target(e._item.first()), true);
3061 3082
      } else {
3062 3083
        return Node(e._item.second(), false);
3063 3084
      }
3064 3085
    }
3065 3086

	
3066 3087
    int id(const Node& n) const {
3067 3088
      return (_digraph->id(n) << 1) | (n._in ? 0 : 1);
3068 3089
    }
3069 3090
    Node nodeFromId(int ix) const {
3070 3091
      return Node(_digraph->nodeFromId(ix >> 1), (ix & 1) == 0);
3071 3092
    }
3072 3093
    int maxNodeId() const {
3073 3094
      return 2 * _digraph->maxNodeId() + 1;
3074 3095
    }
3075 3096

	
3076 3097
    int id(const Arc& e) const {
3077 3098
      if (e._item.firstState()) {
3078 3099
        return _digraph->id(e._item.first()) << 1;
3079 3100
      } else {
3080 3101
        return (_digraph->id(e._item.second()) << 1) | 1;
3081 3102
      }
3082 3103
    }
3083 3104
    Arc arcFromId(int ix) const {
3084 3105
      if ((ix & 1) == 0) {
3085 3106
        return Arc(_digraph->arcFromId(ix >> 1));
3086 3107
      } else {
3087 3108
        return Arc(_digraph->nodeFromId(ix >> 1));
3088 3109
      }
3089 3110
    }
3090 3111
    int maxArcId() const {
3091 3112
      return std::max(_digraph->maxNodeId() << 1,
3092 3113
                      (_digraph->maxArcId() << 1) | 1);
3093 3114
    }
3094 3115

	
3095 3116
    static bool inNode(const Node& n) {
3096 3117
      return n._in;
3097 3118
    }
3098 3119

	
3099 3120
    static bool outNode(const Node& n) {
3100 3121
      return !n._in;
3101 3122
    }
3102 3123

	
3103 3124
    static bool origArc(const Arc& e) {
3104 3125
      return e._item.firstState();
3105 3126
    }
3106 3127

	
3107 3128
    static bool bindArc(const Arc& e) {
3108 3129
      return e._item.secondState();
3109 3130
    }
3110 3131

	
3111 3132
    static Node inNode(const DigraphNode& n) {
3112 3133
      return Node(n, true);
3113 3134
    }
3114 3135

	
3115 3136
    static Node outNode(const DigraphNode& n) {
3116 3137
      return Node(n, false);
3117 3138
    }
3118 3139

	
3119 3140
    static Arc arc(const DigraphNode& n) {
3120 3141
      return Arc(n);
3121 3142
    }
3122 3143

	
3123 3144
    static Arc arc(const DigraphArc& e) {
3124 3145
      return Arc(e);
3125 3146
    }
3126 3147

	
3127 3148
    typedef True NodeNumTag;
3128 3149
    int nodeNum() const {
3129 3150
      return  2 * countNodes(*_digraph);
3130 3151
    }
3131 3152

	
3132 3153
    typedef True ArcNumTag;
3133 3154
    int arcNum() const {
3134 3155
      return countArcs(*_digraph) + countNodes(*_digraph);
3135 3156
    }
3136 3157

	
3137 3158
    typedef True FindArcTag;
3138 3159
    Arc findArc(const Node& u, const Node& v,
3139 3160
                const Arc& prev = INVALID) const {
3140 3161
      if (inNode(u) && outNode(v)) {
3141 3162
        if (static_cast<const DigraphNode&>(u) ==
3142 3163
            static_cast<const DigraphNode&>(v) && prev == INVALID) {
3143 3164
          return Arc(u);
3144 3165
        }
3145 3166
      }
3146 3167
      else if (outNode(u) && inNode(v)) {
3147 3168
        return Arc(::lemon::findArc(*_digraph, u, v, prev));
3148 3169
      }
3149 3170
      return INVALID;
3150 3171
    }
3151 3172

	
3152 3173
  private:
3153 3174

	
3154 3175
    template <typename V>
3155 3176
    class NodeMapBase
3156 3177
      : public MapTraits<typename Parent::template NodeMap<V> > {
3157 3178
      typedef typename Parent::template NodeMap<V> NodeImpl;
3158 3179
    public:
3159 3180
      typedef Node Key;
3160 3181
      typedef V Value;
3161 3182
      typedef typename MapTraits<NodeImpl>::ReferenceMapTag ReferenceMapTag;
3162 3183
      typedef typename MapTraits<NodeImpl>::ReturnValue ReturnValue;
3163 3184
      typedef typename MapTraits<NodeImpl>::ConstReturnValue ConstReturnValue;
3164 3185
      typedef typename MapTraits<NodeImpl>::ReturnValue Reference;
3165 3186
      typedef typename MapTraits<NodeImpl>::ConstReturnValue ConstReference;
3166 3187

	
3167 3188
      NodeMapBase(const SplitNodesBase<DGR>& adaptor)
3168 3189
        : _in_map(*adaptor._digraph), _out_map(*adaptor._digraph) {}
3169 3190
      NodeMapBase(const SplitNodesBase<DGR>& adaptor, const V& value)
3170 3191
        : _in_map(*adaptor._digraph, value),
3171 3192
          _out_map(*adaptor._digraph, value) {}
3172 3193

	
3173 3194
      void set(const Node& key, const V& val) {
3174 3195
        if (SplitNodesBase<DGR>::inNode(key)) { _in_map.set(key, val); }
3175 3196
        else {_out_map.set(key, val); }
3176 3197
      }
3177 3198

	
3178 3199
      ReturnValue operator[](const Node& key) {
3179 3200
        if (SplitNodesBase<DGR>::inNode(key)) { return _in_map[key]; }
3180 3201
        else { return _out_map[key]; }
3181 3202
      }
3182 3203

	
3183 3204
      ConstReturnValue operator[](const Node& key) const {
3184 3205
        if (Adaptor::inNode(key)) { return _in_map[key]; }
3185 3206
        else { return _out_map[key]; }
3186 3207
      }
3187 3208

	
3188 3209
    private:
3189 3210
      NodeImpl _in_map, _out_map;
3190 3211
    };
3191 3212

	
3192 3213
    template <typename V>
3193 3214
    class ArcMapBase
3194 3215
      : public MapTraits<typename Parent::template ArcMap<V> > {
3195 3216
      typedef typename Parent::template ArcMap<V> ArcImpl;
3196 3217
      typedef typename Parent::template NodeMap<V> NodeImpl;
3197 3218
    public:
3198 3219
      typedef Arc Key;
3199 3220
      typedef V Value;
3200 3221
      typedef typename MapTraits<ArcImpl>::ReferenceMapTag ReferenceMapTag;
3201 3222
      typedef typename MapTraits<ArcImpl>::ReturnValue ReturnValue;
3202 3223
      typedef typename MapTraits<ArcImpl>::ConstReturnValue ConstReturnValue;
3203 3224
      typedef typename MapTraits<ArcImpl>::ReturnValue Reference;
3204 3225
      typedef typename MapTraits<ArcImpl>::ConstReturnValue ConstReference;
3205 3226

	
3206 3227
      ArcMapBase(const SplitNodesBase<DGR>& adaptor)
3207 3228
        : _arc_map(*adaptor._digraph), _node_map(*adaptor._digraph) {}
3208 3229
      ArcMapBase(const SplitNodesBase<DGR>& adaptor, const V& value)
3209 3230
        : _arc_map(*adaptor._digraph, value),
3210 3231
          _node_map(*adaptor._digraph, value) {}
3211 3232

	
3212 3233
      void set(const Arc& key, const V& val) {
3213 3234
        if (SplitNodesBase<DGR>::origArc(key)) {
3214 3235
          _arc_map.set(static_cast<const DigraphArc&>(key), val);
3215 3236
        } else {
3216 3237
          _node_map.set(static_cast<const DigraphNode&>(key), val);
3217 3238
        }
3218 3239
      }
3219 3240

	
3220 3241
      ReturnValue operator[](const Arc& key) {
3221 3242
        if (SplitNodesBase<DGR>::origArc(key)) {
3222 3243
          return _arc_map[static_cast<const DigraphArc&>(key)];
3223 3244
        } else {
3224 3245
          return _node_map[static_cast<const DigraphNode&>(key)];
3225 3246
        }
3226 3247
      }
3227 3248

	
3228 3249
      ConstReturnValue operator[](const Arc& key) const {
3229 3250
        if (SplitNodesBase<DGR>::origArc(key)) {
3230 3251
          return _arc_map[static_cast<const DigraphArc&>(key)];
3231 3252
        } else {
3232 3253
          return _node_map[static_cast<const DigraphNode&>(key)];
3233 3254
        }
3234 3255
      }
3235 3256

	
3236 3257
    private:
3237 3258
      ArcImpl _arc_map;
3238 3259
      NodeImpl _node_map;
3239 3260
    };
3240 3261

	
3241 3262
  public:
3242 3263

	
3243 3264
    template <typename V>
3244 3265
    class NodeMap
3245 3266
      : public SubMapExtender<SplitNodesBase<DGR>, NodeMapBase<V> > {
3246 3267
      typedef SubMapExtender<SplitNodesBase<DGR>, NodeMapBase<V> > Parent;
3247 3268

	
3248 3269
    public:
3249 3270
      typedef V Value;
3250 3271

	
3251 3272
      NodeMap(const SplitNodesBase<DGR>& adaptor)
3252 3273
        : Parent(adaptor) {}
3253 3274

	
3254 3275
      NodeMap(const SplitNodesBase<DGR>& adaptor, const V& value)
3255 3276
        : Parent(adaptor, value) {}
3256 3277

	
3257 3278
    private:
3258 3279
      NodeMap& operator=(const NodeMap& cmap) {
3259 3280
        return operator=<NodeMap>(cmap);
3260 3281
      }
3261 3282

	
3262 3283
      template <typename CMap>
3263 3284
      NodeMap& operator=(const CMap& cmap) {
3264 3285
        Parent::operator=(cmap);
3265 3286
        return *this;
3266 3287
      }
3267 3288
    };
3268 3289

	
3269 3290
    template <typename V>
3270 3291
    class ArcMap
3271 3292
      : public SubMapExtender<SplitNodesBase<DGR>, ArcMapBase<V> > {
3272 3293
      typedef SubMapExtender<SplitNodesBase<DGR>, ArcMapBase<V> > Parent;
3273 3294

	
3274 3295
    public:
3275 3296
      typedef V Value;
3276 3297

	
3277 3298
      ArcMap(const SplitNodesBase<DGR>& adaptor)
3278 3299
        : Parent(adaptor) {}
3279 3300

	
3280 3301
      ArcMap(const SplitNodesBase<DGR>& adaptor, const V& value)
3281 3302
        : Parent(adaptor, value) {}
3282 3303

	
3283 3304
    private:
3284 3305
      ArcMap& operator=(const ArcMap& cmap) {
3285 3306
        return operator=<ArcMap>(cmap);
3286 3307
      }
3287 3308

	
3288 3309
      template <typename CMap>
3289 3310
      ArcMap& operator=(const CMap& cmap) {
3290 3311
        Parent::operator=(cmap);
3291 3312
        return *this;
3292 3313
      }
3293 3314
    };
3294 3315

	
3295 3316
  protected:
3296 3317

	
3297 3318
    SplitNodesBase() : _digraph(0) {}
3298 3319

	
3299 3320
    DGR* _digraph;
3300 3321

	
3301 3322
    void initialize(Digraph& digraph) {
3302 3323
      _digraph = &digraph;
3303 3324
    }
3304 3325

	
3305 3326
  };
3306 3327

	
3307 3328
  /// \ingroup graph_adaptors
3308 3329
  ///
3309 3330
  /// \brief Adaptor class for splitting the nodes of a digraph.
3310 3331
  ///
3311 3332
  /// SplitNodes adaptor can be used for splitting each node into an
3312 3333
  /// \e in-node and an \e out-node in a digraph. Formaly, the adaptor
3313 3334
  /// replaces each node \f$ u \f$ in the digraph with two nodes,
3314 3335
  /// namely node \f$ u_{in} \f$ and node \f$ u_{out} \f$.
3315 3336
  /// If there is a \f$ (v, u) \f$ arc in the original digraph, then the
3316 3337
  /// new target of the arc will be \f$ u_{in} \f$ and similarly the
3317 3338
  /// source of each original \f$ (u, v) \f$ arc will be \f$ u_{out} \f$.
3318 3339
  /// The adaptor adds an additional \e bind \e arc from \f$ u_{in} \f$
3319 3340
  /// to \f$ u_{out} \f$ for each node \f$ u \f$ of the original digraph.
3320 3341
  ///
3321 3342
  /// The aim of this class is running an algorithm with respect to node
3322 3343
  /// costs or capacities if the algorithm considers only arc costs or
3323 3344
  /// capacities directly.
3324 3345
  /// In this case you can use \c SplitNodes adaptor, and set the node
3325 3346
  /// costs/capacities of the original digraph to the \e bind \e arcs
3326 3347
  /// in the adaptor.
3327 3348
  ///
3349
  /// This class provides item counting in the same time as the adapted
3350
  /// digraph structure.
3351
  ///
3328 3352
  /// \tparam DGR The type of the adapted digraph.
3329 3353
  /// It must conform to the \ref concepts::Digraph "Digraph" concept.
3330 3354
  /// It is implicitly \c const.
3331 3355
  ///
3332 3356
  /// \note The \c Node type of this adaptor is converible to the \c Node
3333 3357
  /// type of the adapted digraph.
3334 3358
  template <typename DGR>
3335 3359
#ifdef DOXYGEN
3336 3360
  class SplitNodes {
3337 3361
#else
3338 3362
  class SplitNodes
3339 3363
    : public DigraphAdaptorExtender<SplitNodesBase<const DGR> > {
3340 3364
#endif
3341 3365
    typedef DigraphAdaptorExtender<SplitNodesBase<const DGR> > Parent;
3342 3366

	
3343 3367
  public:
3344 3368
    typedef DGR Digraph;
3345 3369

	
3346 3370
    typedef typename DGR::Node DigraphNode;
3347 3371
    typedef typename DGR::Arc DigraphArc;
3348 3372

	
3349 3373
    typedef typename Parent::Node Node;
3350 3374
    typedef typename Parent::Arc Arc;
3351 3375

	
3352 3376
    /// \brief Constructor
3353 3377
    ///
3354 3378
    /// Constructor of the adaptor.
3355 3379
    SplitNodes(const DGR& g) {
3356 3380
      Parent::initialize(g);
3357 3381
    }
3358 3382

	
3359 3383
    /// \brief Returns \c true if the given node is an in-node.
3360 3384
    ///
3361 3385
    /// Returns \c true if the given node is an in-node.
3362 3386
    static bool inNode(const Node& n) {
3363 3387
      return Parent::inNode(n);
3364 3388
    }
3365 3389

	
3366 3390
    /// \brief Returns \c true if the given node is an out-node.
3367 3391
    ///
3368 3392
    /// Returns \c true if the given node is an out-node.
3369 3393
    static bool outNode(const Node& n) {
3370 3394
      return Parent::outNode(n);
3371 3395
    }
3372 3396

	
3373 3397
    /// \brief Returns \c true if the given arc is an original arc.
3374 3398
    ///
3375 3399
    /// Returns \c true if the given arc is one of the arcs in the
3376 3400
    /// original digraph.
3377 3401
    static bool origArc(const Arc& a) {
3378 3402
      return Parent::origArc(a);
3379 3403
    }
3380 3404

	
3381 3405
    /// \brief Returns \c true if the given arc is a bind arc.
3382 3406
    ///
3383 3407
    /// Returns \c true if the given arc is a bind arc, i.e. it connects
3384 3408
    /// an in-node and an out-node.
3385 3409
    static bool bindArc(const Arc& a) {
3386 3410
      return Parent::bindArc(a);
3387 3411
    }
3388 3412

	
3389 3413
    /// \brief Returns the in-node created from the given original node.
3390 3414
    ///
3391 3415
    /// Returns the in-node created from the given original node.
3392 3416
    static Node inNode(const DigraphNode& n) {
3393 3417
      return Parent::inNode(n);
3394 3418
    }
3395 3419

	
3396 3420
    /// \brief Returns the out-node created from the given original node.
3397 3421
    ///
3398 3422
    /// Returns the out-node created from the given original node.
3399 3423
    static Node outNode(const DigraphNode& n) {
3400 3424
      return Parent::outNode(n);
3401 3425
    }
3402 3426

	
3403 3427
    /// \brief Returns the bind arc that corresponds to the given
3404 3428
    /// original node.
3405 3429
    ///
3406 3430
    /// Returns the bind arc in the adaptor that corresponds to the given
3407 3431
    /// original node, i.e. the arc connecting the in-node and out-node
3408 3432
    /// of \c n.
3409 3433
    static Arc arc(const DigraphNode& n) {
3410 3434
      return Parent::arc(n);
3411 3435
    }
3412 3436

	
3413 3437
    /// \brief Returns the arc that corresponds to the given original arc.
3414 3438
    ///
3415 3439
    /// Returns the arc in the adaptor that corresponds to the given
3416 3440
    /// original arc.
3417 3441
    static Arc arc(const DigraphArc& a) {
3418 3442
      return Parent::arc(a);
3419 3443
    }
3420 3444

	
3421 3445
    /// \brief Node map combined from two original node maps
3422 3446
    ///
3423 3447
    /// This map adaptor class adapts two node maps of the original digraph
3424 3448
    /// to get a node map of the split digraph.
3425 3449
    /// Its value type is inherited from the first node map type (\c IN).
3426
    /// \tparam IN The type of the node map for the in-nodes. 
3450
    /// \tparam IN The type of the node map for the in-nodes.
3427 3451
    /// \tparam OUT The type of the node map for the out-nodes.
3428 3452
    template <typename IN, typename OUT>
3429 3453
    class CombinedNodeMap {
3430 3454
    public:
3431 3455

	
3432 3456
      /// The key type of the map
3433 3457
      typedef Node Key;
3434 3458
      /// The value type of the map
3435 3459
      typedef typename IN::Value Value;
3436 3460

	
3437 3461
      typedef typename MapTraits<IN>::ReferenceMapTag ReferenceMapTag;
3438 3462
      typedef typename MapTraits<IN>::ReturnValue ReturnValue;
3439 3463
      typedef typename MapTraits<IN>::ConstReturnValue ConstReturnValue;
3440 3464
      typedef typename MapTraits<IN>::ReturnValue Reference;
3441 3465
      typedef typename MapTraits<IN>::ConstReturnValue ConstReference;
3442 3466

	
3443 3467
      /// Constructor
3444 3468
      CombinedNodeMap(IN& in_map, OUT& out_map)
3445 3469
        : _in_map(in_map), _out_map(out_map) {}
3446 3470

	
3447 3471
      /// Returns the value associated with the given key.
3448 3472
      Value operator[](const Key& key) const {
3449 3473
        if (SplitNodesBase<const DGR>::inNode(key)) {
3450 3474
          return _in_map[key];
3451 3475
        } else {
3452 3476
          return _out_map[key];
3453 3477
        }
3454 3478
      }
3455 3479

	
3456 3480
      /// Returns a reference to the value associated with the given key.
3457 3481
      Value& operator[](const Key& key) {
3458 3482
        if (SplitNodesBase<const DGR>::inNode(key)) {
3459 3483
          return _in_map[key];
3460 3484
        } else {
3461 3485
          return _out_map[key];
3462 3486
        }
3463 3487
      }
3464 3488

	
3465 3489
      /// Sets the value associated with the given key.
3466 3490
      void set(const Key& key, const Value& value) {
3467 3491
        if (SplitNodesBase<const DGR>::inNode(key)) {
3468 3492
          _in_map.set(key, value);
3469 3493
        } else {
3470 3494
          _out_map.set(key, value);
3471 3495
        }
3472 3496
      }
3473 3497

	
3474 3498
    private:
3475 3499

	
3476 3500
      IN& _in_map;
3477 3501
      OUT& _out_map;
3478 3502

	
3479 3503
    };
3480 3504

	
3481 3505

	
3482 3506
    /// \brief Returns a combined node map
3483 3507
    ///
3484 3508
    /// This function just returns a combined node map.
3485 3509
    template <typename IN, typename OUT>
3486 3510
    static CombinedNodeMap<IN, OUT>
3487 3511
    combinedNodeMap(IN& in_map, OUT& out_map) {
3488 3512
      return CombinedNodeMap<IN, OUT>(in_map, out_map);
3489 3513
    }
3490 3514

	
3491 3515
    template <typename IN, typename OUT>
3492 3516
    static CombinedNodeMap<const IN, OUT>
3493 3517
    combinedNodeMap(const IN& in_map, OUT& out_map) {
3494 3518
      return CombinedNodeMap<const IN, OUT>(in_map, out_map);
3495 3519
    }
3496 3520

	
3497 3521
    template <typename IN, typename OUT>
3498 3522
    static CombinedNodeMap<IN, const OUT>
3499 3523
    combinedNodeMap(IN& in_map, const OUT& out_map) {
3500 3524
      return CombinedNodeMap<IN, const OUT>(in_map, out_map);
3501 3525
    }
3502 3526

	
3503 3527
    template <typename IN, typename OUT>
3504 3528
    static CombinedNodeMap<const IN, const OUT>
3505 3529
    combinedNodeMap(const IN& in_map, const OUT& out_map) {
3506 3530
      return CombinedNodeMap<const IN, const OUT>(in_map, out_map);
3507 3531
    }
3508 3532

	
3509 3533
    /// \brief Arc map combined from an arc map and a node map of the
3510 3534
    /// original digraph.
3511 3535
    ///
3512 3536
    /// This map adaptor class adapts an arc map and a node map of the
3513 3537
    /// original digraph to get an arc map of the split digraph.
3514 3538
    /// Its value type is inherited from the original arc map type (\c AM).
3515 3539
    /// \tparam AM The type of the arc map.
3516 3540
    /// \tparam NM the type of the node map.
3517 3541
    template <typename AM, typename NM>
3518 3542
    class CombinedArcMap {
3519 3543
    public:
3520 3544

	
3521 3545
      /// The key type of the map
3522 3546
      typedef Arc Key;
3523 3547
      /// The value type of the map
3524 3548
      typedef typename AM::Value Value;
3525 3549

	
3526 3550
      typedef typename MapTraits<AM>::ReferenceMapTag ReferenceMapTag;
3527 3551
      typedef typename MapTraits<AM>::ReturnValue ReturnValue;
3528 3552
      typedef typename MapTraits<AM>::ConstReturnValue ConstReturnValue;
3529 3553
      typedef typename MapTraits<AM>::ReturnValue Reference;
3530 3554
      typedef typename MapTraits<AM>::ConstReturnValue ConstReference;
3531 3555

	
3532 3556
      /// Constructor
3533 3557
      CombinedArcMap(AM& arc_map, NM& node_map)
3534 3558
        : _arc_map(arc_map), _node_map(node_map) {}
3535 3559

	
3536 3560
      /// Returns the value associated with the given key.
3537 3561
      Value operator[](const Key& arc) const {
3538 3562
        if (SplitNodesBase<const DGR>::origArc(arc)) {
3539 3563
          return _arc_map[arc];
3540 3564
        } else {
3541 3565
          return _node_map[arc];
3542 3566
        }
3543 3567
      }
3544 3568

	
3545 3569
      /// Returns a reference to the value associated with the given key.
3546 3570
      Value& operator[](const Key& arc) {
3547 3571
        if (SplitNodesBase<const DGR>::origArc(arc)) {
3548 3572
          return _arc_map[arc];
3549 3573
        } else {
3550 3574
          return _node_map[arc];
3551 3575
        }
3552 3576
      }
3553 3577

	
3554 3578
      /// Sets the value associated with the given key.
3555 3579
      void set(const Arc& arc, const Value& val) {
3556 3580
        if (SplitNodesBase<const DGR>::origArc(arc)) {
3557 3581
          _arc_map.set(arc, val);
3558 3582
        } else {
3559 3583
          _node_map.set(arc, val);
3560 3584
        }
3561 3585
      }
3562 3586

	
3563 3587
    private:
3564 3588

	
3565 3589
      AM& _arc_map;
3566 3590
      NM& _node_map;
3567 3591

	
3568 3592
    };
3569 3593

	
3570 3594
    /// \brief Returns a combined arc map
3571 3595
    ///
3572 3596
    /// This function just returns a combined arc map.
3573 3597
    template <typename ArcMap, typename NodeMap>
3574 3598
    static CombinedArcMap<ArcMap, NodeMap>
3575 3599
    combinedArcMap(ArcMap& arc_map, NodeMap& node_map) {
3576 3600
      return CombinedArcMap<ArcMap, NodeMap>(arc_map, node_map);
3577 3601
    }
3578 3602

	
3579 3603
    template <typename ArcMap, typename NodeMap>
3580 3604
    static CombinedArcMap<const ArcMap, NodeMap>
3581 3605
    combinedArcMap(const ArcMap& arc_map, NodeMap& node_map) {
3582 3606
      return CombinedArcMap<const ArcMap, NodeMap>(arc_map, node_map);
3583 3607
    }
3584 3608

	
3585 3609
    template <typename ArcMap, typename NodeMap>
3586 3610
    static CombinedArcMap<ArcMap, const NodeMap>
3587 3611
    combinedArcMap(ArcMap& arc_map, const NodeMap& node_map) {
3588 3612
      return CombinedArcMap<ArcMap, const NodeMap>(arc_map, node_map);
3589 3613
    }
3590 3614

	
3591 3615
    template <typename ArcMap, typename NodeMap>
3592 3616
    static CombinedArcMap<const ArcMap, const NodeMap>
3593 3617
    combinedArcMap(const ArcMap& arc_map, const NodeMap& node_map) {
3594 3618
      return CombinedArcMap<const ArcMap, const NodeMap>(arc_map, node_map);
3595 3619
    }
3596 3620

	
3597 3621
  };
3598 3622

	
3599 3623
  /// \brief Returns a (read-only) SplitNodes adaptor
3600 3624
  ///
3601 3625
  /// This function just returns a (read-only) \ref SplitNodes adaptor.
3602 3626
  /// \ingroup graph_adaptors
3603 3627
  /// \relates SplitNodes
3604 3628
  template<typename DGR>
3605 3629
  SplitNodes<DGR>
3606 3630
  splitNodes(const DGR& digraph) {
3607 3631
    return SplitNodes<DGR>(digraph);
3608 3632
  }
3609 3633

	
3610 3634
#undef LEMON_SCOPE_FIX
3611 3635

	
3612 3636
} //namespace lemon
3613 3637

	
3614 3638
#endif //LEMON_ADAPTORS_H
Ignore white space 6 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-2010
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/arg_parser.h>
20 20

	
21 21
namespace lemon {
22 22

	
23
  void ArgParser::_terminate(ArgParserException::Reason reason) const
24
  {
25
    if(_exit_on_problems)
26
      exit(1);
27
    else throw(ArgParserException(reason));
28
  }
29

	
30

	
23 31
  void ArgParser::_showHelp(void *p)
24 32
  {
25 33
    (static_cast<ArgParser*>(p))->showHelp();
26
    exit(1);
34
    (static_cast<ArgParser*>(p))->_terminate(ArgParserException::HELP);
27 35
  }
28 36

	
29 37
  ArgParser::ArgParser(int argc, const char * const *argv)
30
    :_argc(argc), _argv(argv), _command_name(argv[0]) {
38
    :_argc(argc), _argv(argv), _command_name(argv[0]),
39
    _exit_on_problems(true) {
31 40
    funcOption("-help","Print a short help message",_showHelp,this);
32 41
    synonym("help","-help");
33 42
    synonym("h","-help");
34 43
  }
35 44

	
36 45
  ArgParser::~ArgParser()
37 46
  {
38 47
    for(Opts::iterator i=_opts.begin();i!=_opts.end();++i)
39 48
      if(i->second.self_delete)
40 49
        switch(i->second.type) {
41 50
        case BOOL:
42 51
          delete i->second.bool_p;
43 52
          break;
44 53
        case STRING:
45 54
          delete i->second.string_p;
46 55
          break;
47 56
        case DOUBLE:
48 57
          delete i->second.double_p;
49 58
          break;
50 59
        case INTEGER:
51 60
          delete i->second.int_p;
52 61
          break;
53 62
        case UNKNOWN:
54 63
          break;
55 64
        case FUNC:
56 65
          break;
57 66
        }
58 67
  }
59 68

	
60 69

	
61 70
  ArgParser &ArgParser::intOption(const std::string &name,
62 71
                               const std::string &help,
63 72
                               int value, bool obl)
64 73
  {
65 74
    ParData p;
66 75
    p.int_p=new int(value);
67 76
    p.self_delete=true;
68 77
    p.help=help;
69 78
    p.type=INTEGER;
70 79
    p.mandatory=obl;
71 80
    _opts[name]=p;
72 81
    return *this;
73 82
  }
74 83

	
75 84
  ArgParser &ArgParser::doubleOption(const std::string &name,
76 85
                               const std::string &help,
77 86
                               double value, bool obl)
78 87
  {
79 88
    ParData p;
80 89
    p.double_p=new double(value);
81 90
    p.self_delete=true;
82 91
    p.help=help;
83 92
    p.type=DOUBLE;
84 93
    p.mandatory=obl;
85 94
    _opts[name]=p;
86 95
    return *this;
87 96
  }
88 97

	
89 98
  ArgParser &ArgParser::boolOption(const std::string &name,
90 99
                               const std::string &help,
91 100
                               bool value, bool obl)
92 101
  {
93 102
    ParData p;
94 103
    p.bool_p=new bool(value);
95 104
    p.self_delete=true;
96 105
    p.help=help;
97 106
    p.type=BOOL;
98 107
    p.mandatory=obl;
99 108
    _opts[name]=p;
100 109
    return *this;
101 110
  }
102 111

	
103 112
  ArgParser &ArgParser::stringOption(const std::string &name,
104 113
                               const std::string &help,
105 114
                               std::string value, bool obl)
106 115
  {
107 116
    ParData p;
108 117
    p.string_p=new std::string(value);
109 118
    p.self_delete=true;
110 119
    p.help=help;
111 120
    p.type=STRING;
112 121
    p.mandatory=obl;
113 122
    _opts[name]=p;
114 123
    return *this;
115 124
  }
116 125

	
117 126
  ArgParser &ArgParser::refOption(const std::string &name,
118 127
                               const std::string &help,
119 128
                               int &ref, bool obl)
120 129
  {
121 130
    ParData p;
122 131
    p.int_p=&ref;
123 132
    p.self_delete=false;
124 133
    p.help=help;
125 134
    p.type=INTEGER;
126 135
    p.mandatory=obl;
127 136
    _opts[name]=p;
128 137
    return *this;
129 138
  }
130 139

	
131 140
  ArgParser &ArgParser::refOption(const std::string &name,
132 141
                                  const std::string &help,
133 142
                                  double &ref, bool obl)
134 143
  {
135 144
    ParData p;
136 145
    p.double_p=&ref;
137 146
    p.self_delete=false;
138 147
    p.help=help;
139 148
    p.type=DOUBLE;
140 149
    p.mandatory=obl;
141 150
    _opts[name]=p;
142 151
    return *this;
143 152
  }
144 153

	
145 154
  ArgParser &ArgParser::refOption(const std::string &name,
146 155
                                  const std::string &help,
147 156
                                  bool &ref, bool obl)
148 157
  {
149 158
    ParData p;
150 159
    p.bool_p=&ref;
151 160
    p.self_delete=false;
152 161
    p.help=help;
153 162
    p.type=BOOL;
154 163
    p.mandatory=obl;
155 164
    _opts[name]=p;
156 165

	
157 166
    ref = false;
158 167

	
159 168
    return *this;
160 169
  }
161 170

	
162 171
  ArgParser &ArgParser::refOption(const std::string &name,
163 172
                               const std::string &help,
164 173
                               std::string &ref, bool obl)
165 174
  {
166 175
    ParData p;
167 176
    p.string_p=&ref;
168 177
    p.self_delete=false;
169 178
    p.help=help;
170 179
    p.type=STRING;
171 180
    p.mandatory=obl;
172 181
    _opts[name]=p;
173 182
    return *this;
174 183
  }
175 184

	
176 185
  ArgParser &ArgParser::funcOption(const std::string &name,
177 186
                               const std::string &help,
178 187
                               void (*func)(void *),void *data)
179 188
  {
180 189
    ParData p;
181 190
    p.func_p.p=func;
182 191
    p.func_p.data=data;
183 192
    p.self_delete=false;
184 193
    p.help=help;
185 194
    p.type=FUNC;
186 195
    p.mandatory=false;
187 196
    _opts[name]=p;
188 197
    return *this;
189 198
  }
190 199

	
191 200
  ArgParser &ArgParser::optionGroup(const std::string &group,
192 201
                                    const std::string &opt)
193 202
  {
194 203
    Opts::iterator i = _opts.find(opt);
195 204
    LEMON_ASSERT(i!=_opts.end(), "Unknown option: '"+opt+"'");
196 205
    LEMON_ASSERT(!(i->second.ingroup),
197 206
                 "Option already in option group: '"+opt+"'");
198 207
    GroupData &g=_groups[group];
199 208
    g.opts.push_back(opt);
200 209
    i->second.ingroup=true;
201 210
    return *this;
202 211
  }
203 212

	
204 213
  ArgParser &ArgParser::onlyOneGroup(const std::string &group)
205 214
  {
206 215
    GroupData &g=_groups[group];
207 216
    g.only_one=true;
208 217
    return *this;
209 218
  }
210 219

	
211 220
  ArgParser &ArgParser::synonym(const std::string &syn,
212 221
                                const std::string &opt)
213 222
  {
214 223
    Opts::iterator o = _opts.find(opt);
215 224
    Opts::iterator s = _opts.find(syn);
216 225
    LEMON_ASSERT(o!=_opts.end(), "Unknown option: '"+opt+"'");
217 226
    LEMON_ASSERT(s==_opts.end(), "Option already used: '"+syn+"'");
218 227
    ParData p;
219 228
    p.help=opt;
220 229
    p.mandatory=false;
221 230
    p.syn=true;
222 231
    _opts[syn]=p;
223 232
    o->second.has_syn=true;
224 233
    return *this;
225 234
  }
226 235

	
227 236
  ArgParser &ArgParser::mandatoryGroup(const std::string &group)
228 237
  {
229 238
    GroupData &g=_groups[group];
230 239
    g.mandatory=true;
231 240
    return *this;
232 241
  }
233 242

	
234 243
  ArgParser &ArgParser::other(const std::string &name,
235 244
                              const std::string &help)
236 245
  {
237 246
    _others_help.push_back(OtherArg(name,help));
238 247
    return *this;
239 248
  }
240 249

	
241 250
  void ArgParser::show(std::ostream &os,Opts::const_iterator i) const
242 251
  {
243 252
    os << "-" << i->first;
244 253
    if(i->second.has_syn)
245 254
      for(Opts::const_iterator j=_opts.begin();j!=_opts.end();++j)
246 255
        if(j->second.syn&&j->second.help==i->first)
247 256
          os << "|-" << j->first;
248 257
    switch(i->second.type) {
249 258
    case STRING:
250 259
      os << " str";
251 260
      break;
252 261
    case INTEGER:
253 262
      os << " int";
254 263
      break;
255 264
    case DOUBLE:
256 265
      os << " num";
257 266
      break;
258 267
    default:
259 268
      break;
260 269
    }
261 270
  }
262 271

	
263 272
  void ArgParser::show(std::ostream &os,Groups::const_iterator i) const
264 273
  {
265 274
    GroupData::Opts::const_iterator o=i->second.opts.begin();
266 275
    while(o!=i->second.opts.end()) {
267 276
      show(os,_opts.find(*o));
268 277
      ++o;
269 278
      if(o!=i->second.opts.end()) os<<'|';
270 279
    }
271 280
  }
272 281

	
273 282
  void ArgParser::showHelp(Opts::const_iterator i) const
274 283
  {
275 284
    if(i->second.help.size()==0||i->second.syn) return;
276 285
    std::cerr << "  ";
277 286
    show(std::cerr,i);
278 287
    std::cerr << std::endl;
279 288
    std::cerr << "     " << i->second.help << std::endl;
280 289
  }
281 290
  void ArgParser::showHelp(std::vector<ArgParser::OtherArg>::const_iterator i)
282 291
    const
283 292
  {
284 293
    if(i->help.size()==0) return;
285 294
    std::cerr << "  " << i->name << std::endl
286 295
              << "     " << i->help << std::endl;
287 296
  }
288 297

	
289 298
  void ArgParser::shortHelp() const
290 299
  {
291 300
    const unsigned int LINE_LEN=77;
292 301
    const std::string indent("    ");
293 302
    std::cerr << "Usage:\n  " << _command_name;
294 303
    int pos=_command_name.size()+2;
295 304
    for(Groups::const_iterator g=_groups.begin();g!=_groups.end();++g) {
296 305
      std::ostringstream cstr;
297 306
      cstr << ' ';
298 307
      if(!g->second.mandatory) cstr << '[';
299 308
      show(cstr,g);
300 309
      if(!g->second.mandatory) cstr << ']';
301 310
      if(pos+cstr.str().size()>LINE_LEN) {
302 311
        std::cerr << std::endl << indent;
303 312
        pos=indent.size();
304 313
      }
305 314
      std::cerr << cstr.str();
306 315
      pos+=cstr.str().size();
307 316
    }
308 317
    for(Opts::const_iterator i=_opts.begin();i!=_opts.end();++i)
309 318
      if(!i->second.ingroup&&!i->second.syn) {
310 319
        std::ostringstream cstr;
311 320
        cstr << ' ';
312 321
        if(!i->second.mandatory) cstr << '[';
313 322
        show(cstr,i);
314 323
        if(!i->second.mandatory) cstr << ']';
315 324
        if(pos+cstr.str().size()>LINE_LEN) {
316 325
          std::cerr << std::endl << indent;
317 326
          pos=indent.size();
318 327
        }
319 328
        std::cerr << cstr.str();
320 329
        pos+=cstr.str().size();
321 330
      }
322 331
    for(std::vector<OtherArg>::const_iterator i=_others_help.begin();
323 332
        i!=_others_help.end();++i)
324 333
      {
325 334
        std::ostringstream cstr;
326 335
        cstr << ' ' << i->name;
327 336

	
328 337
        if(pos+cstr.str().size()>LINE_LEN) {
329 338
          std::cerr << std::endl << indent;
330 339
          pos=indent.size();
331 340
        }
332 341
        std::cerr << cstr.str();
333 342
        pos+=cstr.str().size();
334 343
      }
335 344
    std::cerr << std::endl;
336 345
  }
337 346

	
338 347
  void ArgParser::showHelp() const
339 348
  {
340 349
    shortHelp();
341 350
    std::cerr << "Where:\n";
342 351
    for(std::vector<OtherArg>::const_iterator i=_others_help.begin();
343 352
        i!=_others_help.end();++i) showHelp(i);
344 353
    for(Opts::const_iterator i=_opts.begin();i!=_opts.end();++i) showHelp(i);
345
    exit(1);
354
    _terminate(ArgParserException::HELP);
346 355
  }
347 356

	
348 357

	
349 358
  void ArgParser::unknownOpt(std::string arg) const
350 359
  {
351 360
    std::cerr << "\nUnknown option: " << arg << "\n";
352 361
    std::cerr << "\nType '" << _command_name <<
353 362
      " --help' to obtain a short summary on the usage.\n\n";
354
    exit(1);
363
    _terminate(ArgParserException::UNKNOWN_OPT);
355 364
  }
356 365

	
357 366
  void ArgParser::requiresValue(std::string arg, OptType t) const
358 367
  {
359 368
    std::cerr << "Argument '" << arg << "' requires a";
360 369
    switch(t) {
361 370
    case STRING:
362 371
      std::cerr << " string";
363 372
      break;
364 373
    case INTEGER:
365 374
      std::cerr << "n integer";
366 375
      break;
367 376
    case DOUBLE:
368 377
      std::cerr << " floating point";
369 378
      break;
370 379
    default:
371 380
      break;
372 381
    }
373 382
    std::cerr << " value\n\n";
374 383
    showHelp();
375 384
  }
376 385

	
377 386

	
378 387
  void ArgParser::checkMandatories() const
379 388
  {
380 389
    bool ok=true;
381 390
    for(Opts::const_iterator i=_opts.begin();i!=_opts.end();++i)
382 391
      if(i->second.mandatory&&!i->second.set)
383 392
        {
384 393
          if(ok)
385 394
            std::cerr << _command_name
386 395
                      << ": The following mandatory arguments are missing.\n";
387 396
          ok=false;
388 397
          showHelp(i);
389 398
        }
390 399
    for(Groups::const_iterator i=_groups.begin();i!=_groups.end();++i)
391 400
      if(i->second.mandatory||i->second.only_one)
392 401
        {
393 402
          int set=0;
394 403
          for(GroupData::Opts::const_iterator o=i->second.opts.begin();
395 404
              o!=i->second.opts.end();++o)
396 405
            if(_opts.find(*o)->second.set) ++set;
397 406
          if(i->second.mandatory&&!set) {
398 407
            std::cerr << _command_name <<
399 408
              ": At least one of the following arguments is mandatory.\n";
400 409
            ok=false;
401 410
            for(GroupData::Opts::const_iterator o=i->second.opts.begin();
402 411
                o!=i->second.opts.end();++o)
403 412
              showHelp(_opts.find(*o));
404 413
          }
405 414
          if(i->second.only_one&&set>1) {
406 415
            std::cerr << _command_name <<
407 416
              ": At most one of the following arguments can be given.\n";
408 417
            ok=false;
409 418
            for(GroupData::Opts::const_iterator o=i->second.opts.begin();
410 419
                o!=i->second.opts.end();++o)
411 420
              showHelp(_opts.find(*o));
412 421
          }
413 422
        }
414 423
    if(!ok) {
415 424
      std::cerr << "\nType '" << _command_name <<
416 425
        " --help' to obtain a short summary on the usage.\n\n";
417
      exit(1);
426
      _terminate(ArgParserException::INVALID_OPT);
418 427
    }
419 428
  }
420 429

	
421 430
  ArgParser &ArgParser::parse()
422 431
  {
423 432
    for(int ar=1; ar<_argc; ++ar) {
424 433
      std::string arg(_argv[ar]);
425 434
      if (arg[0] != '-' || arg.size() == 1) {
426 435
        _file_args.push_back(arg);
427 436
      }
428 437
      else {
429 438
        Opts::iterator i = _opts.find(arg.substr(1));
430 439
        if(i==_opts.end()) unknownOpt(arg);
431 440
        else {
432 441
          if(i->second.syn) i=_opts.find(i->second.help);
433 442
          ParData &p(i->second);
434 443
          if (p.type==BOOL) *p.bool_p=true;
435 444
          else if (p.type==FUNC) p.func_p.p(p.func_p.data);
436 445
          else if(++ar==_argc) requiresValue(arg, p.type);
437 446
          else {
438 447
            std::string val(_argv[ar]);
439 448
            std::istringstream vals(val);
440 449
            switch(p.type) {
441 450
            case STRING:
442 451
              *p.string_p=val;
443 452
              break;
444 453
            case INTEGER:
445 454
              vals >> *p.int_p;
446 455
              break;
447 456
            case DOUBLE:
448 457
              vals >> *p.double_p;
449 458
              break;
450 459
            default:
451 460
              break;
452 461
            }
453 462
            if(p.type!=STRING&&(!vals||!vals.eof()))
454 463
              requiresValue(arg, p.type);
455 464
          }
456 465
          p.set = true;
457 466
        }
458 467
      }
459 468
    }
460 469
    checkMandatories();
461 470

	
462 471
    return *this;
463 472
  }
464 473

	
465 474
}
Ignore white space 6 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-2010
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_ARG_PARSER_H
20 20
#define LEMON_ARG_PARSER_H
21 21

	
22 22
#include <vector>
23 23
#include <map>
24 24
#include <list>
25 25
#include <string>
26 26
#include <iostream>
27 27
#include <sstream>
28 28
#include <algorithm>
29 29
#include <lemon/assert.h>
30 30

	
31 31
///\ingroup misc
32 32
///\file
33 33
///\brief A tool to parse command line arguments.
34 34

	
35 35
namespace lemon {
36 36

	
37
  ///Exception used by ArgParser
38
  class ArgParserException : public Exception {
39
  public:
40
    enum Reason {
41
      HELP,         /// <tt>--help</tt> option was given
42
      UNKNOWN_OPT,  /// Unknown option was given
43
      INVALID_OPT   /// Invalid combination of options
44
    };
45

	
46
  private:
47
    Reason _reason;
48

	
49
  public:
50
    ///Constructor
51
    ArgParserException(Reason r) throw() : _reason(r) {}
52
    ///Virtual destructor
53
    virtual ~ArgParserException() throw() {}
54
    ///A short description of the exception
55
    virtual const char* what() const throw() {
56
      switch(_reason)
57
        {
58
        case HELP:
59
          return "lemon::ArgParseException: ask for help";
60
          break;
61
        case UNKNOWN_OPT:
62
          return "lemon::ArgParseException: unknown option";
63
          break;
64
        case INVALID_OPT:
65
          return "lemon::ArgParseException: invalid combination of options";
66
          break;
67
        }
68
      return "";
69
    }
70
    ///Return the reason for the failure
71
    Reason reason() const {return _reason; }
72
  };
73

	
74

	
37 75
  ///Command line arguments parser
38 76

	
39 77
  ///\ingroup misc
40 78
  ///Command line arguments parser.
41 79
  ///
42 80
  ///For a complete example see the \ref arg_parser_demo.cc demo file.
43 81
  class ArgParser {
44 82

	
45 83
    static void _showHelp(void *p);
46 84
  protected:
47 85

	
48 86
    int _argc;
49 87
    const char * const *_argv;
50 88

	
51 89
    enum OptType { UNKNOWN=0, BOOL=1, STRING=2, DOUBLE=3, INTEGER=4, FUNC=5 };
52 90

	
53 91
    class ParData {
54 92
    public:
55 93
      union {
56 94
        bool *bool_p;
57 95
        int *int_p;
58 96
        double *double_p;
59 97
        std::string *string_p;
60 98
        struct {
61 99
          void (*p)(void *);
62 100
          void *data;
63 101
        } func_p;
64 102

	
65 103
      };
66 104
      std::string help;
67 105
      bool mandatory;
68 106
      OptType type;
69 107
      bool set;
70 108
      bool ingroup;
71 109
      bool has_syn;
72 110
      bool syn;
73 111
      bool self_delete;
74 112
      ParData() : mandatory(false), type(UNKNOWN), set(false), ingroup(false),
75 113
                  has_syn(false), syn(false), self_delete(false) {}
76 114
    };
77 115

	
78 116
    typedef std::map<std::string,ParData> Opts;
79 117
    Opts _opts;
80 118

	
81 119
    class GroupData
82 120
    {
83 121
    public:
84 122
      typedef std::list<std::string> Opts;
85 123
      Opts opts;
86 124
      bool only_one;
87 125
      bool mandatory;
88 126
      GroupData() :only_one(false), mandatory(false) {}
89 127
    };
90 128

	
91 129
    typedef std::map<std::string,GroupData> Groups;
92 130
    Groups _groups;
93 131

	
94 132
    struct OtherArg
95 133
    {
96 134
      std::string name;
97 135
      std::string help;
98 136
      OtherArg(std::string n, std::string h) :name(n), help(h) {}
99 137

	
100 138
    };
101 139

	
102 140
    std::vector<OtherArg> _others_help;
103 141
    std::vector<std::string> _file_args;
104 142
    std::string _command_name;
105 143

	
106 144

	
107 145
  private:
108 146
    //Bind a function to an option.
109 147

	
110 148
    //\param name The name of the option. The leading '-' must be omitted.
111 149
    //\param help A help string.
112 150
    //\retval func The function to be called when the option is given. It
113 151
    //  must be of type "void f(void *)"
114 152
    //\param data Data to be passed to \c func
115 153
    ArgParser &funcOption(const std::string &name,
116 154
                    const std::string &help,
117 155
                    void (*func)(void *),void *data);
118 156

	
157
    bool _exit_on_problems;
158

	
159
    void _terminate(ArgParserException::Reason reason) const;
160

	
119 161
  public:
120 162

	
121 163
    ///Constructor
122 164
    ArgParser(int argc, const char * const *argv);
123 165

	
124 166
    ~ArgParser();
125 167

	
126 168
    ///\name Options
127 169
    ///
128 170

	
129 171
    ///@{
130 172

	
131 173
    ///Add a new integer type option
132 174

	
133 175
    ///Add a new integer type option.
134 176
    ///\param name The name of the option. The leading '-' must be omitted.
135 177
    ///\param help A help string.
136 178
    ///\param value A default value for the option.
137 179
    ///\param obl Indicate if the option is mandatory.
138 180
    ArgParser &intOption(const std::string &name,
139 181
                    const std::string &help,
140 182
                    int value=0, bool obl=false);
141 183

	
142 184
    ///Add a new floating point type option
143 185

	
144 186
    ///Add a new floating point type option.
145 187
    ///\param name The name of the option. The leading '-' must be omitted.
146 188
    ///\param help A help string.
147 189
    ///\param value A default value for the option.
148 190
    ///\param obl Indicate if the option is mandatory.
149 191
    ArgParser &doubleOption(const std::string &name,
150 192
                      const std::string &help,
151 193
                      double value=0, bool obl=false);
152 194

	
153 195
    ///Add a new bool type option
154 196

	
155 197
    ///Add a new bool type option.
156 198
    ///\param name The name of the option. The leading '-' must be omitted.
157 199
    ///\param help A help string.
158 200
    ///\param value A default value for the option.
159 201
    ///\param obl Indicate if the option is mandatory.
160 202
    ///\note A mandatory bool obtion is of very little use.
161 203
    ArgParser &boolOption(const std::string &name,
162 204
                      const std::string &help,
163 205
                      bool value=false, bool obl=false);
164 206

	
165 207
    ///Add a new string type option
166 208

	
167 209
    ///Add a new string type option.
168 210
    ///\param name The name of the option. The leading '-' must be omitted.
169 211
    ///\param help A help string.
170 212
    ///\param value A default value for the option.
171 213
    ///\param obl Indicate if the option is mandatory.
172 214
    ArgParser &stringOption(const std::string &name,
173 215
                      const std::string &help,
174 216
                      std::string value="", bool obl=false);
175 217

	
176 218
    ///Give help string for non-parsed arguments.
177 219

	
178 220
    ///With this function you can give help string for non-parsed arguments.
179 221
    ///The parameter \c name will be printed in the short usage line, while
180 222
    ///\c help gives a more detailed description.
181 223
    ArgParser &other(const std::string &name,
182 224
                     const std::string &help="");
183 225

	
184 226
    ///@}
185 227

	
186 228
    ///\name Options with External Storage
187 229
    ///Using this functions, the value of the option will be directly written
188 230
    ///into a variable once the option appears in the command line.
189 231

	
190 232
    ///@{
191 233

	
192 234
    ///Add a new integer type option with a storage reference
193 235

	
194 236
    ///Add a new integer type option with a storage reference.
195 237
    ///\param name The name of the option. The leading '-' must be omitted.
196 238
    ///\param help A help string.
197 239
    ///\param obl Indicate if the option is mandatory.
198 240
    ///\retval ref The value of the argument will be written to this variable.
199 241
    ArgParser &refOption(const std::string &name,
200 242
                    const std::string &help,
201 243
                    int &ref, bool obl=false);
202 244

	
203 245
    ///Add a new floating type option with a storage reference
204 246

	
205 247
    ///Add a new floating type option with a storage reference.
206 248
    ///\param name The name of the option. The leading '-' must be omitted.
207 249
    ///\param help A help string.
208 250
    ///\param obl Indicate if the option is mandatory.
209 251
    ///\retval ref The value of the argument will be written to this variable.
210 252
    ArgParser &refOption(const std::string &name,
211 253
                      const std::string &help,
212 254
                      double &ref, bool obl=false);
213 255

	
214 256
    ///Add a new bool type option with a storage reference
215 257

	
216 258
    ///Add a new bool type option with a storage reference.
217 259
    ///\param name The name of the option. The leading '-' must be omitted.
218 260
    ///\param help A help string.
219 261
    ///\param obl Indicate if the option is mandatory.
220 262
    ///\retval ref The value of the argument will be written to this variable.
221 263
    ///\note A mandatory bool obtion is of very little use.
222 264
    ArgParser &refOption(const std::string &name,
223 265
                      const std::string &help,
224 266
                      bool &ref, bool obl=false);
225 267

	
226 268
    ///Add a new string type option with a storage reference
227 269

	
228 270
    ///Add a new string type option with a storage reference.
229 271
    ///\param name The name of the option. The leading '-' must be omitted.
230 272
    ///\param help A help string.
231 273
    ///\param obl Indicate if the option is mandatory.
232 274
    ///\retval ref The value of the argument will be written to this variable.
233 275
    ArgParser &refOption(const std::string &name,
234 276
                      const std::string &help,
235 277
                      std::string &ref, bool obl=false);
236 278

	
237 279
    ///@}
238 280

	
239 281
    ///\name Option Groups and Synonyms
240 282
    ///
241 283

	
242 284
    ///@{
243 285

	
244 286
    ///Bundle some options into a group
245 287

	
246 288
    /// You can group some option by calling this function repeatedly for each
247 289
    /// option to be grouped with the same groupname.
248 290
    ///\param group The group name.
249 291
    ///\param opt The option name.
250 292
    ArgParser &optionGroup(const std::string &group,
251 293
                           const std::string &opt);
252 294

	
253 295
    ///Make the members of a group exclusive
254 296

	
255 297
    ///If you call this function for a group, than at most one of them can be
256 298
    ///given at the same time.
257 299
    ArgParser &onlyOneGroup(const std::string &group);
258 300

	
259 301
    ///Make a group mandatory
260 302

	
261 303
    ///Using this function, at least one of the members of \c group
262 304
    ///must be given.
263 305
    ArgParser &mandatoryGroup(const std::string &group);
264 306

	
265 307
    ///Create synonym to an option
266 308

	
267 309
    ///With this function you can create a synonym \c syn of the
268 310
    ///option \c opt.
269 311
    ArgParser &synonym(const std::string &syn,
270 312
                           const std::string &opt);
271 313

	
272 314
    ///@}
273 315

	
274 316
  private:
275 317
    void show(std::ostream &os,Opts::const_iterator i) const;
276 318
    void show(std::ostream &os,Groups::const_iterator i) const;
277 319
    void showHelp(Opts::const_iterator i) const;
278 320
    void showHelp(std::vector<OtherArg>::const_iterator i) const;
279 321

	
280 322
    void unknownOpt(std::string arg) const;
281 323

	
282 324
    void requiresValue(std::string arg, OptType t) const;
283 325
    void checkMandatories() const;
284 326

	
285 327
    void shortHelp() const;
286 328
    void showHelp() const;
287 329
  public:
288 330

	
289 331
    ///Start the parsing process
290 332
    ArgParser &parse();
291 333

	
292 334
    /// Synonym for parse()
293 335
    ArgParser &run()
294 336
    {
295 337
      return parse();
296 338
    }
297 339

	
298 340
    ///Give back the command name (the 0th argument)
299 341
    const std::string &commandName() const { return _command_name; }
300 342

	
301 343
    ///Check if an opion has been given to the command.
302 344
    bool given(std::string op) const
303 345
    {
304 346
      Opts::const_iterator i = _opts.find(op);
305 347
      return i!=_opts.end()?i->second.set:false;
306 348
    }
307 349

	
308 350

	
309 351
    ///Magic type for operator[]
310 352

	
311 353
    ///This is the type of the return value of ArgParser::operator[]().
312 354
    ///It automatically converts to \c int, \c double, \c bool or
313 355
    ///\c std::string if the type of the option matches, which is checked
314 356
    ///with an \ref LEMON_ASSERT "assertion" (i.e. it performs runtime
315 357
    ///type checking).
316 358
    class RefType
317 359
    {
318 360
      const ArgParser &_parser;
319 361
      std::string _name;
320 362
    public:
321 363
      ///\e
322 364
      RefType(const ArgParser &p,const std::string &n) :_parser(p),_name(n) {}
323 365
      ///\e
324 366
      operator bool()
325 367
      {
326 368
        Opts::const_iterator i = _parser._opts.find(_name);
327 369
        LEMON_ASSERT(i!=_parser._opts.end(),
328 370
                     std::string()+"Unkown option: '"+_name+"'");
329 371
        LEMON_ASSERT(i->second.type==ArgParser::BOOL,
330 372
                     std::string()+"'"+_name+"' is a bool option");
331 373
        return *(i->second.bool_p);
332 374
      }
333 375
      ///\e
334 376
      operator std::string()
335 377
      {
336 378
        Opts::const_iterator i = _parser._opts.find(_name);
337 379
        LEMON_ASSERT(i!=_parser._opts.end(),
338 380
                     std::string()+"Unkown option: '"+_name+"'");
339 381
        LEMON_ASSERT(i->second.type==ArgParser::STRING,
340 382
                     std::string()+"'"+_name+"' is a string option");
341 383
        return *(i->second.string_p);
342 384
      }
343 385
      ///\e
344 386
      operator double()
345 387
      {
346 388
        Opts::const_iterator i = _parser._opts.find(_name);
347 389
        LEMON_ASSERT(i!=_parser._opts.end(),
348 390
                     std::string()+"Unkown option: '"+_name+"'");
349 391
        LEMON_ASSERT(i->second.type==ArgParser::DOUBLE ||
350 392
                     i->second.type==ArgParser::INTEGER,
351 393
                     std::string()+"'"+_name+"' is a floating point option");
352 394
        return i->second.type==ArgParser::DOUBLE ?
353 395
          *(i->second.double_p) : *(i->second.int_p);
354 396
      }
355 397
      ///\e
356 398
      operator int()
357 399
      {
358 400
        Opts::const_iterator i = _parser._opts.find(_name);
359 401
        LEMON_ASSERT(i!=_parser._opts.end(),
360 402
                     std::string()+"Unkown option: '"+_name+"'");
361 403
        LEMON_ASSERT(i->second.type==ArgParser::INTEGER,
362 404
                     std::string()+"'"+_name+"' is an integer option");
363 405
        return *(i->second.int_p);
364 406
      }
365 407

	
366 408
    };
367 409

	
368 410
    ///Give back the value of an option
369 411

	
370 412
    ///Give back the value of an option.
371 413
    ///\sa RefType
372 414
    RefType operator[](const std::string &n) const
373 415
    {
374 416
      return RefType(*this, n);
375 417
    }
376 418

	
377 419
    ///Give back the non-option type arguments.
378 420

	
379 421
    ///Give back a reference to a vector consisting of the program arguments
380 422
    ///not starting with a '-' character.
381 423
    const std::vector<std::string> &files() const { return _file_args; }
382 424

	
425
    ///Throw instead of exit in case of problems
426
    void throwOnProblems()
427
    {
428
      _exit_on_problems=false;
429
    }
383 430
  };
384 431
}
385 432

	
386 433
#endif // LEMON_ARG_PARSER_H

Changeset was too big and was cut off... Show full diff

0 comments (0 inline)