1.1 --- a/demo/arg_parser_demo.cc Sun Jul 13 16:46:56 2008 +0100
1.2 +++ b/demo/arg_parser_demo.cc Sun Jul 13 19:51:02 2008 +0100
1.3 @@ -1,6 +1,6 @@
1.4 -/* -*- C++ -*-
1.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
1.6 *
1.7 - * This file is a part of LEMON, a generic C++ optimization library
1.8 + * This file is a part of LEMON, a generic C++ optimization library.
1.9 *
1.10 * Copyright (C) 2003-2008
1.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
1.12 @@ -64,7 +64,7 @@
1.13 // Add non-parsed arguments (e.g. input files)
1.14 ap.other("infile", "The input file.")
1.15 .other("...");
1.16 -
1.17 +
1.18 // Perform the parsing process
1.19 // (in case of any error it terminates the program)
1.20 ap.parse();
1.21 @@ -84,7 +84,7 @@
1.22 if(ap.given("gra")) std::cout << " -gra is given\n";
1.23 if(ap.given("grb")) std::cout << " -grb is given\n";
1.24 if(ap.given("grc")) std::cout << " -grc is given\n";
1.25 -
1.26 +
1.27 switch(ap.files().size()) {
1.28 case 0:
1.29 std::cout << " No file argument was given.\n";
1.30 @@ -94,10 +94,10 @@
1.31 break;
1.32 default:
1.33 std::cout << " "
1.34 - << ap.files().size() << " file arguments were given. They are:\n";
1.35 + << ap.files().size() << " file arguments were given. They are:\n";
1.36 }
1.37 for(unsigned int i=0;i<ap.files().size();++i)
1.38 std::cout << " '" << ap.files()[i] << "'\n";
1.39 -
1.40 +
1.41 return 0;
1.42 }
2.1 --- a/demo/graph_to_eps_demo.cc Sun Jul 13 16:46:56 2008 +0100
2.2 +++ b/demo/graph_to_eps_demo.cc Sun Jul 13 19:51:02 2008 +0100
2.3 @@ -1,6 +1,6 @@
2.4 -/* -*- C++ -*-
2.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
2.6 *
2.7 - * This file is a part of LEMON, a generic C++ optimization library
2.8 + * This file is a part of LEMON, a generic C++ optimization library.
2.9 *
2.10 * Copyright (C) 2003-2008
2.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
2.12 @@ -49,7 +49,7 @@
2.13 typedef ListDigraph::NodeIt NodeIt;
2.14 typedef ListDigraph::Arc Arc;
2.15 typedef dim2::Point<int> Point;
2.16 -
2.17 +
2.18 Node n1=g.addNode();
2.19 Node n2=g.addNode();
2.20 Node n3=g.addNode();
2.21 @@ -62,13 +62,13 @@
2.22 ListDigraph::NodeMap<int> shapes(g);
2.23 ListDigraph::ArcMap<int> acolors(g);
2.24 ListDigraph::ArcMap<int> widths(g);
2.25 -
2.26 +
2.27 coords[n1]=Point(50,50); sizes[n1]=1; colors[n1]=1; shapes[n1]=0;
2.28 coords[n2]=Point(50,70); sizes[n2]=2; colors[n2]=2; shapes[n2]=2;
2.29 coords[n3]=Point(70,70); sizes[n3]=1; colors[n3]=3; shapes[n3]=0;
2.30 coords[n4]=Point(70,50); sizes[n4]=2; colors[n4]=4; shapes[n4]=1;
2.31 coords[n5]=Point(85,60); sizes[n5]=3; colors[n5]=5; shapes[n5]=2;
2.32 -
2.33 +
2.34 Arc a;
2.35
2.36 a=g.addArc(n1,n2); acolors[a]=0; widths[a]=1;
2.37 @@ -78,7 +78,7 @@
2.38 a=g.addArc(n4,n1); acolors[a]=0; widths[a]=1;
2.39 a=g.addArc(n2,n4); acolors[a]=1; widths[a]=2;
2.40 a=g.addArc(n3,n4); acolors[a]=2; widths[a]=1;
2.41 -
2.42 +
2.43 IdMap<ListDigraph,Node> id(g);
2.44
2.45 // Create five .eps files showing the digraph with different options
2.46 @@ -182,14 +182,14 @@
2.47 ListDigraph h;
2.48 ListDigraph::NodeMap<int> hcolors(h);
2.49 ListDigraph::NodeMap<Point> hcoords(h);
2.50 -
2.51 +
2.52 int cols=int(sqrt(double(palette.size())));
2.53 for(int i=0;i<int(paletteW.size());i++) {
2.54 Node n=h.addNode();
2.55 hcoords[n]=Point(1+i%cols,1+i/cols);
2.56 hcolors[n]=i;
2.57 }
2.58 -
2.59 +
2.60 cout << "Create 'graph_to_eps_demo_out_6_colors.eps'" << endl;
2.61 graphToEps(h,"graph_to_eps_demo_out_6_colors.eps").
2.62 scale(60).
2.63 @@ -202,6 +202,6 @@
2.64 nodeTexts(hcolors).nodeTextSize(.6).
2.65 nodeColors(composeMap(paletteW,hcolors)).
2.66 run();
2.67 -
2.68 +
2.69 return 0;
2.70 }
3.1 --- a/demo/lgf_demo.cc Sun Jul 13 16:46:56 2008 +0100
3.2 +++ b/demo/lgf_demo.cc Sun Jul 13 19:51:02 2008 +0100
3.3 @@ -1,6 +1,6 @@
3.4 -/* -*- C++ -*-
3.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
3.6 *
3.7 - * This file is a part of LEMON, a generic C++ optimization library
3.8 + * This file is a part of LEMON, a generic C++ optimization library.
3.9 *
3.10 * Copyright (C) 2003-2008
3.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
3.12 @@ -21,7 +21,7 @@
3.13 ///\brief Demonstrating graph input and output
3.14 ///
3.15 /// This program gives an example of how to read and write a digraph
3.16 -/// and additional maps from/to a stream or a file using the
3.17 +/// and additional maps from/to a stream or a file using the
3.18 /// \ref lgf-format "LGF" format.
3.19 ///
3.20 /// The \c "digraph.lgf" file:
3.21 @@ -42,7 +42,7 @@
3.22 SmartDigraph g;
3.23 SmartDigraph::ArcMap<int> cap(g);
3.24 SmartDigraph::Node s, t;
3.25 -
3.26 +
3.27 try {
3.28 digraphReader("digraph.lgf", g). // read the directed graph into g
3.29 arcMap("capacity", cap). // read the 'capacity' arc map into cap
4.1 --- a/doc/coding_style.dox Sun Jul 13 16:46:56 2008 +0100
4.2 +++ b/doc/coding_style.dox Sun Jul 13 19:51:02 2008 +0100
4.3 @@ -1,6 +1,6 @@
4.4 -/* -*- C++ -*-
4.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
4.6 *
4.7 - * This file is a part of LEMON, a generic C++ optimization library
4.8 + * This file is a part of LEMON, a generic C++ optimization library.
4.9 *
4.10 * Copyright (C) 2003-2008
4.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
4.12 @@ -18,7 +18,7 @@
4.13
4.14 /*!
4.15
4.16 -\page coding_style LEMON Coding Style
4.17 +\page coding_style LEMON Coding Style
4.18
4.19 \section naming_conv Naming Conventions
4.20
4.21 @@ -68,7 +68,7 @@
4.22 The name of a class or any type should look like the following.
4.23
4.24 \code
4.25 -AllWordsCapitalizedWithoutUnderscores
4.26 +AllWordsCapitalizedWithoutUnderscores
4.27 \endcode
4.28
4.29 \subsection cs-func Methods and other functions
4.30 @@ -76,7 +76,7 @@
4.31 The name of a function should look like the following.
4.32
4.33 \code
4.34 -firstWordLowerCaseRestCapitalizedWithoutUnderscores
4.35 +firstWordLowerCaseRestCapitalizedWithoutUnderscores
4.36 \endcode
4.37
4.38 \subsection cs-funcs Constants, Macros
4.39 @@ -84,15 +84,15 @@
4.40 The names of constants and macros should look like the following.
4.41
4.42 \code
4.43 -ALL_UPPER_CASE_WITH_UNDERSCORES
4.44 +ALL_UPPER_CASE_WITH_UNDERSCORES
4.45 \endcode
4.46
4.47 -\subsection cs-loc-var Class and instance member variables, auto variables
4.48 +\subsection cs-loc-var Class and instance member variables, auto variables
4.49
4.50 The names of class and instance member variables and auto variables (=variables used locally in methods) should look like the following.
4.51
4.52 \code
4.53 -all_lower_case_with_underscores
4.54 +all_lower_case_with_underscores
4.55 \endcode
4.56
4.57 \subsection pri-loc-var Private member variables
5.1 --- a/doc/dirs.dox Sun Jul 13 16:46:56 2008 +0100
5.2 +++ b/doc/dirs.dox Sun Jul 13 19:51:02 2008 +0100
5.3 @@ -1,6 +1,6 @@
5.4 -/* -*- C++ -*-
5.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
5.6 *
5.7 - * This file is a part of LEMON, a generic C++ optimization library
5.8 + * This file is a part of LEMON, a generic C++ optimization library.
5.9 *
5.10 * Copyright (C) 2003-2008
5.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
5.12 @@ -74,6 +74,6 @@
5.13 \brief Implementation helper files
5.14
5.15 This directory contains some helper classes to implement graphs, maps and
5.16 -some other classes. As a user you typically don't have to deal with these
5.17 +some other classes. As a user you typically don't have to deal with these
5.18 files.
5.19 */
6.1 --- a/doc/groups.dox Sun Jul 13 16:46:56 2008 +0100
6.2 +++ b/doc/groups.dox Sun Jul 13 19:51:02 2008 +0100
6.3 @@ -1,6 +1,6 @@
6.4 -/* -*- C++ -*-
6.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
6.6 *
6.7 - * This file is a part of LEMON, a generic C++ optimization library
6.8 + * This file is a part of LEMON, a generic C++ optimization library.
6.9 *
6.10 * Copyright (C) 2003-2008
6.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
6.12 @@ -26,10 +26,10 @@
6.13 @ingroup datas
6.14 \brief Graph structures implemented in LEMON.
6.15
6.16 -The implementation of combinatorial algorithms heavily relies on
6.17 -efficient graph implementations. LEMON offers data structures which are
6.18 -planned to be easily used in an experimental phase of implementation studies,
6.19 -and thereafter the program code can be made efficient by small modifications.
6.20 +The implementation of combinatorial algorithms heavily relies on
6.21 +efficient graph implementations. LEMON offers data structures which are
6.22 +planned to be easily used in an experimental phase of implementation studies,
6.23 +and thereafter the program code can be made efficient by small modifications.
6.24
6.25 The most efficient implementation of diverse applications require the
6.26 usage of different physical graph implementations. These differences
6.27 @@ -40,21 +40,21 @@
6.28 running time or on memory usage, some structures may fail to provide
6.29 some graph features like arc/edge or node deletion.
6.30
6.31 -Alteration of standard containers need a very limited number of
6.32 -operations, these together satisfy the everyday requirements.
6.33 -In the case of graph structures, different operations are needed which do
6.34 -not alter the physical graph, but gives another view. If some nodes or
6.35 +Alteration of standard containers need a very limited number of
6.36 +operations, these together satisfy the everyday requirements.
6.37 +In the case of graph structures, different operations are needed which do
6.38 +not alter the physical graph, but gives another view. If some nodes or
6.39 arcs have to be hidden or the reverse oriented graph have to be used, then
6.40 -this is the case. It also may happen that in a flow implementation
6.41 -the residual graph can be accessed by another algorithm, or a node-set
6.42 -is to be shrunk for another algorithm.
6.43 -LEMON also provides a variety of graphs for these requirements called
6.44 -\ref graph_adaptors "graph adaptors". Adaptors cannot be used alone but only
6.45 -in conjunction with other graph representations.
6.46 +this is the case. It also may happen that in a flow implementation
6.47 +the residual graph can be accessed by another algorithm, or a node-set
6.48 +is to be shrunk for another algorithm.
6.49 +LEMON also provides a variety of graphs for these requirements called
6.50 +\ref graph_adaptors "graph adaptors". Adaptors cannot be used alone but only
6.51 +in conjunction with other graph representations.
6.52
6.53 You are free to use the graph structure that fit your requirements
6.54 the best, most graph algorithms and auxiliary data structures can be used
6.55 -with any graph structures.
6.56 +with any graph structures.
6.57 */
6.58
6.59 /**
6.60 @@ -63,12 +63,12 @@
6.61 \brief Graph types between real graphs and graph adaptors.
6.62
6.63 This group describes some graph types between real graphs and graph adaptors.
6.64 -These classes wrap graphs to give new functionality as the adaptors do it.
6.65 +These classes wrap graphs to give new functionality as the adaptors do it.
6.66 On the other hand they are not light-weight structures as the adaptors.
6.67 */
6.68
6.69 /**
6.70 -@defgroup maps Maps
6.71 +@defgroup maps Maps
6.72 @ingroup datas
6.73 \brief Map structures implemented in LEMON.
6.74
6.75 @@ -79,7 +79,7 @@
6.76 */
6.77
6.78 /**
6.79 -@defgroup graph_maps Graph Maps
6.80 +@defgroup graph_maps Graph Maps
6.81 @ingroup maps
6.82 \brief Special graph-related maps.
6.83
6.84 @@ -115,14 +115,14 @@
6.85 return Color(0.0, 0.0, 0.0);
6.86 }
6.87 }
6.88 -
6.89 +
6.90 Digraph::NodeMap<int> degree_map(graph);
6.91 -
6.92 +
6.93 digraphToEps(graph, "graph.eps")
6.94 .coords(coords).scaleToA4().undirected()
6.95 .nodeColors(composeMap(functorToMap(nodeColor), degree_map))
6.96 .run();
6.97 -\endcode
6.98 +\endcode
6.99 The \c functorToMap() function makes an \c int to \c Color map from the
6.100 \e nodeColor() function. The \c composeMap() compose the \e degree_map
6.101 and the previously created map. The composed map is a proper function to
6.102 @@ -140,7 +140,7 @@
6.103
6.104 typedef DivMap<DoubleArcMap, DoubleArcMap> TimeMap;
6.105 TimeMap time(length, speed);
6.106 -
6.107 +
6.108 Dijkstra<Digraph, TimeMap> dijkstra(graph, time);
6.109 dijkstra.run(source, target);
6.110 \endcode
6.111 @@ -152,7 +152,7 @@
6.112 */
6.113
6.114 /**
6.115 -@defgroup matrices Matrices
6.116 +@defgroup matrices Matrices
6.117 @ingroup datas
6.118 \brief Two dimensional data storages implemented in LEMON.
6.119
6.120 @@ -200,7 +200,7 @@
6.121 @ingroup algs
6.122 \brief Common graph search algorithms.
6.123
6.124 -This group describes the common graph search algorithms like
6.125 +This group describes the common graph search algorithms like
6.126 Breadth-first search (Bfs) and Depth-first search (Dfs).
6.127 */
6.128
6.129 @@ -212,9 +212,9 @@
6.130 This group describes the algorithms for finding shortest paths in graphs.
6.131 */
6.132
6.133 -/**
6.134 -@defgroup max_flow Maximum Flow algorithms
6.135 -@ingroup algs
6.136 +/**
6.137 +@defgroup max_flow Maximum Flow algorithms
6.138 +@ingroup algs
6.139 \brief Algorithms for finding maximum flows.
6.140
6.141 This group describes the algorithms for finding maximum flows and
6.142 @@ -231,7 +231,7 @@
6.143 \f[ \max \sum_{v\in\delta^{+}(s)}f_{uv} - \sum_{v\in\delta^{-}(s)}f_{vu}\f]
6.144
6.145 LEMON contains several algorithms for solving maximum flow problems:
6.146 -- \ref lemon::EdmondsKarp "Edmonds-Karp"
6.147 +- \ref lemon::EdmondsKarp "Edmonds-Karp"
6.148 - \ref lemon::Preflow "Goldberg's Preflow algorithm"
6.149 - \ref lemon::DinitzSleatorTarjan "Dinitz's blocking flow algorithm with dynamic trees"
6.150 - \ref lemon::GoldbergTarjan "Preflow algorithm with dynamic trees"
6.151 @@ -250,12 +250,12 @@
6.152 \brief Algorithms for finding minimum cost flows and circulations.
6.153
6.154 This group describes the algorithms for finding minimum cost flows and
6.155 -circulations.
6.156 +circulations.
6.157 */
6.158
6.159 /**
6.160 -@defgroup min_cut Minimum Cut algorithms
6.161 -@ingroup algs
6.162 +@defgroup min_cut Minimum Cut algorithms
6.163 +@ingroup algs
6.164
6.165 \brief Algorithms for finding minimum cut in graphs.
6.166
6.167 @@ -272,7 +272,7 @@
6.168 LEMON contains several algorithms related to minimum cut problems:
6.169
6.170 - \ref lemon::HaoOrlin "Hao-Orlin algorithm" to calculate minimum cut
6.171 - in directed graphs
6.172 + in directed graphs
6.173 - \ref lemon::NagamochiIbaraki "Nagamochi-Ibaraki algorithm" to
6.174 calculate minimum cut in undirected graphs
6.175 - \ref lemon::GomoryHuTree "Gomory-Hu tree computation" to calculate all
6.176 @@ -307,14 +307,14 @@
6.177 */
6.178
6.179 /**
6.180 -@defgroup matching Matching algorithms
6.181 +@defgroup matching Matching algorithms
6.182 @ingroup algs
6.183 \brief Algorithms for finding matchings in graphs and bipartite graphs.
6.184
6.185 This group contains algorithm objects and functions to calculate
6.186 matchings in graphs and bipartite graphs. The general matching problem is
6.187 finding a subset of the arcs which does not shares common endpoints.
6.188 -
6.189 +
6.190 There are several different algorithms for calculate matchings in
6.191 graphs. The matching problems in bipartite graphs are generally
6.192 easier than in general graphs. The goal of the matching optimization
6.193 @@ -323,16 +323,16 @@
6.194 maximum cardinality matching.
6.195
6.196 Lemon contains the next algorithms:
6.197 -- \ref lemon::MaxBipartiteMatching "MaxBipartiteMatching" Hopcroft-Karp
6.198 - augmenting path algorithm for calculate maximum cardinality matching in
6.199 +- \ref lemon::MaxBipartiteMatching "MaxBipartiteMatching" Hopcroft-Karp
6.200 + augmenting path algorithm for calculate maximum cardinality matching in
6.201 bipartite graphs
6.202 -- \ref lemon::PrBipartiteMatching "PrBipartiteMatching" Push-Relabel
6.203 - algorithm for calculate maximum cardinality matching in bipartite graphs
6.204 -- \ref lemon::MaxWeightedBipartiteMatching "MaxWeightedBipartiteMatching"
6.205 - Successive shortest path algorithm for calculate maximum weighted matching
6.206 +- \ref lemon::PrBipartiteMatching "PrBipartiteMatching" Push-Relabel
6.207 + algorithm for calculate maximum cardinality matching in bipartite graphs
6.208 +- \ref lemon::MaxWeightedBipartiteMatching "MaxWeightedBipartiteMatching"
6.209 + Successive shortest path algorithm for calculate maximum weighted matching
6.210 and maximum weighted bipartite matching in bipartite graph
6.211 -- \ref lemon::MinCostMaxBipartiteMatching "MinCostMaxBipartiteMatching"
6.212 - Successive shortest path algorithm for calculate minimum cost maximum
6.213 +- \ref lemon::MinCostMaxBipartiteMatching "MinCostMaxBipartiteMatching"
6.214 + Successive shortest path algorithm for calculate minimum cost maximum
6.215 matching in bipartite graph
6.216 - \ref lemon::MaxMatching "MaxMatching" Edmond's blossom shrinking algorithm
6.217 for calculate maximum cardinality matching in general graph
6.218 @@ -396,8 +396,8 @@
6.219
6.220 */
6.221
6.222 -/**
6.223 -@defgroup lp_utils Tools for Lp and Mip solvers
6.224 +/**
6.225 +@defgroup lp_utils Tools for Lp and Mip solvers
6.226 @ingroup lp_group
6.227 \brief Helper tools to the Lp and Mip solvers.
6.228
6.229 @@ -414,7 +414,7 @@
6.230 */
6.231
6.232 /**
6.233 -@defgroup utils Tools and Utilities
6.234 +@defgroup utils Tools and Utilities
6.235 \brief Tools and utilities for programming in LEMON
6.236
6.237 Tools and utilities for programming in LEMON.
6.238 @@ -467,7 +467,7 @@
6.239 @defgroup io_group Input-Output
6.240 \brief Graph Input-Output methods
6.241
6.242 -This group describes the tools for importing and exporting graphs
6.243 +This group describes the tools for importing and exporting graphs
6.244 and graph related data. Now it supports the LEMON format, the
6.245 \c DIMACS format and the encapsulated postscript (EPS) format.
6.246 */
6.247 @@ -486,7 +486,7 @@
6.248 \brief General \c EPS drawer and graph exporter
6.249
6.250 This group describes general \c EPS drawing methods and special
6.251 -graph exporting tools.
6.252 +graph exporting tools.
6.253 */
6.254
6.255
6.256 @@ -498,7 +498,7 @@
6.257 classes implemented in LEMON.
6.258
6.259 The purpose of the classes in this group is fourfold.
6.260 -
6.261 +
6.262 - These classes contain the documentations of the concepts. In order
6.263 to avoid document multiplications, an implementation of a concept
6.264 simply refers to the corresponding concept class.
6.265 @@ -551,9 +551,9 @@
6.266 /**
6.267 @defgroup tools Standalone utility applications
6.268
6.269 -Some utility applications are listed here.
6.270 +Some utility applications are listed here.
6.271
6.272 The standard compilation procedure (<tt>./configure;make</tt>) will compile
6.273 -them, as well.
6.274 +them, as well.
6.275 */
6.276
7.1 --- a/doc/lgf.dox Sun Jul 13 16:46:56 2008 +0100
7.2 +++ b/doc/lgf.dox Sun Jul 13 19:51:02 2008 +0100
7.3 @@ -1,6 +1,6 @@
7.4 -/* -*- C++ -*-
7.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
7.6 *
7.7 - * This file is a part of LEMON, a generic C++ optimization library
7.8 + * This file is a part of LEMON, a generic C++ optimization library.
7.9 *
7.10 * Copyright (C) 2003-2008
7.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7.12 @@ -43,7 +43,7 @@
7.13 \e quoted. A plain token is just a sequence of non-whitespace characters,
7.14 while a quoted token is a
7.15 character sequence surrounded by double quotes, and it can also
7.16 -contain whitespaces and escape sequences.
7.17 +contain whitespaces and escape sequences.
7.18
7.19 The \c \@nodes section describes a set of nodes and associated
7.20 maps. The first is a header line, its columns are the names of the
7.21 @@ -72,7 +72,7 @@
7.22
7.23 \code
7.24 @arcs
7.25 - capacity
7.26 + capacity
7.27 1 2 16
7.28 1 3 12
7.29 2 3 18
8.1 --- a/doc/license.dox Sun Jul 13 16:46:56 2008 +0100
8.2 +++ b/doc/license.dox Sun Jul 13 19:51:02 2008 +0100
8.3 @@ -1,6 +1,6 @@
8.4 -/* -*- C++ -*-
8.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
8.6 *
8.7 - * This file is a part of LEMON, a generic C++ optimization library
8.8 + * This file is a part of LEMON, a generic C++ optimization library.
8.9 *
8.10 * Copyright (C) 2003-2008
8.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
9.1 --- a/doc/mainpage.dox Sun Jul 13 16:46:56 2008 +0100
9.2 +++ b/doc/mainpage.dox Sun Jul 13 19:51:02 2008 +0100
9.3 @@ -1,6 +1,6 @@
9.4 -/* -*- C++ -*-
9.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
9.6 *
9.7 - * This file is a part of LEMON, a generic C++ optimization library
9.8 + * This file is a part of LEMON, a generic C++ optimization library.
9.9 *
9.10 * Copyright (C) 2003-2008
9.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
9.12 @@ -41,15 +41,15 @@
9.13
9.14 \subsection howtoread How to read the documentation
9.15
9.16 -If you want to get a quick start and see the most important features then
9.17 +If you want to get a quick start and see the most important features then
9.18 take a look at our \ref quicktour
9.19 "Quick Tour to LEMON" which will guide you along.
9.20
9.21 -If you already feel like using our library, see the page that tells you
9.22 +If you already feel like using our library, see the page that tells you
9.23 \ref getstart "How to start using LEMON".
9.24
9.25 -If you
9.26 -want to see how LEMON works, see
9.27 +If you
9.28 +want to see how LEMON works, see
9.29 some \ref demoprograms "demo programs"!
9.30
9.31 If you know what you are looking for then try to find it under the
10.1 --- a/doc/namespaces.dox Sun Jul 13 16:46:56 2008 +0100
10.2 +++ b/doc/namespaces.dox Sun Jul 13 19:51:02 2008 +0100
10.3 @@ -1,6 +1,6 @@
10.4 -/* -*- C++ -*-
10.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
10.6 *
10.7 - * This file is a part of LEMON, a generic C++ optimization library
10.8 + * This file is a part of LEMON, a generic C++ optimization library.
10.9 *
10.10 * Copyright (C) 2003-2008
10.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
11.1 --- a/doc/template.h Sun Jul 13 16:46:56 2008 +0100
11.2 +++ b/doc/template.h Sun Jul 13 19:51:02 2008 +0100
11.3 @@ -1,6 +1,6 @@
11.4 -/* -*- C++ -*-
11.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
11.6 *
11.7 - * This file is a part of LEMON, a generic C++ optimization library
11.8 + * This file is a part of LEMON, a generic C++ optimization library.
11.9 *
11.10 * Copyright (C) 2003-2008
11.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
12.1 --- a/lemon/arg_parser.cc Sun Jul 13 16:46:56 2008 +0100
12.2 +++ b/lemon/arg_parser.cc Sun Jul 13 19:51:02 2008 +0100
12.3 @@ -1,6 +1,6 @@
12.4 -/* -*- C++ -*-
12.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
12.6 *
12.7 - * This file is a part of LEMON, a generic C++ optimization library
12.8 + * This file is a part of LEMON, a generic C++ optimization library.
12.9 *
12.10 * Copyright (C) 2003-2008
12.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
12.12 @@ -38,30 +38,30 @@
12.13 {
12.14 for(Opts::iterator i=_opts.begin();i!=_opts.end();++i)
12.15 if(i->second.self_delete)
12.16 - switch(i->second.type) {
12.17 - case BOOL:
12.18 - delete i->second.bool_p;
12.19 - break;
12.20 - case STRING:
12.21 - delete i->second.string_p;
12.22 - break;
12.23 - case DOUBLE:
12.24 - delete i->second.double_p;
12.25 - break;
12.26 - case INTEGER:
12.27 - delete i->second.int_p;
12.28 - break;
12.29 - case UNKNOWN:
12.30 - break;
12.31 - case FUNC:
12.32 - break;
12.33 - }
12.34 + switch(i->second.type) {
12.35 + case BOOL:
12.36 + delete i->second.bool_p;
12.37 + break;
12.38 + case STRING:
12.39 + delete i->second.string_p;
12.40 + break;
12.41 + case DOUBLE:
12.42 + delete i->second.double_p;
12.43 + break;
12.44 + case INTEGER:
12.45 + delete i->second.int_p;
12.46 + break;
12.47 + case UNKNOWN:
12.48 + break;
12.49 + case FUNC:
12.50 + break;
12.51 + }
12.52 }
12.53 -
12.54 +
12.55
12.56 ArgParser &ArgParser::intOption(const std::string &name,
12.57 - const std::string &help,
12.58 - int value, bool obl)
12.59 + const std::string &help,
12.60 + int value, bool obl)
12.61 {
12.62 ParData p;
12.63 p.int_p=new int(value);
12.64 @@ -74,8 +74,8 @@
12.65 }
12.66
12.67 ArgParser &ArgParser::doubleOption(const std::string &name,
12.68 - const std::string &help,
12.69 - double value, bool obl)
12.70 + const std::string &help,
12.71 + double value, bool obl)
12.72 {
12.73 ParData p;
12.74 p.double_p=new double(value);
12.75 @@ -88,8 +88,8 @@
12.76 }
12.77
12.78 ArgParser &ArgParser::boolOption(const std::string &name,
12.79 - const std::string &help,
12.80 - bool value, bool obl)
12.81 + const std::string &help,
12.82 + bool value, bool obl)
12.83 {
12.84 ParData p;
12.85 p.bool_p=new bool(value);
12.86 @@ -102,8 +102,8 @@
12.87 }
12.88
12.89 ArgParser &ArgParser::stringOption(const std::string &name,
12.90 - const std::string &help,
12.91 - std::string value, bool obl)
12.92 + const std::string &help,
12.93 + std::string value, bool obl)
12.94 {
12.95 ParData p;
12.96 p.string_p=new std::string(value);
12.97 @@ -116,8 +116,8 @@
12.98 }
12.99
12.100 ArgParser &ArgParser::refOption(const std::string &name,
12.101 - const std::string &help,
12.102 - int &ref, bool obl)
12.103 + const std::string &help,
12.104 + int &ref, bool obl)
12.105 {
12.106 ParData p;
12.107 p.int_p=&ref;
12.108 @@ -161,8 +161,8 @@
12.109 }
12.110
12.111 ArgParser &ArgParser::refOption(const std::string &name,
12.112 - const std::string &help,
12.113 - std::string &ref, bool obl)
12.114 + const std::string &help,
12.115 + std::string &ref, bool obl)
12.116 {
12.117 ParData p;
12.118 p.string_p=&ref;
12.119 @@ -175,8 +175,8 @@
12.120 }
12.121
12.122 ArgParser &ArgParser::funcOption(const std::string &name,
12.123 - const std::string &help,
12.124 - void (*func)(void *),void *data)
12.125 + const std::string &help,
12.126 + void (*func)(void *),void *data)
12.127 {
12.128 ParData p;
12.129 p.func_p.p=func;
12.130 @@ -190,11 +190,11 @@
12.131 }
12.132
12.133 ArgParser &ArgParser::optionGroup(const std::string &group,
12.134 - const std::string &opt)
12.135 + const std::string &opt)
12.136 {
12.137 Opts::iterator i = _opts.find(opt);
12.138 LEMON_ASSERT(i!=_opts.end(), "Unknown option: '"+opt+"'");
12.139 - LEMON_ASSERT(!(i->second.ingroup),
12.140 + LEMON_ASSERT(!(i->second.ingroup),
12.141 "Option already in option group: '"+opt+"'");
12.142 GroupData &g=_groups[group];
12.143 g.opts.push_back(opt);
12.144 @@ -210,7 +210,7 @@
12.145 }
12.146
12.147 ArgParser &ArgParser::synonym(const std::string &syn,
12.148 - const std::string &opt)
12.149 + const std::string &opt)
12.150 {
12.151 Opts::iterator o = _opts.find(opt);
12.152 Opts::iterator s = _opts.find(syn);
12.153 @@ -233,7 +233,7 @@
12.154 }
12.155
12.156 ArgParser &ArgParser::other(const std::string &name,
12.157 - const std::string &help)
12.158 + const std::string &help)
12.159 {
12.160 _others_help.push_back(OtherArg(name,help));
12.161 return *this;
12.162 @@ -244,8 +244,8 @@
12.163 os << "-" << i->first;
12.164 if(i->second.has_syn)
12.165 for(Opts::iterator j=_opts.begin();j!=_opts.end();++j)
12.166 - if(j->second.syn&&j->second.help==i->first)
12.167 - os << "|-" << j->first;
12.168 + if(j->second.syn&&j->second.help==i->first)
12.169 + os << "|-" << j->first;
12.170 switch(i->second.type) {
12.171 case STRING:
12.172 os << " str";
12.173 @@ -270,7 +270,7 @@
12.174 if(o!=i->second.opts.end()) os<<'|';
12.175 }
12.176 }
12.177 -
12.178 +
12.179 void ArgParser::showHelp(Opts::iterator i)
12.180 {
12.181 if(i->second.help.size()==0||i->second.syn) return;
12.182 @@ -283,9 +283,9 @@
12.183 {
12.184 if(i->help.size()==0) return;
12.185 std::cerr << " " << i->name << std::endl
12.186 - << " " << i->help << std::endl;
12.187 + << " " << i->help << std::endl;
12.188 }
12.189 -
12.190 +
12.191 void ArgParser::shortHelp()
12.192 {
12.193 const unsigned int LINE_LEN=77;
12.194 @@ -299,62 +299,62 @@
12.195 show(cstr,g);
12.196 if(!g->second.mandatory) cstr << ']';
12.197 if(pos+cstr.str().size()>LINE_LEN) {
12.198 - std::cerr << std::endl << indent;
12.199 - pos=indent.size();
12.200 + std::cerr << std::endl << indent;
12.201 + pos=indent.size();
12.202 }
12.203 std::cerr << cstr.str();
12.204 pos+=cstr.str().size();
12.205 }
12.206 for(Opts::iterator i=_opts.begin();i!=_opts.end();++i)
12.207 if(!i->second.ingroup&&!i->second.syn) {
12.208 - std::ostringstream cstr;
12.209 - cstr << ' ';
12.210 - if(!i->second.mandatory) cstr << '[';
12.211 - show(cstr,i);
12.212 - if(!i->second.mandatory) cstr << ']';
12.213 - if(pos+cstr.str().size()>LINE_LEN) {
12.214 - std::cerr << std::endl << indent;
12.215 - pos=indent.size();
12.216 - }
12.217 - std::cerr << cstr.str();
12.218 - pos+=cstr.str().size();
12.219 + std::ostringstream cstr;
12.220 + cstr << ' ';
12.221 + if(!i->second.mandatory) cstr << '[';
12.222 + show(cstr,i);
12.223 + if(!i->second.mandatory) cstr << ']';
12.224 + if(pos+cstr.str().size()>LINE_LEN) {
12.225 + std::cerr << std::endl << indent;
12.226 + pos=indent.size();
12.227 + }
12.228 + std::cerr << cstr.str();
12.229 + pos+=cstr.str().size();
12.230 }
12.231 for(std::vector<OtherArg>::iterator i=_others_help.begin();
12.232 - i!=_others_help.end();++i)
12.233 + i!=_others_help.end();++i)
12.234 {
12.235 - std::ostringstream cstr;
12.236 - cstr << ' ' << i->name;
12.237 -
12.238 - if(pos+cstr.str().size()>LINE_LEN) {
12.239 - std::cerr << std::endl << indent;
12.240 - pos=indent.size();
12.241 - }
12.242 - std::cerr << cstr.str();
12.243 - pos+=cstr.str().size();
12.244 + std::ostringstream cstr;
12.245 + cstr << ' ' << i->name;
12.246 +
12.247 + if(pos+cstr.str().size()>LINE_LEN) {
12.248 + std::cerr << std::endl << indent;
12.249 + pos=indent.size();
12.250 + }
12.251 + std::cerr << cstr.str();
12.252 + pos+=cstr.str().size();
12.253 }
12.254 std::cerr << std::endl;
12.255 }
12.256 -
12.257 +
12.258 void ArgParser::showHelp()
12.259 {
12.260 shortHelp();
12.261 std::cerr << "Where:\n";
12.262 for(std::vector<OtherArg>::iterator i=_others_help.begin();
12.263 - i!=_others_help.end();++i) showHelp(i);
12.264 + i!=_others_help.end();++i) showHelp(i);
12.265 for(Opts::iterator i=_opts.begin();i!=_opts.end();++i) showHelp(i);
12.266 exit(1);
12.267 }
12.268 -
12.269 -
12.270 - void ArgParser::unknownOpt(std::string arg)
12.271 +
12.272 +
12.273 + void ArgParser::unknownOpt(std::string arg)
12.274 {
12.275 std::cerr << "\nUnknown option: " << arg << "\n";
12.276 std::cerr << "\nType '" << _command_name <<
12.277 " --help' to obtain a short summary on the usage.\n\n";
12.278 exit(1);
12.279 }
12.280 -
12.281 - void ArgParser::requiresValue(std::string arg, OptType t)
12.282 +
12.283 + void ArgParser::requiresValue(std::string arg, OptType t)
12.284 {
12.285 std::cerr << "Argument '" << arg << "' requires a";
12.286 switch(t) {
12.287 @@ -373,47 +373,47 @@
12.288 std::cerr << " value\n\n";
12.289 showHelp();
12.290 }
12.291 -
12.292 +
12.293
12.294 void ArgParser::checkMandatories()
12.295 {
12.296 bool ok=true;
12.297 for(Opts::iterator i=_opts.begin();i!=_opts.end();++i)
12.298 - if(i->second.mandatory&&!i->second.set)
12.299 - {
12.300 - if(ok)
12.301 - std::cerr << _command_name
12.302 - << ": The following mandatory arguments are missing.\n";
12.303 - ok=false;
12.304 - showHelp(i);
12.305 - }
12.306 + if(i->second.mandatory&&!i->second.set)
12.307 + {
12.308 + if(ok)
12.309 + std::cerr << _command_name
12.310 + << ": The following mandatory arguments are missing.\n";
12.311 + ok=false;
12.312 + showHelp(i);
12.313 + }
12.314 for(Groups::iterator i=_groups.begin();i!=_groups.end();++i)
12.315 if(i->second.mandatory||i->second.only_one)
12.316 - {
12.317 - int set=0;
12.318 - for(GroupData::Opts::iterator o=i->second.opts.begin();
12.319 - o!=i->second.opts.end();++o)
12.320 - if(_opts.find(*o)->second.set) ++set;
12.321 - if(i->second.mandatory&&!set) {
12.322 - std::cerr << _command_name
12.323 - << ": At least one of the following arguments is mandatory.\n";
12.324 - ok=false;
12.325 - for(GroupData::Opts::iterator o=i->second.opts.begin();
12.326 - o!=i->second.opts.end();++o)
12.327 - showHelp(_opts.find(*o));
12.328 - }
12.329 - if(i->second.only_one&&set>1) {
12.330 - std::cerr << _command_name
12.331 - << ": At most one of the following arguments can be given.\n";
12.332 - ok=false;
12.333 - for(GroupData::Opts::iterator o=i->second.opts.begin();
12.334 - o!=i->second.opts.end();++o)
12.335 - showHelp(_opts.find(*o));
12.336 - }
12.337 - }
12.338 + {
12.339 + int set=0;
12.340 + for(GroupData::Opts::iterator o=i->second.opts.begin();
12.341 + o!=i->second.opts.end();++o)
12.342 + if(_opts.find(*o)->second.set) ++set;
12.343 + if(i->second.mandatory&&!set) {
12.344 + std::cerr << _command_name
12.345 + << ": At least one of the following arguments is mandatory.\n";
12.346 + ok=false;
12.347 + for(GroupData::Opts::iterator o=i->second.opts.begin();
12.348 + o!=i->second.opts.end();++o)
12.349 + showHelp(_opts.find(*o));
12.350 + }
12.351 + if(i->second.only_one&&set>1) {
12.352 + std::cerr << _command_name
12.353 + << ": At most one of the following arguments can be given.\n";
12.354 + ok=false;
12.355 + for(GroupData::Opts::iterator o=i->second.opts.begin();
12.356 + o!=i->second.opts.end();++o)
12.357 + showHelp(_opts.find(*o));
12.358 + }
12.359 + }
12.360 if(!ok) {
12.361 std::cerr << "\nType '" << _command_name <<
12.362 - " --help' to obtain a short summary on the usage.\n\n";
12.363 + " --help' to obtain a short summary on the usage.\n\n";
12.364 exit(1);
12.365 }
12.366 }
12.367 @@ -423,43 +423,43 @@
12.368 for(int ar=1; ar<_argc; ++ar) {
12.369 std::string arg(_argv[ar]);
12.370 if (arg[0] != '-' || arg.size() == 1) {
12.371 - _file_args.push_back(arg);
12.372 + _file_args.push_back(arg);
12.373 }
12.374 else {
12.375 - Opts::iterator i = _opts.find(arg.substr(1));
12.376 - if(i==_opts.end()) unknownOpt(arg);
12.377 - else {
12.378 - if(i->second.syn) i=_opts.find(i->second.help);
12.379 - ParData &p(i->second);
12.380 - if (p.type==BOOL) *p.bool_p=true;
12.381 - else if (p.type==FUNC) p.func_p.p(p.func_p.data);
12.382 - else if(++ar==_argc) requiresValue(arg, p.type);
12.383 - else {
12.384 - std::string val(_argv[ar]);
12.385 - std::istringstream vals(val);
12.386 - switch(p.type) {
12.387 - case STRING:
12.388 - *p.string_p=val;
12.389 - break;
12.390 - case INTEGER:
12.391 - vals >> *p.int_p;
12.392 - break;
12.393 - case DOUBLE:
12.394 - vals >> *p.double_p;
12.395 - break;
12.396 - default:
12.397 - break;
12.398 - }
12.399 - if(p.type!=STRING&&(!vals||!vals.eof()))
12.400 - requiresValue(arg, p.type);
12.401 - }
12.402 - p.set = true;
12.403 - }
12.404 + Opts::iterator i = _opts.find(arg.substr(1));
12.405 + if(i==_opts.end()) unknownOpt(arg);
12.406 + else {
12.407 + if(i->second.syn) i=_opts.find(i->second.help);
12.408 + ParData &p(i->second);
12.409 + if (p.type==BOOL) *p.bool_p=true;
12.410 + else if (p.type==FUNC) p.func_p.p(p.func_p.data);
12.411 + else if(++ar==_argc) requiresValue(arg, p.type);
12.412 + else {
12.413 + std::string val(_argv[ar]);
12.414 + std::istringstream vals(val);
12.415 + switch(p.type) {
12.416 + case STRING:
12.417 + *p.string_p=val;
12.418 + break;
12.419 + case INTEGER:
12.420 + vals >> *p.int_p;
12.421 + break;
12.422 + case DOUBLE:
12.423 + vals >> *p.double_p;
12.424 + break;
12.425 + default:
12.426 + break;
12.427 + }
12.428 + if(p.type!=STRING&&(!vals||!vals.eof()))
12.429 + requiresValue(arg, p.type);
12.430 + }
12.431 + p.set = true;
12.432 + }
12.433 }
12.434 }
12.435 checkMandatories();
12.436
12.437 return *this;
12.438 - }
12.439 + }
12.440
12.441 }
13.1 --- a/lemon/arg_parser.h Sun Jul 13 16:46:56 2008 +0100
13.2 +++ b/lemon/arg_parser.h Sun Jul 13 19:51:02 2008 +0100
13.3 @@ -1,6 +1,6 @@
13.4 -/* -*- C++ -*-
13.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
13.6 *
13.7 - * This file is a part of LEMON, a generic C++ optimization library
13.8 + * This file is a part of LEMON, a generic C++ optimization library.
13.9 *
13.10 * Copyright (C) 2003-2008
13.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
13.12 @@ -41,27 +41,27 @@
13.13 ///
13.14 ///For a complete example see the \ref arg_parser_demo.cc demo file.
13.15 class ArgParser {
13.16 -
13.17 +
13.18 static void _showHelp(void *p);
13.19 protected:
13.20 -
13.21 +
13.22 int _argc;
13.23 const char **_argv;
13.24 -
13.25 +
13.26 enum OptType { UNKNOWN=0, BOOL=1, STRING=2, DOUBLE=3, INTEGER=4, FUNC=5 };
13.27 -
13.28 +
13.29 class ParData {
13.30 public:
13.31 union {
13.32 - bool *bool_p;
13.33 - int *int_p;
13.34 - double *double_p;
13.35 - std::string *string_p;
13.36 - struct {
13.37 - void (*p)(void *);
13.38 - void *data;
13.39 - } func_p;
13.40 -
13.41 + bool *bool_p;
13.42 + int *int_p;
13.43 + double *double_p;
13.44 + std::string *string_p;
13.45 + struct {
13.46 + void (*p)(void *);
13.47 + void *data;
13.48 + } func_p;
13.49 +
13.50 };
13.51 std::string help;
13.52 bool mandatory;
13.53 @@ -72,13 +72,13 @@
13.54 bool syn;
13.55 bool self_delete;
13.56 ParData() : mandatory(false), type(UNKNOWN), set(false), ingroup(false),
13.57 - has_syn(false), syn(false), self_delete(false) {}
13.58 + has_syn(false), syn(false), self_delete(false) {}
13.59 };
13.60
13.61 typedef std::map<std::string,ParData> Opts;
13.62 Opts _opts;
13.63
13.64 - class GroupData
13.65 + class GroupData
13.66 {
13.67 public:
13.68 typedef std::list<std::string> Opts;
13.69 @@ -87,7 +87,7 @@
13.70 bool mandatory;
13.71 GroupData() :only_one(false), mandatory(false) {}
13.72 };
13.73 -
13.74 +
13.75 typedef std::map<std::string,GroupData> Groups;
13.76 Groups _groups;
13.77
13.78 @@ -98,12 +98,12 @@
13.79 OtherArg(std::string n, std::string h) :name(n), help(h) {}
13.80
13.81 };
13.82 -
13.83 +
13.84 std::vector<OtherArg> _others_help;
13.85 std::vector<std::string> _file_args;
13.86 std::string _command_name;
13.87
13.88 -
13.89 +
13.90 private:
13.91 //Bind a function to an option.
13.92
13.93 @@ -113,9 +113,9 @@
13.94 // must be of type "void f(void *)"
13.95 //\param data Data to be passed to \c func
13.96 ArgParser &funcOption(const std::string &name,
13.97 - const std::string &help,
13.98 - void (*func)(void *),void *data);
13.99 -
13.100 + const std::string &help,
13.101 + void (*func)(void *),void *data);
13.102 +
13.103 public:
13.104
13.105 ///Constructor
13.106 @@ -136,8 +136,8 @@
13.107 ///\param value A default value for the option.
13.108 ///\param obl Indicate if the option is mandatory.
13.109 ArgParser &intOption(const std::string &name,
13.110 - const std::string &help,
13.111 - int value=0, bool obl=false);
13.112 + const std::string &help,
13.113 + int value=0, bool obl=false);
13.114
13.115 ///Add a new floating point type option
13.116
13.117 @@ -147,8 +147,8 @@
13.118 ///\param value A default value for the option.
13.119 ///\param obl Indicate if the option is mandatory.
13.120 ArgParser &doubleOption(const std::string &name,
13.121 - const std::string &help,
13.122 - double value=0, bool obl=false);
13.123 + const std::string &help,
13.124 + double value=0, bool obl=false);
13.125
13.126 ///Add a new bool type option
13.127
13.128 @@ -159,8 +159,8 @@
13.129 ///\param obl Indicate if the option is mandatory.
13.130 ///\note A mandatory bool obtion is of very little use.
13.131 ArgParser &boolOption(const std::string &name,
13.132 - const std::string &help,
13.133 - bool value=false, bool obl=false);
13.134 + const std::string &help,
13.135 + bool value=false, bool obl=false);
13.136
13.137 ///Add a new string type option
13.138
13.139 @@ -170,8 +170,8 @@
13.140 ///\param value A default value for the option.
13.141 ///\param obl Indicate if the option is mandatory.
13.142 ArgParser &stringOption(const std::string &name,
13.143 - const std::string &help,
13.144 - std::string value="", bool obl=false);
13.145 + const std::string &help,
13.146 + std::string value="", bool obl=false);
13.147
13.148 ///Give help string for non-parsed arguments.
13.149
13.150 @@ -179,8 +179,8 @@
13.151 ///The parameter \c name will be printed in the short usage line, while
13.152 ///\c help gives a more detailed description.
13.153 ArgParser &other(const std::string &name,
13.154 - const std::string &help="");
13.155 -
13.156 + const std::string &help="");
13.157 +
13.158 ///@}
13.159
13.160 ///\name Options with External Storage
13.161 @@ -197,8 +197,8 @@
13.162 ///\param obl Indicate if the option is mandatory.
13.163 ///\retval ref The value of the argument will be written to this variable.
13.164 ArgParser &refOption(const std::string &name,
13.165 - const std::string &help,
13.166 - int &ref, bool obl=false);
13.167 + const std::string &help,
13.168 + int &ref, bool obl=false);
13.169
13.170 ///Add a new floating type option with a storage reference
13.171
13.172 @@ -208,8 +208,8 @@
13.173 ///\param obl Indicate if the option is mandatory.
13.174 ///\retval ref The value of the argument will be written to this variable.
13.175 ArgParser &refOption(const std::string &name,
13.176 - const std::string &help,
13.177 - double &ref, bool obl=false);
13.178 + const std::string &help,
13.179 + double &ref, bool obl=false);
13.180
13.181 ///Add a new bool type option with a storage reference
13.182
13.183 @@ -220,8 +220,8 @@
13.184 ///\retval ref The value of the argument will be written to this variable.
13.185 ///\note A mandatory bool obtion is of very little use.
13.186 ArgParser &refOption(const std::string &name,
13.187 - const std::string &help,
13.188 - bool &ref, bool obl=false);
13.189 + const std::string &help,
13.190 + bool &ref, bool obl=false);
13.191
13.192 ///Add a new string type option with a storage reference
13.193
13.194 @@ -231,14 +231,14 @@
13.195 ///\param obl Indicate if the option is mandatory.
13.196 ///\retval ref The value of the argument will be written to this variable.
13.197 ArgParser &refOption(const std::string &name,
13.198 - const std::string &help,
13.199 - std::string &ref, bool obl=false);
13.200 -
13.201 + const std::string &help,
13.202 + std::string &ref, bool obl=false);
13.203 +
13.204 ///@}
13.205
13.206 ///\name Option Groups and Synonyms
13.207 ///
13.208 -
13.209 +
13.210 ///@{
13.211
13.212 ///Bundle some options into a group
13.213 @@ -248,27 +248,27 @@
13.214 ///\param group The group name.
13.215 ///\param opt The option name.
13.216 ArgParser &optionGroup(const std::string &group,
13.217 - const std::string &opt);
13.218 + const std::string &opt);
13.219
13.220 ///Make the members of a group exclusive
13.221
13.222 ///If you call this function for a group, than at most one of them can be
13.223 ///given at the same time.
13.224 ArgParser &onlyOneGroup(const std::string &group);
13.225 -
13.226 +
13.227 ///Make a group mandatory
13.228
13.229 ///Using this function, at least one of the members of \c group
13.230 ///must be given.
13.231 ArgParser &mandatoryGroup(const std::string &group);
13.232 -
13.233 +
13.234 ///Create synonym to an option
13.235
13.236 ///With this function you can create a synonym \c syn of the
13.237 ///option \c opt.
13.238 ArgParser &synonym(const std::string &syn,
13.239 - const std::string &opt);
13.240 -
13.241 + const std::string &opt);
13.242 +
13.243 ///@}
13.244
13.245 void show(std::ostream &os,Opts::iterator i);
13.246 @@ -282,21 +282,21 @@
13.247
13.248 void requiresValue(std::string arg, OptType t);
13.249 void checkMandatories();
13.250 -
13.251 +
13.252 ///Start the parsing process
13.253 ArgParser &parse();
13.254
13.255 /// Synonym for parse()
13.256 - ArgParser &run()
13.257 + ArgParser &run()
13.258 {
13.259 return parse();
13.260 }
13.261 -
13.262 +
13.263 ///Give back the command name (the 0th argument)
13.264 const std::string &commandName() { return _command_name; }
13.265
13.266 ///Check if an opion has been given to the command.
13.267 - bool given(std::string op)
13.268 + bool given(std::string op)
13.269 {
13.270 Opts::iterator i = _opts.find(op);
13.271 return i!=_opts.end()?i->second.set:false;
13.272 @@ -304,12 +304,12 @@
13.273
13.274
13.275 ///Magic type for operator[]
13.276 -
13.277 +
13.278 ///This is the type of the return value of ArgParser::operator[]().
13.279 ///It automatically converts to \c int, \c double, \c bool or
13.280 ///\c std::string if the type of the option matches, otherwise it
13.281 ///throws an exception (i.e. it performs runtime type checking).
13.282 - class RefType
13.283 + class RefType
13.284 {
13.285 ArgParser &_parser;
13.286 std::string _name;
13.287 @@ -317,65 +317,65 @@
13.288 ///\e
13.289 RefType(ArgParser &p,const std::string &n) :_parser(p),_name(n) {}
13.290 ///\e
13.291 - operator bool()
13.292 + operator bool()
13.293 {
13.294 - Opts::iterator i = _parser._opts.find(_name);
13.295 - LEMON_ASSERT(i!=_parser._opts.end(),
13.296 - std::string()+"Unkown option: '"+_name+"'");
13.297 - LEMON_ASSERT(i->second.type==ArgParser::BOOL,
13.298 - std::string()+"'"+_name+"' is a bool option");
13.299 - return *(i->second.bool_p);
13.300 + Opts::iterator i = _parser._opts.find(_name);
13.301 + LEMON_ASSERT(i!=_parser._opts.end(),
13.302 + std::string()+"Unkown option: '"+_name+"'");
13.303 + LEMON_ASSERT(i->second.type==ArgParser::BOOL,
13.304 + std::string()+"'"+_name+"' is a bool option");
13.305 + return *(i->second.bool_p);
13.306 }
13.307 ///\e
13.308 operator std::string()
13.309 {
13.310 - Opts::iterator i = _parser._opts.find(_name);
13.311 - LEMON_ASSERT(i!=_parser._opts.end(),
13.312 - std::string()+"Unkown option: '"+_name+"'");
13.313 - LEMON_ASSERT(i->second.type==ArgParser::STRING,
13.314 - std::string()+"'"+_name+"' is a string option");
13.315 - return *(i->second.string_p);
13.316 + Opts::iterator i = _parser._opts.find(_name);
13.317 + LEMON_ASSERT(i!=_parser._opts.end(),
13.318 + std::string()+"Unkown option: '"+_name+"'");
13.319 + LEMON_ASSERT(i->second.type==ArgParser::STRING,
13.320 + std::string()+"'"+_name+"' is a string option");
13.321 + return *(i->second.string_p);
13.322 }
13.323 ///\e
13.324 - operator double()
13.325 + operator double()
13.326 {
13.327 - Opts::iterator i = _parser._opts.find(_name);
13.328 - LEMON_ASSERT(i!=_parser._opts.end(),
13.329 - std::string()+"Unkown option: '"+_name+"'");
13.330 - LEMON_ASSERT(i->second.type==ArgParser::DOUBLE ||
13.331 - i->second.type==ArgParser::INTEGER,
13.332 - std::string()+"'"+_name+"' is a floating point option");
13.333 - return i->second.type==ArgParser::DOUBLE ?
13.334 - *(i->second.double_p) : *(i->second.int_p);
13.335 + Opts::iterator i = _parser._opts.find(_name);
13.336 + LEMON_ASSERT(i!=_parser._opts.end(),
13.337 + std::string()+"Unkown option: '"+_name+"'");
13.338 + LEMON_ASSERT(i->second.type==ArgParser::DOUBLE ||
13.339 + i->second.type==ArgParser::INTEGER,
13.340 + std::string()+"'"+_name+"' is a floating point option");
13.341 + return i->second.type==ArgParser::DOUBLE ?
13.342 + *(i->second.double_p) : *(i->second.int_p);
13.343 }
13.344 ///\e
13.345 - operator int()
13.346 + operator int()
13.347 {
13.348 - Opts::iterator i = _parser._opts.find(_name);
13.349 - LEMON_ASSERT(i!=_parser._opts.end(),
13.350 - std::string()+"Unkown option: '"+_name+"'");
13.351 - LEMON_ASSERT(i->second.type==ArgParser::INTEGER,
13.352 - std::string()+"'"+_name+"' is an integer option");
13.353 - return *(i->second.int_p);
13.354 + Opts::iterator i = _parser._opts.find(_name);
13.355 + LEMON_ASSERT(i!=_parser._opts.end(),
13.356 + std::string()+"Unkown option: '"+_name+"'");
13.357 + LEMON_ASSERT(i->second.type==ArgParser::INTEGER,
13.358 + std::string()+"'"+_name+"' is an integer option");
13.359 + return *(i->second.int_p);
13.360 }
13.361
13.362 };
13.363
13.364 ///Give back the value of an option
13.365 -
13.366 +
13.367 ///Give back the value of an option.
13.368 ///\sa RefType
13.369 RefType operator[](const std::string &n)
13.370 {
13.371 return RefType(*this, n);
13.372 - }
13.373 + }
13.374
13.375 ///Give back the non-option type arguments.
13.376
13.377 ///Give back a reference to a vector consisting of the program arguments
13.378 ///not starting with a '-' character.
13.379 std::vector<std::string> &files() { return _file_args; }
13.380 -
13.381 +
13.382 };
13.383 }
13.384
14.1 --- a/lemon/assert.h Sun Jul 13 16:46:56 2008 +0100
14.2 +++ b/lemon/assert.h Sun Jul 13 19:51:02 2008 +0100
14.3 @@ -1,6 +1,6 @@
14.4 -/* -*- C++ -*-
14.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
14.6 *
14.7 - * This file is a part of LEMON, a generic C++ optimization library
14.8 + * This file is a part of LEMON, a generic C++ optimization library.
14.9 *
14.10 * Copyright (C) 2003-2008
14.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
14.12 @@ -28,7 +28,7 @@
14.13 namespace lemon {
14.14
14.15 inline void assert_fail_log(const char *file, int line, const char *function,
14.16 - const char *message, const char *assertion)
14.17 + const char *message, const char *assertion)
14.18 {
14.19 std::cerr << file << ":" << line << ": ";
14.20 if (function)
14.21 @@ -40,23 +40,23 @@
14.22 }
14.23
14.24 inline void assert_fail_abort(const char *file, int line,
14.25 - const char *function, const char* message,
14.26 - const char *assertion)
14.27 + const char *function, const char* message,
14.28 + const char *assertion)
14.29 {
14.30 assert_fail_log(file, line, function, message, assertion);
14.31 std::abort();
14.32 }
14.33
14.34 namespace _assert_bits {
14.35 -
14.36 -
14.37 +
14.38 +
14.39 inline const char* cstringify(const std::string& str) {
14.40 return str.c_str();
14.41 }
14.42
14.43 inline const char* cstringify(const char* str) {
14.44 return str;
14.45 - }
14.46 + }
14.47 }
14.48 }
14.49
14.50 @@ -66,17 +66,17 @@
14.51 #undef LEMON_FIXME
14.52 #undef LEMON_DEBUG
14.53
14.54 -#if (defined(LEMON_ASSERT_LOG) ? 1 : 0) + \
14.55 - (defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \
14.56 +#if (defined(LEMON_ASSERT_LOG) ? 1 : 0) + \
14.57 + (defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \
14.58 (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) > 1
14.59 #error "LEMON assertion system is not set properly"
14.60 #endif
14.61
14.62 -#if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) + \
14.63 - (defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \
14.64 - (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 || \
14.65 - defined(LEMON_ENABLE_ASSERTS)) && \
14.66 - (defined(LEMON_DISABLE_ASSERTS) || \
14.67 +#if ((defined(LEMON_ASSERT_LOG) ? 1 : 0) + \
14.68 + (defined(LEMON_ASSERT_ABORT) ? 1 : 0) + \
14.69 + (defined(LEMON_ASSERT_CUSTOM) ? 1 : 0) == 1 || \
14.70 + defined(LEMON_ENABLE_ASSERTS)) && \
14.71 + (defined(LEMON_DISABLE_ASSERTS) || \
14.72 defined(NDEBUG))
14.73 #error "LEMON assertion system is not set properly"
14.74 #endif
14.75 @@ -136,12 +136,12 @@
14.76 /// make CXXFLAGS='-DLEMON_DISABLE_ASSERTS'
14.77 /// \endcode
14.78 /// The checking is also disabled when the standard macro \c NDEBUG is defined.
14.79 -///
14.80 +///
14.81 /// The LEMON assertion system has a wide range of customization
14.82 /// properties. As a default behaviour the failed assertion prints a
14.83 /// short log message to the standard error and aborts the execution.
14.84 ///
14.85 -/// The following modes can be used in the assertion system:
14.86 +/// The following modes can be used in the assertion system:
14.87 ///
14.88 /// - \c LEMON_ASSERT_LOG The failed assertion prints a short log
14.89 /// message to the standard error and continues the execution.
14.90 @@ -155,7 +155,7 @@
14.91 /// const char* message, const char* assertion);
14.92 /// \endcode
14.93 /// The name of the function should be defined as the \c
14.94 -/// LEMON_CUSTOM_ASSERT_HANDLER macro name.
14.95 +/// LEMON_CUSTOM_ASSERT_HANDLER macro name.
14.96 /// \code
14.97 /// #define LEMON_CUSTOM_ASSERT_HANDLER custom_assert_handler
14.98 /// \endcode
14.99 @@ -166,11 +166,11 @@
14.100 /// If the macros are redefined with other settings and the
14.101 /// \ref lemon/assert.h "assert.h" file is reincluded, then the
14.102 /// behaviour is changed appropiately to the new settings.
14.103 -# define LEMON_ASSERT(exp, msg) \
14.104 - (static_cast<void> (!!(exp) ? 0 : ( \
14.105 - LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \
14.106 - LEMON_FUNCTION_NAME, \
14.107 - ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
14.108 +# define LEMON_ASSERT(exp, msg) \
14.109 + (static_cast<void> (!!(exp) ? 0 : ( \
14.110 + LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \
14.111 + LEMON_FUNCTION_NAME, \
14.112 + ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
14.113
14.114 /// \ingroup exceptions
14.115 ///
14.116 @@ -182,11 +182,11 @@
14.117 /// LEMON_ASSERT(false, msg);
14.118 /// \endcode
14.119 ///
14.120 -/// \see LEMON_ASSERT
14.121 -# define LEMON_FIXME(msg) \
14.122 - (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME, \
14.123 - ::lemon::_assert_bits::cstringify(msg), \
14.124 - static_cast<const char*>(0)))
14.125 +/// \see LEMON_ASSERT
14.126 +# define LEMON_FIXME(msg) \
14.127 + (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME, \
14.128 + ::lemon::_assert_bits::cstringify(msg), \
14.129 + static_cast<const char*>(0)))
14.130
14.131 /// \ingroup exceptions
14.132 ///
14.133 @@ -210,12 +210,12 @@
14.134 /// current behaviour depends on the settings of \c LEMON_ASSERT
14.135 /// macro.
14.136 ///
14.137 -/// \see LEMON_ASSERT
14.138 -# define LEMON_DEBUG(exp, msg) \
14.139 - (static_cast<void> (!!(exp) ? 0 : ( \
14.140 +/// \see LEMON_ASSERT
14.141 +# define LEMON_DEBUG(exp, msg) \
14.142 + (static_cast<void> (!!(exp) ? 0 : ( \
14.143 LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \
14.144 - LEMON_FUNCTION_NAME, \
14.145 - ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
14.146 + LEMON_FUNCTION_NAME, \
14.147 + ::lemon::_assert_bits::cstringify(msg), #exp), 0)))
14.148
14.149 #else
14.150
14.151 @@ -224,24 +224,24 @@
14.152 # define LEMON_FIXME(msg) (static_cast<void>(0))
14.153 # define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
14.154 # else
14.155 -# define LEMON_ASSERT(exp, msg) \
14.156 - (static_cast<void> (!!(exp) ? 0 : ( \
14.157 +# define LEMON_ASSERT(exp, msg) \
14.158 + (static_cast<void> (!!(exp) ? 0 : ( \
14.159 LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \
14.160 - LEMON_FUNCTION_NAME, \
14.161 - ::lemon::_assert_bits::cstringify(msg), \
14.162 - #exp), 0)))
14.163 -# define LEMON_FIXME(msg) \
14.164 - (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME, \
14.165 - ::lemon::_assert_bits::cstringify(msg), \
14.166 - static_cast<const char*>(0)))
14.167 + LEMON_FUNCTION_NAME, \
14.168 + ::lemon::_assert_bits::cstringify(msg), \
14.169 + #exp), 0)))
14.170 +# define LEMON_FIXME(msg) \
14.171 + (LEMON_ASSERT_HANDLER(__FILE__, __LINE__, LEMON_FUNCTION_NAME, \
14.172 + ::lemon::_assert_bits::cstringify(msg), \
14.173 + static_cast<const char*>(0)))
14.174
14.175 # if LEMON_ENABLE_DEBUG
14.176 # define LEMON_DEBUG(exp, msg)
14.177 (static_cast<void> (!!(exp) ? 0 : ( \
14.178 LEMON_ASSERT_HANDLER(__FILE__, __LINE__, \
14.179 LEMON_FUNCTION_NAME, \
14.180 - ::lemon::_assert_bits::cstringify(msg), \
14.181 - #exp), 0)))
14.182 + ::lemon::_assert_bits::cstringify(msg), \
14.183 + #exp), 0)))
14.184 # else
14.185 # define LEMON_DEBUG(exp, msg) (static_cast<void>(0))
14.186 # endif
15.1 --- a/lemon/base.cc Sun Jul 13 16:46:56 2008 +0100
15.2 +++ b/lemon/base.cc Sun Jul 13 19:51:02 2008 +0100
15.3 @@ -1,6 +1,6 @@
15.4 -/* -*- C++ -*-
15.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
15.6 *
15.7 - * This file is a part of LEMON, a generic C++ optimization library
15.8 + * This file is a part of LEMON, a generic C++ optimization library.
15.9 *
15.10 * Copyright (C) 2003-2008
15.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
16.1 --- a/lemon/bfs.h Sun Jul 13 16:46:56 2008 +0100
16.2 +++ b/lemon/bfs.h Sun Jul 13 19:51:02 2008 +0100
16.3 @@ -1,6 +1,6 @@
16.4 -/* -*- C++ -*-
16.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
16.6 *
16.7 - * This file is a part of LEMON, a generic C++ optimization library
16.8 + * This file is a part of LEMON, a generic C++ optimization library.
16.9 *
16.10 * Copyright (C) 2003-2008
16.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
16.12 @@ -33,7 +33,7 @@
16.13 namespace lemon {
16.14
16.15
16.16 -
16.17 +
16.18 ///Default traits class of Bfs class.
16.19
16.20 ///Default traits class of Bfs class.
16.21 @@ -41,34 +41,34 @@
16.22 template<class GR>
16.23 struct BfsDefaultTraits
16.24 {
16.25 - ///The digraph type the algorithm runs on.
16.26 + ///The digraph type the algorithm runs on.
16.27 typedef GR Digraph;
16.28 ///\brief The type of the map that stores the last
16.29 ///arcs of the shortest paths.
16.30 - ///
16.31 + ///
16.32 ///The type of the map that stores the last
16.33 ///arcs of the shortest paths.
16.34 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
16.35 ///
16.36 typedef typename Digraph::template NodeMap<typename GR::Arc> PredMap;
16.37 ///Instantiates a PredMap.
16.38 -
16.39 - ///This function instantiates a \ref PredMap.
16.40 +
16.41 + ///This function instantiates a \ref PredMap.
16.42 ///\param G is the digraph, to which we would like to define the PredMap.
16.43 ///\todo The digraph alone may be insufficient to initialize
16.44 - static PredMap *createPredMap(const GR &G)
16.45 + static PredMap *createPredMap(const GR &G)
16.46 {
16.47 return new PredMap(G);
16.48 }
16.49 ///The type of the map that indicates which nodes are processed.
16.50 -
16.51 +
16.52 ///The type of the map that indicates which nodes are processed.
16.53 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
16.54 ///\todo named parameter to set this type, function to read and write.
16.55 typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
16.56 ///Instantiates a ProcessedMap.
16.57 -
16.58 - ///This function instantiates a \ref ProcessedMap.
16.59 +
16.60 + ///This function instantiates a \ref ProcessedMap.
16.61 ///\param g is the digraph, to which
16.62 ///we would like to define the \ref ProcessedMap
16.63 #ifdef DOXYGEN
16.64 @@ -80,14 +80,14 @@
16.65 return new ProcessedMap();
16.66 }
16.67 ///The type of the map that indicates which nodes are reached.
16.68 -
16.69 +
16.70 ///The type of the map that indicates which nodes are reached.
16.71 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
16.72 ///\todo named parameter to set this type, function to read and write.
16.73 typedef typename Digraph::template NodeMap<bool> ReachedMap;
16.74 ///Instantiates a ReachedMap.
16.75 -
16.76 - ///This function instantiates a \ref ReachedMap.
16.77 +
16.78 + ///This function instantiates a \ref ReachedMap.
16.79 ///\param G is the digraph, to which
16.80 ///we would like to define the \ref ReachedMap.
16.81 static ReachedMap *createReachedMap(const GR &G)
16.82 @@ -95,23 +95,23 @@
16.83 return new ReachedMap(G);
16.84 }
16.85 ///The type of the map that stores the dists of the nodes.
16.86 -
16.87 +
16.88 ///The type of the map that stores the dists of the nodes.
16.89 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
16.90 ///
16.91 typedef typename Digraph::template NodeMap<int> DistMap;
16.92 ///Instantiates a DistMap.
16.93 -
16.94 - ///This function instantiates a \ref DistMap.
16.95 +
16.96 + ///This function instantiates a \ref DistMap.
16.97 ///\param G is the digraph, to which we would like to define the \ref DistMap
16.98 static DistMap *createDistMap(const GR &G)
16.99 {
16.100 return new DistMap(G);
16.101 }
16.102 };
16.103 -
16.104 +
16.105 ///%BFS algorithm class.
16.106 -
16.107 +
16.108 ///\ingroup search
16.109 ///This class provides an efficient implementation of the %BFS algorithm.
16.110 ///
16.111 @@ -126,10 +126,10 @@
16.112
16.113 #ifdef DOXYGEN
16.114 template <typename GR,
16.115 - typename TR>
16.116 + typename TR>
16.117 #else
16.118 template <typename GR=ListDigraph,
16.119 - typename TR=BfsDefaultTraits<GR> >
16.120 + typename TR=BfsDefaultTraits<GR> >
16.121 #endif
16.122 class Bfs {
16.123 public:
16.124 @@ -142,14 +142,14 @@
16.125 class UninitializedParameter : public lemon::UninitializedParameter {
16.126 public:
16.127 virtual const char* what() const throw() {
16.128 - return "lemon::Bfs::UninitializedParameter";
16.129 + return "lemon::Bfs::UninitializedParameter";
16.130 }
16.131 };
16.132
16.133 typedef TR Traits;
16.134 ///The type of the underlying digraph.
16.135 typedef typename TR::Digraph Digraph;
16.136 -
16.137 +
16.138 ///\brief The type of the map that stores the last
16.139 ///arcs of the shortest paths.
16.140 typedef typename TR::PredMap PredMap;
16.141 @@ -190,34 +190,34 @@
16.142 int _curr_dist;
16.143
16.144 ///Creates the maps if necessary.
16.145 -
16.146 +
16.147 ///\todo Better memory allocation (instead of new).
16.148 - void create_maps()
16.149 + void create_maps()
16.150 {
16.151 if(!_pred) {
16.152 - local_pred = true;
16.153 - _pred = Traits::createPredMap(*G);
16.154 + local_pred = true;
16.155 + _pred = Traits::createPredMap(*G);
16.156 }
16.157 if(!_dist) {
16.158 - local_dist = true;
16.159 - _dist = Traits::createDistMap(*G);
16.160 + local_dist = true;
16.161 + _dist = Traits::createDistMap(*G);
16.162 }
16.163 if(!_reached) {
16.164 - local_reached = true;
16.165 - _reached = Traits::createReachedMap(*G);
16.166 + local_reached = true;
16.167 + _reached = Traits::createReachedMap(*G);
16.168 }
16.169 if(!_processed) {
16.170 - local_processed = true;
16.171 - _processed = Traits::createProcessedMap(*G);
16.172 + local_processed = true;
16.173 + _processed = Traits::createProcessedMap(*G);
16.174 }
16.175 }
16.176
16.177 protected:
16.178 -
16.179 +
16.180 Bfs() {}
16.181 -
16.182 +
16.183 public:
16.184 -
16.185 +
16.186 typedef Bfs Create;
16.187
16.188 ///\name Named template parameters
16.189 @@ -227,9 +227,9 @@
16.190 template <class T>
16.191 struct DefPredMapTraits : public Traits {
16.192 typedef T PredMap;
16.193 - static PredMap *createPredMap(const Digraph &)
16.194 + static PredMap *createPredMap(const Digraph &)
16.195 {
16.196 - throw UninitializedParameter();
16.197 + throw UninitializedParameter();
16.198 }
16.199 };
16.200 ///\brief \ref named-templ-param "Named parameter" for setting
16.201 @@ -238,16 +238,16 @@
16.202 ///\ref named-templ-param "Named parameter" for setting PredMap type
16.203 ///
16.204 template <class T>
16.205 - struct DefPredMap : public Bfs< Digraph, DefPredMapTraits<T> > {
16.206 + struct DefPredMap : public Bfs< Digraph, DefPredMapTraits<T> > {
16.207 typedef Bfs< Digraph, DefPredMapTraits<T> > Create;
16.208 };
16.209 -
16.210 +
16.211 template <class T>
16.212 struct DefDistMapTraits : public Traits {
16.213 typedef T DistMap;
16.214 - static DistMap *createDistMap(const Digraph &)
16.215 + static DistMap *createDistMap(const Digraph &)
16.216 {
16.217 - throw UninitializedParameter();
16.218 + throw UninitializedParameter();
16.219 }
16.220 };
16.221 ///\brief \ref named-templ-param "Named parameter" for setting
16.222 @@ -256,16 +256,16 @@
16.223 ///\ref named-templ-param "Named parameter" for setting DistMap type
16.224 ///
16.225 template <class T>
16.226 - struct DefDistMap : public Bfs< Digraph, DefDistMapTraits<T> > {
16.227 + struct DefDistMap : public Bfs< Digraph, DefDistMapTraits<T> > {
16.228 typedef Bfs< Digraph, DefDistMapTraits<T> > Create;
16.229 };
16.230 -
16.231 +
16.232 template <class T>
16.233 struct DefReachedMapTraits : public Traits {
16.234 typedef T ReachedMap;
16.235 - static ReachedMap *createReachedMap(const Digraph &)
16.236 + static ReachedMap *createReachedMap(const Digraph &)
16.237 {
16.238 - throw UninitializedParameter();
16.239 + throw UninitializedParameter();
16.240 }
16.241 };
16.242 ///\brief \ref named-templ-param "Named parameter" for setting
16.243 @@ -274,16 +274,16 @@
16.244 ///\ref named-templ-param "Named parameter" for setting ReachedMap type
16.245 ///
16.246 template <class T>
16.247 - struct DefReachedMap : public Bfs< Digraph, DefReachedMapTraits<T> > {
16.248 + struct DefReachedMap : public Bfs< Digraph, DefReachedMapTraits<T> > {
16.249 typedef Bfs< Digraph, DefReachedMapTraits<T> > Create;
16.250 };
16.251 -
16.252 +
16.253 template <class T>
16.254 struct DefProcessedMapTraits : public Traits {
16.255 typedef T ProcessedMap;
16.256 - static ProcessedMap *createProcessedMap(const Digraph &)
16.257 + static ProcessedMap *createProcessedMap(const Digraph &)
16.258 {
16.259 - throw UninitializedParameter();
16.260 + throw UninitializedParameter();
16.261 }
16.262 };
16.263 ///\brief \ref named-templ-param "Named parameter" for setting
16.264 @@ -295,12 +295,12 @@
16.265 struct DefProcessedMap : public Bfs< Digraph, DefProcessedMapTraits<T> > {
16.266 typedef Bfs< Digraph, DefProcessedMapTraits<T> > Create;
16.267 };
16.268 -
16.269 +
16.270 struct DefDigraphProcessedMapTraits : public Traits {
16.271 typedef typename Digraph::template NodeMap<bool> ProcessedMap;
16.272 - static ProcessedMap *createProcessedMap(const Digraph &G)
16.273 + static ProcessedMap *createProcessedMap(const Digraph &G)
16.274 {
16.275 - return new ProcessedMap(G);
16.276 + return new ProcessedMap(G);
16.277 }
16.278 };
16.279 ///\brief \ref named-templ-param "Named parameter"
16.280 @@ -311,16 +311,16 @@
16.281 ///If you don't set it explicitly, it will be automatically allocated.
16.282 template <class T>
16.283 struct DefProcessedMapToBeDefaultMap :
16.284 - public Bfs< Digraph, DefDigraphProcessedMapTraits> {
16.285 + public Bfs< Digraph, DefDigraphProcessedMapTraits> {
16.286 typedef Bfs< Digraph, DefDigraphProcessedMapTraits> Create;
16.287 };
16.288 -
16.289 +
16.290 ///@}
16.291
16.292 - public:
16.293 -
16.294 + public:
16.295 +
16.296 ///Constructor.
16.297 -
16.298 +
16.299 ///\param _G the digraph the algorithm will run on.
16.300 ///
16.301 Bfs(const Digraph& _G) :
16.302 @@ -330,9 +330,9 @@
16.303 _reached(NULL), local_reached(false),
16.304 _processed(NULL), local_processed(false)
16.305 { }
16.306 -
16.307 +
16.308 ///Destructor.
16.309 - ~Bfs()
16.310 + ~Bfs()
16.311 {
16.312 if(local_pred) delete _pred;
16.313 if(local_dist) delete _dist;
16.314 @@ -347,11 +347,11 @@
16.315 ///it will allocate one. The destructor deallocates this
16.316 ///automatically allocated map, of course.
16.317 ///\return <tt> (*this) </tt>
16.318 - Bfs &predMap(PredMap &m)
16.319 + Bfs &predMap(PredMap &m)
16.320 {
16.321 if(local_pred) {
16.322 - delete _pred;
16.323 - local_pred=false;
16.324 + delete _pred;
16.325 + local_pred=false;
16.326 }
16.327 _pred = &m;
16.328 return *this;
16.329 @@ -364,11 +364,11 @@
16.330 ///it will allocate one. The destructor deallocates this
16.331 ///automatically allocated map, of course.
16.332 ///\return <tt> (*this) </tt>
16.333 - Bfs &reachedMap(ReachedMap &m)
16.334 + Bfs &reachedMap(ReachedMap &m)
16.335 {
16.336 if(local_reached) {
16.337 - delete _reached;
16.338 - local_reached=false;
16.339 + delete _reached;
16.340 + local_reached=false;
16.341 }
16.342 _reached = &m;
16.343 return *this;
16.344 @@ -381,11 +381,11 @@
16.345 ///it will allocate one. The destructor deallocates this
16.346 ///automatically allocated map, of course.
16.347 ///\return <tt> (*this) </tt>
16.348 - Bfs &processedMap(ProcessedMap &m)
16.349 + Bfs &processedMap(ProcessedMap &m)
16.350 {
16.351 if(local_processed) {
16.352 - delete _processed;
16.353 - local_processed=false;
16.354 + delete _processed;
16.355 + local_processed=false;
16.356 }
16.357 _processed = &m;
16.358 return *this;
16.359 @@ -398,11 +398,11 @@
16.360 ///it will allocate one. The destructor deallocates this
16.361 ///automatically allocated map, of course.
16.362 ///\return <tt> (*this) </tt>
16.363 - Bfs &distMap(DistMap &m)
16.364 + Bfs &distMap(DistMap &m)
16.365 {
16.366 if(local_dist) {
16.367 - delete _dist;
16.368 - local_dist=false;
16.369 + delete _dist;
16.370 + local_dist=false;
16.371 }
16.372 _dist = &m;
16.373 return *this;
16.374 @@ -432,12 +432,12 @@
16.375 _queue_head=_queue_tail=0;
16.376 _curr_dist=1;
16.377 for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
16.378 - _pred->set(u,INVALID);
16.379 - _reached->set(u,false);
16.380 - _processed->set(u,false);
16.381 + _pred->set(u,INVALID);
16.382 + _reached->set(u,false);
16.383 + _processed->set(u,false);
16.384 }
16.385 }
16.386 -
16.387 +
16.388 ///Adds a new source node.
16.389
16.390 ///Adds a new source node to the set of nodes to be processed.
16.391 @@ -445,15 +445,15 @@
16.392 void addSource(Node s)
16.393 {
16.394 if(!(*_reached)[s])
16.395 - {
16.396 - _reached->set(s,true);
16.397 - _pred->set(s,INVALID);
16.398 - _dist->set(s,0);
16.399 - _queue[_queue_head++]=s;
16.400 - _queue_next_dist=_queue_head;
16.401 - }
16.402 + {
16.403 + _reached->set(s,true);
16.404 + _pred->set(s,INVALID);
16.405 + _dist->set(s,0);
16.406 + _queue[_queue_head++]=s;
16.407 + _queue_next_dist=_queue_head;
16.408 + }
16.409 }
16.410 -
16.411 +
16.412 ///Processes the next node.
16.413
16.414 ///Processes the next node.
16.415 @@ -464,19 +464,19 @@
16.416 Node processNextNode()
16.417 {
16.418 if(_queue_tail==_queue_next_dist) {
16.419 - _curr_dist++;
16.420 - _queue_next_dist=_queue_head;
16.421 + _curr_dist++;
16.422 + _queue_next_dist=_queue_head;
16.423 }
16.424 Node n=_queue[_queue_tail++];
16.425 _processed->set(n,true);
16.426 Node m;
16.427 for(OutArcIt e(*G,n);e!=INVALID;++e)
16.428 - if(!(*_reached)[m=G->target(e)]) {
16.429 - _queue[_queue_head++]=m;
16.430 - _reached->set(m,true);
16.431 - _pred->set(m,e);
16.432 - _dist->set(m,_curr_dist);
16.433 - }
16.434 + if(!(*_reached)[m=G->target(e)]) {
16.435 + _queue[_queue_head++]=m;
16.436 + _reached->set(m,true);
16.437 + _pred->set(m,e);
16.438 + _dist->set(m,_curr_dist);
16.439 + }
16.440 return n;
16.441 }
16.442
16.443 @@ -495,20 +495,20 @@
16.444 Node processNextNode(Node target, bool& reach)
16.445 {
16.446 if(_queue_tail==_queue_next_dist) {
16.447 - _curr_dist++;
16.448 - _queue_next_dist=_queue_head;
16.449 + _curr_dist++;
16.450 + _queue_next_dist=_queue_head;
16.451 }
16.452 Node n=_queue[_queue_tail++];
16.453 _processed->set(n,true);
16.454 Node m;
16.455 for(OutArcIt e(*G,n);e!=INVALID;++e)
16.456 - if(!(*_reached)[m=G->target(e)]) {
16.457 - _queue[_queue_head++]=m;
16.458 - _reached->set(m,true);
16.459 - _pred->set(m,e);
16.460 - _dist->set(m,_curr_dist);
16.461 + if(!(*_reached)[m=G->target(e)]) {
16.462 + _queue[_queue_head++]=m;
16.463 + _reached->set(m,true);
16.464 + _pred->set(m,e);
16.465 + _dist->set(m,_curr_dist);
16.466 reach = reach || (target == m);
16.467 - }
16.468 + }
16.469 return n;
16.470 }
16.471
16.472 @@ -528,23 +528,23 @@
16.473 Node processNextNode(const NM& nm, Node& rnode)
16.474 {
16.475 if(_queue_tail==_queue_next_dist) {
16.476 - _curr_dist++;
16.477 - _queue_next_dist=_queue_head;
16.478 + _curr_dist++;
16.479 + _queue_next_dist=_queue_head;
16.480 }
16.481 Node n=_queue[_queue_tail++];
16.482 _processed->set(n,true);
16.483 Node m;
16.484 for(OutArcIt e(*G,n);e!=INVALID;++e)
16.485 - if(!(*_reached)[m=G->target(e)]) {
16.486 - _queue[_queue_head++]=m;
16.487 - _reached->set(m,true);
16.488 - _pred->set(m,e);
16.489 - _dist->set(m,_curr_dist);
16.490 - if (nm[m] && rnode == INVALID) rnode = m;
16.491 - }
16.492 + if(!(*_reached)[m=G->target(e)]) {
16.493 + _queue[_queue_head++]=m;
16.494 + _reached->set(m,true);
16.495 + _pred->set(m,e);
16.496 + _dist->set(m,_curr_dist);
16.497 + if (nm[m] && rnode == INVALID) rnode = m;
16.498 + }
16.499 return n;
16.500 }
16.501 -
16.502 +
16.503 ///Next node to be processed.
16.504
16.505 ///Next node to be processed.
16.506 @@ -552,10 +552,10 @@
16.507 ///\return The next node to be processed or INVALID if the queue is
16.508 /// empty.
16.509 Node nextNode()
16.510 - {
16.511 + {
16.512 return _queue_tail<_queue_head?_queue[_queue_tail]:INVALID;
16.513 }
16.514 -
16.515 +
16.516 ///\brief Returns \c false if there are nodes
16.517 ///to be processed in the queue
16.518 ///
16.519 @@ -563,10 +563,10 @@
16.520 ///to be processed in the queue
16.521 bool emptyQueue() { return _queue_tail==_queue_head; }
16.522 ///Returns the number of the nodes to be processed.
16.523 -
16.524 +
16.525 ///Returns the number of the nodes to be processed in the queue.
16.526 int queueSize() { return _queue_head-_queue_tail; }
16.527 -
16.528 +
16.529 ///Executes the algorithm.
16.530
16.531 ///Executes the algorithm.
16.532 @@ -584,7 +584,7 @@
16.533 {
16.534 while ( !emptyQueue() ) processNextNode();
16.535 }
16.536 -
16.537 +
16.538 ///Executes the algorithm until \c dest is reached.
16.539
16.540 ///Executes the algorithm until \c dest is reached.
16.541 @@ -602,7 +602,7 @@
16.542 bool reach = false;
16.543 while ( !emptyQueue() && !reach ) processNextNode(dest, reach);
16.544 }
16.545 -
16.546 +
16.547 ///Executes the algorithm until a condition is met.
16.548
16.549 ///Executes the algorithm until a condition is met.
16.550 @@ -621,13 +621,13 @@
16.551 {
16.552 Node rnode = INVALID;
16.553 while ( !emptyQueue() && rnode == INVALID ) {
16.554 - processNextNode(nm, rnode);
16.555 + processNextNode(nm, rnode);
16.556 }
16.557 return rnode;
16.558 }
16.559 -
16.560 +
16.561 ///Runs %BFS algorithm from node \c s.
16.562 -
16.563 +
16.564 ///This method runs the %BFS algorithm from a root node \c s
16.565 ///in order to
16.566 ///compute the
16.567 @@ -646,9 +646,9 @@
16.568 addSource(s);
16.569 start();
16.570 }
16.571 -
16.572 +
16.573 ///Finds the shortest path between \c s and \c t.
16.574 -
16.575 +
16.576 ///Finds the shortest path between \c s and \c t.
16.577 ///
16.578 ///\return The length of the shortest s---t path if there exists one,
16.579 @@ -666,7 +666,7 @@
16.580 start(t);
16.581 return reached(t) ? _curr_dist : 0;
16.582 }
16.583 -
16.584 +
16.585 ///@}
16.586
16.587 ///\name Query Functions
16.588 @@ -674,16 +674,16 @@
16.589 ///functions.\n
16.590 ///Before the use of these functions,
16.591 ///either run() or start() must be calleb.
16.592 -
16.593 +
16.594 ///@{
16.595
16.596 typedef PredMapPath<Digraph, PredMap> Path;
16.597
16.598 ///Gives back the shortest path.
16.599 -
16.600 +
16.601 ///Gives back the shortest path.
16.602 ///\pre The \c t should be reachable from the source.
16.603 - Path path(Node t)
16.604 + Path path(Node t)
16.605 {
16.606 return Path(*G, *_pred, t);
16.607 }
16.608 @@ -722,15 +722,15 @@
16.609 ///\pre Either \ref run() or \ref start() must be called before
16.610 ///using this function.
16.611 Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
16.612 - G->source((*_pred)[v]); }
16.613 -
16.614 + G->source((*_pred)[v]); }
16.615 +
16.616 ///Returns a reference to the NodeMap of distances.
16.617
16.618 ///Returns a reference to the NodeMap of distances.
16.619 ///\pre Either \ref run() or \ref init() must
16.620 ///be called before using this function.
16.621 const DistMap &distMap() const { return *_dist;}
16.622 -
16.623 +
16.624 ///Returns a reference to the shortest path tree map.
16.625
16.626 ///Returns a reference to the NodeMap of the arcs of the
16.627 @@ -738,7 +738,7 @@
16.628 ///\pre Either \ref run() or \ref init()
16.629 ///must be called before using this function.
16.630 const PredMap &predMap() const { return *_pred;}
16.631 -
16.632 +
16.633 ///Checks if a node is reachable from the root.
16.634
16.635 ///Returns \c true if \c v is reachable from the root.
16.636 @@ -747,7 +747,7 @@
16.637 ///must be called before using this function.
16.638 ///
16.639 bool reached(Node v) { return (*_reached)[v]; }
16.640 -
16.641 +
16.642 ///@}
16.643 };
16.644
16.645 @@ -758,39 +758,39 @@
16.646 template<class GR>
16.647 struct BfsWizardDefaultTraits
16.648 {
16.649 - ///The digraph type the algorithm runs on.
16.650 + ///The digraph type the algorithm runs on.
16.651 typedef GR Digraph;
16.652 ///\brief The type of the map that stores the last
16.653 ///arcs of the shortest paths.
16.654 - ///
16.655 + ///
16.656 ///The type of the map that stores the last
16.657 ///arcs of the shortest paths.
16.658 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
16.659 ///
16.660 typedef NullMap<typename Digraph::Node,typename GR::Arc> PredMap;
16.661 ///Instantiates a PredMap.
16.662 -
16.663 - ///This function instantiates a \ref PredMap.
16.664 +
16.665 + ///This function instantiates a \ref PredMap.
16.666 ///\param g is the digraph, to which we would like to define the PredMap.
16.667 ///\todo The digraph alone may be insufficient to initialize
16.668 #ifdef DOXYGEN
16.669 - static PredMap *createPredMap(const GR &g)
16.670 + static PredMap *createPredMap(const GR &g)
16.671 #else
16.672 - static PredMap *createPredMap(const GR &)
16.673 + static PredMap *createPredMap(const GR &)
16.674 #endif
16.675 {
16.676 return new PredMap();
16.677 }
16.678
16.679 ///The type of the map that indicates which nodes are processed.
16.680 -
16.681 +
16.682 ///The type of the map that indicates which nodes are processed.
16.683 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
16.684 ///\todo named parameter to set this type, function to read and write.
16.685 typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
16.686 ///Instantiates a ProcessedMap.
16.687 -
16.688 - ///This function instantiates a \ref ProcessedMap.
16.689 +
16.690 + ///This function instantiates a \ref ProcessedMap.
16.691 ///\param g is the digraph, to which
16.692 ///we would like to define the \ref ProcessedMap
16.693 #ifdef DOXYGEN
16.694 @@ -802,14 +802,14 @@
16.695 return new ProcessedMap();
16.696 }
16.697 ///The type of the map that indicates which nodes are reached.
16.698 -
16.699 +
16.700 ///The type of the map that indicates which nodes are reached.
16.701 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
16.702 ///\todo named parameter to set this type, function to read and write.
16.703 typedef typename Digraph::template NodeMap<bool> ReachedMap;
16.704 ///Instantiates a ReachedMap.
16.705 -
16.706 - ///This function instantiates a \ref ReachedMap.
16.707 +
16.708 + ///This function instantiates a \ref ReachedMap.
16.709 ///\param G is the digraph, to which
16.710 ///we would like to define the \ref ReachedMap.
16.711 static ReachedMap *createReachedMap(const GR &G)
16.712 @@ -817,14 +817,14 @@
16.713 return new ReachedMap(G);
16.714 }
16.715 ///The type of the map that stores the dists of the nodes.
16.716 -
16.717 +
16.718 ///The type of the map that stores the dists of the nodes.
16.719 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
16.720 ///
16.721 typedef NullMap<typename Digraph::Node,int> DistMap;
16.722 ///Instantiates a DistMap.
16.723 -
16.724 - ///This function instantiates a \ref DistMap.
16.725 +
16.726 + ///This function instantiates a \ref DistMap.
16.727 ///\param g is the digraph, to which we would like to define the \ref DistMap
16.728 #ifdef DOXYGEN
16.729 static DistMap *createDistMap(const GR &g)
16.730 @@ -835,7 +835,7 @@
16.731 return new DistMap();
16.732 }
16.733 };
16.734 -
16.735 +
16.736 /// Default traits used by \ref BfsWizard
16.737
16.738 /// To make it easier to use Bfs algorithm
16.739 @@ -865,28 +865,28 @@
16.740 void *_dist;
16.741 ///Pointer to the source node.
16.742 Node _source;
16.743 -
16.744 +
16.745 public:
16.746 /// Constructor.
16.747 -
16.748 +
16.749 /// This constructor does not require parameters, therefore it initiates
16.750 /// all of the attributes to default values (0, INVALID).
16.751 BfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
16.752 - _dist(0), _source(INVALID) {}
16.753 + _dist(0), _source(INVALID) {}
16.754
16.755 /// Constructor.
16.756 -
16.757 +
16.758 /// This constructor requires some parameters,
16.759 /// listed in the parameters list.
16.760 /// Others are initiated to 0.
16.761 /// \param g is the initial value of \ref _g
16.762 /// \param s is the initial value of \ref _source
16.763 BfsWizardBase(const GR &g, Node s=INVALID) :
16.764 - _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
16.765 + _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
16.766 _reached(0), _processed(0), _pred(0), _dist(0), _source(s) {}
16.767
16.768 };
16.769 -
16.770 +
16.771 /// A class to make the usage of Bfs algorithm easier
16.772
16.773 /// This class is created to make it easier to use Bfs algorithm.
16.774 @@ -921,7 +921,7 @@
16.775 typedef typename Digraph::Arc Arc;
16.776 //\e
16.777 typedef typename Digraph::OutArcIt OutArcIt;
16.778 -
16.779 +
16.780 ///\brief The type of the map that stores
16.781 ///the reached nodes
16.782 typedef typename TR::ReachedMap ReachedMap;
16.783 @@ -951,7 +951,7 @@
16.784 ~BfsWizard() {}
16.785
16.786 ///Runs Bfs algorithm from a given node.
16.787 -
16.788 +
16.789 ///Runs Bfs algorithm from a given node.
16.790 ///The node can be given by the \ref source function.
16.791 void run()
16.792 @@ -959,12 +959,12 @@
16.793 if(Base::_source==INVALID) throw UninitializedParameter();
16.794 Bfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
16.795 if(Base::_reached)
16.796 - alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
16.797 - if(Base::_processed)
16.798 + alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
16.799 + if(Base::_processed)
16.800 alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
16.801 - if(Base::_pred)
16.802 + if(Base::_pred)
16.803 alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
16.804 - if(Base::_dist)
16.805 + if(Base::_dist)
16.806 alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
16.807 alg.run(Base::_source);
16.808 }
16.809 @@ -985,7 +985,7 @@
16.810 static PredMap *createPredMap(const Digraph &) { return 0; };
16.811 DefPredMapBase(const TR &b) : TR(b) {}
16.812 };
16.813 -
16.814 +
16.815 ///\brief \ref named-templ-param "Named parameter"
16.816 ///function for setting PredMap
16.817 ///
16.818 @@ -993,20 +993,20 @@
16.819 ///function for setting PredMap
16.820 ///
16.821 template<class T>
16.822 - BfsWizard<DefPredMapBase<T> > predMap(const T &t)
16.823 + BfsWizard<DefPredMapBase<T> > predMap(const T &t)
16.824 {
16.825 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
16.826 return BfsWizard<DefPredMapBase<T> >(*this);
16.827 }
16.828 -
16.829 -
16.830 +
16.831 +
16.832 template<class T>
16.833 struct DefReachedMapBase : public Base {
16.834 typedef T ReachedMap;
16.835 static ReachedMap *createReachedMap(const Digraph &) { return 0; };
16.836 DefReachedMapBase(const TR &b) : TR(b) {}
16.837 };
16.838 -
16.839 +
16.840 ///\brief \ref named-templ-param "Named parameter"
16.841 ///function for setting ReachedMap
16.842 ///
16.843 @@ -1014,12 +1014,12 @@
16.844 ///function for setting ReachedMap
16.845 ///
16.846 template<class T>
16.847 - BfsWizard<DefReachedMapBase<T> > reachedMap(const T &t)
16.848 + BfsWizard<DefReachedMapBase<T> > reachedMap(const T &t)
16.849 {
16.850 Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t));
16.851 return BfsWizard<DefReachedMapBase<T> >(*this);
16.852 }
16.853 -
16.854 +
16.855
16.856 template<class T>
16.857 struct DefProcessedMapBase : public Base {
16.858 @@ -1027,7 +1027,7 @@
16.859 static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
16.860 DefProcessedMapBase(const TR &b) : TR(b) {}
16.861 };
16.862 -
16.863 +
16.864 ///\brief \ref named-templ-param "Named parameter"
16.865 ///function for setting ProcessedMap
16.866 ///
16.867 @@ -1035,20 +1035,20 @@
16.868 ///function for setting ProcessedMap
16.869 ///
16.870 template<class T>
16.871 - BfsWizard<DefProcessedMapBase<T> > processedMap(const T &t)
16.872 + BfsWizard<DefProcessedMapBase<T> > processedMap(const T &t)
16.873 {
16.874 Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
16.875 return BfsWizard<DefProcessedMapBase<T> >(*this);
16.876 }
16.877 -
16.878 -
16.879 +
16.880 +
16.881 template<class T>
16.882 struct DefDistMapBase : public Base {
16.883 typedef T DistMap;
16.884 static DistMap *createDistMap(const Digraph &) { return 0; };
16.885 DefDistMapBase(const TR &b) : TR(b) {}
16.886 };
16.887 -
16.888 +
16.889 ///\brief \ref named-templ-param "Named parameter"
16.890 ///function for setting DistMap type
16.891 ///
16.892 @@ -1056,24 +1056,24 @@
16.893 ///function for setting DistMap type
16.894 ///
16.895 template<class T>
16.896 - BfsWizard<DefDistMapBase<T> > distMap(const T &t)
16.897 + BfsWizard<DefDistMapBase<T> > distMap(const T &t)
16.898 {
16.899 Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
16.900 return BfsWizard<DefDistMapBase<T> >(*this);
16.901 }
16.902 -
16.903 +
16.904 /// Sets the source node, from which the Bfs algorithm runs.
16.905
16.906 /// Sets the source node, from which the Bfs algorithm runs.
16.907 /// \param s is the source node.
16.908 - BfsWizard<TR> &source(Node s)
16.909 + BfsWizard<TR> &source(Node s)
16.910 {
16.911 Base::_source=s;
16.912 return *this;
16.913 }
16.914 -
16.915 +
16.916 };
16.917 -
16.918 +
16.919 ///Function type interface for Bfs algorithm.
16.920
16.921 /// \ingroup search
16.922 @@ -1100,7 +1100,7 @@
16.923
16.924 #ifdef DOXYGEN
16.925 /// \brief Visitor class for bfs.
16.926 - ///
16.927 + ///
16.928 /// This class defines the interface of the BfsVisit events, and
16.929 /// it could be the base of a real Visitor class.
16.930 template <typename _Digraph>
16.931 @@ -1109,26 +1109,26 @@
16.932 typedef typename Digraph::Arc Arc;
16.933 typedef typename Digraph::Node Node;
16.934 /// \brief Called when the arc reach a node.
16.935 - ///
16.936 + ///
16.937 /// It is called when the bfs find an arc which target is not
16.938 /// reached yet.
16.939 void discover(const Arc& arc) {}
16.940 /// \brief Called when the node reached first time.
16.941 - ///
16.942 + ///
16.943 /// It is Called when the node reached first time.
16.944 void reach(const Node& node) {}
16.945 - /// \brief Called when the arc examined but target of the arc
16.946 + /// \brief Called when the arc examined but target of the arc
16.947 /// already discovered.
16.948 - ///
16.949 - /// It called when the arc examined but the target of the arc
16.950 + ///
16.951 + /// It called when the arc examined but the target of the arc
16.952 /// already discovered.
16.953 void examine(const Arc& arc) {}
16.954 /// \brief Called for the source node of the bfs.
16.955 - ///
16.956 + ///
16.957 /// It is called for the source node of the bfs.
16.958 void start(const Node& node) {}
16.959 /// \brief Called when the node processed.
16.960 - ///
16.961 + ///
16.962 /// It is Called when the node processed.
16.963 void process(const Node& node) {}
16.964 };
16.965 @@ -1147,12 +1147,12 @@
16.966 template <typename _Visitor>
16.967 struct Constraints {
16.968 void constraints() {
16.969 - Arc arc;
16.970 - Node node;
16.971 - visitor.discover(arc);
16.972 - visitor.reach(node);
16.973 - visitor.examine(arc);
16.974 - visitor.start(node);
16.975 + Arc arc;
16.976 + Node node;
16.977 + visitor.discover(arc);
16.978 + visitor.reach(node);
16.979 + visitor.examine(arc);
16.980 + visitor.start(node);
16.981 visitor.process(node);
16.982 }
16.983 _Visitor& visitor;
16.984 @@ -1167,11 +1167,11 @@
16.985 template<class _Digraph>
16.986 struct BfsVisitDefaultTraits {
16.987
16.988 - /// \brief The digraph type the algorithm runs on.
16.989 + /// \brief The digraph type the algorithm runs on.
16.990 typedef _Digraph Digraph;
16.991
16.992 /// \brief The type of the map that indicates which nodes are reached.
16.993 - ///
16.994 + ///
16.995 /// The type of the map that indicates which nodes are reached.
16.996 /// It must meet the \ref concepts::WriteMap "WriteMap" concept.
16.997 /// \todo named parameter to set this type, function to read and write.
16.998 @@ -1179,7 +1179,7 @@
16.999
16.1000 /// \brief Instantiates a ReachedMap.
16.1001 ///
16.1002 - /// This function instantiates a \ref ReachedMap.
16.1003 + /// This function instantiates a \ref ReachedMap.
16.1004 /// \param digraph is the digraph, to which
16.1005 /// we would like to define the \ref ReachedMap.
16.1006 static ReachedMap *createReachedMap(const Digraph &digraph) {
16.1007 @@ -1189,24 +1189,24 @@
16.1008 };
16.1009
16.1010 /// \ingroup search
16.1011 - ///
16.1012 + ///
16.1013 /// \brief %BFS Visit algorithm class.
16.1014 - ///
16.1015 + ///
16.1016 /// This class provides an efficient implementation of the %BFS algorithm
16.1017 /// with visitor interface.
16.1018 ///
16.1019 /// The %BfsVisit class provides an alternative interface to the Bfs
16.1020 /// class. It works with callback mechanism, the BfsVisit object calls
16.1021 - /// on every bfs event the \c Visitor class member functions.
16.1022 + /// on every bfs event the \c Visitor class member functions.
16.1023 ///
16.1024 /// \tparam _Digraph The digraph type the algorithm runs on. The default value is
16.1025 /// \ref ListDigraph. The value of _Digraph is not used directly by Bfs, it
16.1026 /// is only passed to \ref BfsDefaultTraits.
16.1027 - /// \tparam _Visitor The Visitor object for the algorithm. The
16.1028 + /// \tparam _Visitor The Visitor object for the algorithm. The
16.1029 /// \ref BfsVisitor "BfsVisitor<_Digraph>" is an empty Visitor which
16.1030 /// does not observe the Bfs events. If you want to observe the bfs
16.1031 /// events you should implement your own Visitor class.
16.1032 - /// \tparam _Traits Traits class to set various data types used by the
16.1033 + /// \tparam _Traits Traits class to set various data types used by the
16.1034 /// algorithm. The default traits class is
16.1035 /// \ref BfsVisitDefaultTraits "BfsVisitDefaultTraits<_Digraph>".
16.1036 /// See \ref BfsVisitDefaultTraits for the documentation of
16.1037 @@ -1215,21 +1215,21 @@
16.1038 template <typename _Digraph, typename _Visitor, typename _Traits>
16.1039 #else
16.1040 template <typename _Digraph = ListDigraph,
16.1041 - typename _Visitor = BfsVisitor<_Digraph>,
16.1042 - typename _Traits = BfsDefaultTraits<_Digraph> >
16.1043 + typename _Visitor = BfsVisitor<_Digraph>,
16.1044 + typename _Traits = BfsDefaultTraits<_Digraph> >
16.1045 #endif
16.1046 class BfsVisit {
16.1047 public:
16.1048 -
16.1049 +
16.1050 /// \brief \ref Exception for uninitialized parameters.
16.1051 ///
16.1052 /// This error represents problems in the initialization
16.1053 /// of the parameters of the algorithms.
16.1054 class UninitializedParameter : public lemon::UninitializedParameter {
16.1055 public:
16.1056 - virtual const char* what() const throw()
16.1057 + virtual const char* what() const throw()
16.1058 {
16.1059 - return "lemon::BfsVisit::UninitializedParameter";
16.1060 + return "lemon::BfsVisit::UninitializedParameter";
16.1061 }
16.1062 };
16.1063
16.1064 @@ -1266,15 +1266,15 @@
16.1065 /// Creates the maps if necessary.
16.1066 void create_maps() {
16.1067 if(!_reached) {
16.1068 - local_reached = true;
16.1069 - _reached = Traits::createReachedMap(*_digraph);
16.1070 + local_reached = true;
16.1071 + _reached = Traits::createReachedMap(*_digraph);
16.1072 }
16.1073 }
16.1074
16.1075 protected:
16.1076
16.1077 BfsVisit() {}
16.1078 -
16.1079 +
16.1080 public:
16.1081
16.1082 typedef BfsVisit Create;
16.1083 @@ -1286,22 +1286,22 @@
16.1084 struct DefReachedMapTraits : public Traits {
16.1085 typedef T ReachedMap;
16.1086 static ReachedMap *createReachedMap(const Digraph &digraph) {
16.1087 - throw UninitializedParameter();
16.1088 + throw UninitializedParameter();
16.1089 }
16.1090 };
16.1091 - /// \brief \ref named-templ-param "Named parameter" for setting
16.1092 + /// \brief \ref named-templ-param "Named parameter" for setting
16.1093 /// ReachedMap type
16.1094 ///
16.1095 /// \ref named-templ-param "Named parameter" for setting ReachedMap type
16.1096 template <class T>
16.1097 struct DefReachedMap : public BfsVisit< Digraph, Visitor,
16.1098 - DefReachedMapTraits<T> > {
16.1099 + DefReachedMapTraits<T> > {
16.1100 typedef BfsVisit< Digraph, Visitor, DefReachedMapTraits<T> > Create;
16.1101 };
16.1102 ///@}
16.1103
16.1104 - public:
16.1105 -
16.1106 + public:
16.1107 +
16.1108 /// \brief Constructor.
16.1109 ///
16.1110 /// Constructor.
16.1111 @@ -1309,10 +1309,10 @@
16.1112 /// \param digraph the digraph the algorithm will run on.
16.1113 /// \param visitor The visitor of the algorithm.
16.1114 ///
16.1115 - BfsVisit(const Digraph& digraph, Visitor& visitor)
16.1116 + BfsVisit(const Digraph& digraph, Visitor& visitor)
16.1117 : _digraph(&digraph), _visitor(&visitor),
16.1118 - _reached(0), local_reached(false) {}
16.1119 -
16.1120 + _reached(0), local_reached(false) {}
16.1121 +
16.1122 /// \brief Destructor.
16.1123 ///
16.1124 /// Destructor.
16.1125 @@ -1329,8 +1329,8 @@
16.1126 /// \return <tt> (*this) </tt>
16.1127 BfsVisit &reachedMap(ReachedMap &m) {
16.1128 if(local_reached) {
16.1129 - delete _reached;
16.1130 - local_reached = false;
16.1131 + delete _reached;
16.1132 + local_reached = false;
16.1133 }
16.1134 _reached = &m;
16.1135 return *this;
16.1136 @@ -1357,22 +1357,22 @@
16.1137 _list.resize(countNodes(*_digraph));
16.1138 _list_front = _list_back = -1;
16.1139 for (NodeIt u(*_digraph) ; u != INVALID ; ++u) {
16.1140 - _reached->set(u, false);
16.1141 + _reached->set(u, false);
16.1142 }
16.1143 }
16.1144 -
16.1145 +
16.1146 /// \brief Adds a new source node.
16.1147 ///
16.1148 /// Adds a new source node to the set of nodes to be processed.
16.1149 void addSource(Node s) {
16.1150 if(!(*_reached)[s]) {
16.1151 - _reached->set(s,true);
16.1152 - _visitor->start(s);
16.1153 - _visitor->reach(s);
16.1154 + _reached->set(s,true);
16.1155 + _visitor->start(s);
16.1156 + _visitor->reach(s);
16.1157 _list[++_list_back] = s;
16.1158 - }
16.1159 + }
16.1160 }
16.1161 -
16.1162 +
16.1163 /// \brief Processes the next node.
16.1164 ///
16.1165 /// Processes the next node.
16.1166 @@ -1380,7 +1380,7 @@
16.1167 /// \return The processed node.
16.1168 ///
16.1169 /// \pre The queue must not be empty!
16.1170 - Node processNextNode() {
16.1171 + Node processNextNode() {
16.1172 Node n = _list[++_list_front];
16.1173 _visitor->process(n);
16.1174 Arc e;
16.1175 @@ -1467,7 +1467,7 @@
16.1176 ///
16.1177 /// \return The next node to be processed or INVALID if the stack is
16.1178 /// empty.
16.1179 - Node nextNode() {
16.1180 + Node nextNode() {
16.1181 return _list_front != _list_back ? _list[_list_front + 1] : INVALID;
16.1182 }
16.1183
16.1184 @@ -1482,7 +1482,7 @@
16.1185 ///
16.1186 /// Returns the number of the nodes to be processed in the queue.
16.1187 int queueSize() { return _list_back - _list_front; }
16.1188 -
16.1189 +
16.1190 /// \brief Executes the algorithm.
16.1191 ///
16.1192 /// Executes the algorithm.
16.1193 @@ -1492,7 +1492,7 @@
16.1194 void start() {
16.1195 while ( !emptyQueue() ) processNextNode();
16.1196 }
16.1197 -
16.1198 +
16.1199 /// \brief Executes the algorithm until \c dest is reached.
16.1200 ///
16.1201 /// Executes the algorithm until \c dest is reached.
16.1202 @@ -1503,7 +1503,7 @@
16.1203 bool reach = false;
16.1204 while ( !emptyQueue() && !reach ) processNextNode(dest, reach);
16.1205 }
16.1206 -
16.1207 +
16.1208 /// \brief Executes the algorithm until a condition is met.
16.1209 ///
16.1210 /// Executes the algorithm until a condition is met.
16.1211 @@ -1521,7 +1521,7 @@
16.1212 Node start(const NM &nm) {
16.1213 Node rnode = INVALID;
16.1214 while ( !emptyQueue() && rnode == INVALID ) {
16.1215 - processNextNode(nm, rnode);
16.1216 + processNextNode(nm, rnode);
16.1217 }
16.1218 return rnode;
16.1219 }
16.1220 @@ -1542,7 +1542,7 @@
16.1221 }
16.1222
16.1223 /// \brief Runs %BFSVisit algorithm to visit all nodes in the digraph.
16.1224 - ///
16.1225 + ///
16.1226 /// This method runs the %BFS algorithm in order to
16.1227 /// compute the %BFS path to each node. The algorithm computes
16.1228 /// - The %BFS tree.
17.1 --- a/lemon/bin_heap.h Sun Jul 13 16:46:56 2008 +0100
17.2 +++ b/lemon/bin_heap.h Sun Jul 13 19:51:02 2008 +0100
17.3 @@ -1,6 +1,6 @@
17.4 -/* -*- C++ -*-
17.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
17.6 *
17.7 - * This file is a part of LEMON, a generic C++ optimization library
17.8 + * This file is a part of LEMON, a generic C++ optimization library.
17.9 *
17.10 * Copyright (C) 2003-2008
17.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
17.12 @@ -48,7 +48,7 @@
17.13 ///\sa FibHeap
17.14 ///\sa Dijkstra
17.15 template <typename _Prio, typename _ItemIntMap,
17.16 - typename _Compare = std::less<_Prio> >
17.17 + typename _Compare = std::less<_Prio> >
17.18 class BinHeap {
17.19
17.20 public:
17.21 @@ -90,7 +90,7 @@
17.22 /// internally to handle the cross references. The value of the map
17.23 /// should be PRE_HEAP (-1) for each element.
17.24 explicit BinHeap(ItemIntMap &_iim) : iim(_iim) {}
17.25 -
17.26 +
17.27 /// \brief The constructor.
17.28 ///
17.29 /// The constructor.
17.30 @@ -99,7 +99,7 @@
17.31 /// should be PRE_HEAP (-1) for each element.
17.32 ///
17.33 /// \param _comp The comparator function object.
17.34 - BinHeap(ItemIntMap &_iim, const Compare &_comp)
17.35 + BinHeap(ItemIntMap &_iim, const Compare &_comp)
17.36 : iim(_iim), comp(_comp) {}
17.37
17.38
17.39 @@ -107,20 +107,20 @@
17.40 ///
17.41 /// \brief Returns the number of items stored in the heap.
17.42 int size() const { return data.size(); }
17.43 -
17.44 +
17.45 /// \brief Checks if the heap stores no items.
17.46 ///
17.47 /// Returns \c true if and only if the heap stores no items.
17.48 bool empty() const { return data.empty(); }
17.49
17.50 /// \brief Make empty this heap.
17.51 - ///
17.52 + ///
17.53 /// Make empty this heap. It does not change the cross reference map.
17.54 /// If you want to reuse what is not surely empty you should first clear
17.55 /// the heap and after that you should set the cross reference map for
17.56 /// each item to \c PRE_HEAP.
17.57 - void clear() {
17.58 - data.clear();
17.59 + void clear() {
17.60 + data.clear();
17.61 }
17.62
17.63 private:
17.64 @@ -134,9 +134,9 @@
17.65 int bubble_up(int hole, Pair p) {
17.66 int par = parent(hole);
17.67 while( hole>0 && less(p,data[par]) ) {
17.68 - move(data[par],hole);
17.69 - hole = par;
17.70 - par = parent(hole);
17.71 + move(data[par],hole);
17.72 + hole = par;
17.73 + par = parent(hole);
17.74 }
17.75 move(p, hole);
17.76 return hole;
17.77 @@ -145,19 +145,19 @@
17.78 int bubble_down(int hole, Pair p, int length) {
17.79 int child = second_child(hole);
17.80 while(child < length) {
17.81 - if( less(data[child-1], data[child]) ) {
17.82 - --child;
17.83 - }
17.84 - if( !less(data[child], p) )
17.85 - goto ok;
17.86 - move(data[child], hole);
17.87 - hole = child;
17.88 - child = second_child(hole);
17.89 + if( less(data[child-1], data[child]) ) {
17.90 + --child;
17.91 + }
17.92 + if( !less(data[child], p) )
17.93 + goto ok;
17.94 + move(data[child], hole);
17.95 + hole = child;
17.96 + child = second_child(hole);
17.97 }
17.98 child--;
17.99 if( child<length && less(data[child], p) ) {
17.100 - move(data[child], hole);
17.101 - hole=child;
17.102 + move(data[child], hole);
17.103 + hole=child;
17.104 }
17.105 ok:
17.106 move(p, hole);
17.107 @@ -181,8 +181,8 @@
17.108 }
17.109
17.110 /// \brief Insert an item into the heap with the given heap.
17.111 - ///
17.112 - /// Adds \c i to the heap with priority \c p.
17.113 + ///
17.114 + /// Adds \c i to the heap with priority \c p.
17.115 /// \param i The item to insert.
17.116 /// \param p The priority of the item.
17.117 void push(const Item &i, const Prio &p) { push(Pair(i,p)); }
17.118 @@ -190,8 +190,8 @@
17.119 /// \brief Returns the item with minimum priority relative to \c Compare.
17.120 ///
17.121 /// This method returns the item with minimum priority relative to \c
17.122 - /// Compare.
17.123 - /// \pre The heap must be nonempty.
17.124 + /// Compare.
17.125 + /// \pre The heap must be nonempty.
17.126 Item top() const {
17.127 return data[0].first;
17.128 }
17.129 @@ -207,13 +207,13 @@
17.130 /// \brief Deletes the item with minimum priority relative to \c Compare.
17.131 ///
17.132 /// This method deletes the item with minimum priority relative to \c
17.133 - /// Compare from the heap.
17.134 - /// \pre The heap must be non-empty.
17.135 + /// Compare from the heap.
17.136 + /// \pre The heap must be non-empty.
17.137 void pop() {
17.138 int n = data.size()-1;
17.139 iim.set(data[0].first, POST_HEAP);
17.140 if (n > 0) {
17.141 - bubble_down(0, data[n], n);
17.142 + bubble_down(0, data[n], n);
17.143 }
17.144 data.pop_back();
17.145 }
17.146 @@ -228,17 +228,17 @@
17.147 int n = data.size()-1;
17.148 iim.set(data[h].first, POST_HEAP);
17.149 if( h < n ) {
17.150 - if ( bubble_up(h, data[n]) == h) {
17.151 - bubble_down(h, data[n], n);
17.152 - }
17.153 + if ( bubble_up(h, data[n]) == h) {
17.154 + bubble_down(h, data[n], n);
17.155 + }
17.156 }
17.157 data.pop_back();
17.158 }
17.159
17.160 -
17.161 +
17.162 /// \brief Returns the priority of \c i.
17.163 ///
17.164 - /// This function returns the priority of item \c i.
17.165 + /// This function returns the priority of item \c i.
17.166 /// \pre \c i must be in the heap.
17.167 /// \param i The item.
17.168 Prio operator[](const Item &i) const {
17.169 @@ -246,7 +246,7 @@
17.170 return data[idx].second;
17.171 }
17.172
17.173 - /// \brief \c i gets to the heap with priority \c p independently
17.174 + /// \brief \c i gets to the heap with priority \c p independently
17.175 /// if \c i was already there.
17.176 ///
17.177 /// This method calls \ref push(\c i, \c p) if \c i is not stored
17.178 @@ -256,13 +256,13 @@
17.179 void set(const Item &i, const Prio &p) {
17.180 int idx = iim[i];
17.181 if( idx < 0 ) {
17.182 - push(i,p);
17.183 + push(i,p);
17.184 }
17.185 else if( comp(p, data[idx].second) ) {
17.186 - bubble_up(idx, Pair(i,p));
17.187 + bubble_up(idx, Pair(i,p));
17.188 }
17.189 else {
17.190 - bubble_down(idx, Pair(i,p), data.size());
17.191 + bubble_down(idx, Pair(i,p), data.size());
17.192 }
17.193 }
17.194
17.195 @@ -277,10 +277,10 @@
17.196 int idx = iim[i];
17.197 bubble_up(idx, Pair(i,p));
17.198 }
17.199 -
17.200 +
17.201 /// \brief Increases the priority of \c i to \c p.
17.202 ///
17.203 - /// This method sets the priority of item \c i to \c p.
17.204 + /// This method sets the priority of item \c i to \c p.
17.205 /// \pre \c i must be stored in the heap with priority at most \c
17.206 /// p relative to \c Compare.
17.207 /// \param i The item.
17.208 @@ -290,7 +290,7 @@
17.209 bubble_down(idx, Pair(i,p), data.size());
17.210 }
17.211
17.212 - /// \brief Returns if \c item is in, has already been in, or has
17.213 + /// \brief Returns if \c item is in, has already been in, or has
17.214 /// never been in the heap.
17.215 ///
17.216 /// This method returns PRE_HEAP if \c item has never been in the
17.217 @@ -301,7 +301,7 @@
17.218 State state(const Item &i) const {
17.219 int s = iim[i];
17.220 if( s>=0 )
17.221 - s=0;
17.222 + s=0;
17.223 return State(s);
17.224 }
17.225
17.226 @@ -311,7 +311,7 @@
17.227 /// manually clear the heap when it is important to achive the
17.228 /// better time complexity.
17.229 /// \param i The item.
17.230 - /// \param st The state. It should not be \c IN_HEAP.
17.231 + /// \param st The state. It should not be \c IN_HEAP.
17.232 void state(const Item& i, State st) {
17.233 switch (st) {
17.234 case POST_HEAP:
17.235 @@ -340,7 +340,7 @@
17.236 }
17.237
17.238 }; // class BinHeap
17.239 -
17.240 +
17.241 } // namespace lemon
17.242
17.243 #endif // LEMON_BIN_HEAP_H
18.1 --- a/lemon/bits/alteration_notifier.h Sun Jul 13 16:46:56 2008 +0100
18.2 +++ b/lemon/bits/alteration_notifier.h Sun Jul 13 19:51:02 2008 +0100
18.3 @@ -1,6 +1,6 @@
18.4 -/* -*- C++ -*-
18.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
18.6 *
18.7 - * This file is a part of LEMON, a generic C++ optimization library
18.8 + * This file is a part of LEMON, a generic C++ optimization library.
18.9 *
18.10 * Copyright (C) 2003-2008
18.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
18.12 @@ -32,7 +32,7 @@
18.13
18.14 /// \ingroup graphbits
18.15 ///
18.16 - /// \brief Notifier class to notify observes about alterations in
18.17 + /// \brief Notifier class to notify observes about alterations in
18.18 /// a container.
18.19 ///
18.20 /// The simple graph's can be refered as two containers, one node container
18.21 @@ -49,7 +49,7 @@
18.22 /// an alteration in the graph, which cause only drawback on the
18.23 /// alteration of the graph.
18.24 ///
18.25 - /// This class provides an interface to the container. The \e first() and \e
18.26 + /// This class provides an interface to the container. The \e first() and \e
18.27 /// next() member functions make possible to iterate on the keys of the
18.28 /// container. The \e id() function returns an integer id for each key.
18.29 /// The \e maxId() function gives back an upper bound of the ids.
18.30 @@ -60,7 +60,7 @@
18.31 /// \e erase() signals that only one or few items added or erased to or
18.32 /// from the graph. If all items are erased from the graph or from an empty
18.33 /// graph a new graph is builded then it can be signaled with the
18.34 - /// clear() and build() members. Important rule that if we erase items
18.35 + /// clear() and build() members. Important rule that if we erase items
18.36 /// from graph we should first signal the alteration and after that erase
18.37 /// them from the container, on the other way on item addition we should
18.38 /// first extend the container and just after that signal the alteration.
18.39 @@ -68,7 +68,7 @@
18.40 /// The alteration can be observed with a class inherited from the
18.41 /// \e ObserverBase nested class. The signals can be handled with
18.42 /// overriding the virtual functions defined in the base class. The
18.43 - /// observer base can be attached to the notifier with the
18.44 + /// observer base can be attached to the notifier with the
18.45 /// \e attach() member and can be detached with detach() function. The
18.46 /// alteration handlers should not call any function which signals
18.47 /// an other alteration in the same notifier and should not
18.48 @@ -79,13 +79,13 @@
18.49 /// observeres will not be notified and the fulfilled additions will
18.50 /// be rolled back by calling the \e erase() or \e clear()
18.51 /// functions. Thence the \e erase() and \e clear() should not throw
18.52 - /// exception. Actullay, it can be throw only
18.53 + /// exception. Actullay, it can be throw only
18.54 /// \ref AlterationObserver::ImmediateDetach ImmediateDetach
18.55 /// exception which detach the observer from the notifier.
18.56 ///
18.57 /// There are some place when the alteration observing is not completly
18.58 /// reliable. If we want to carry out the node degree in the graph
18.59 - /// as in the \ref InDegMap and we use the reverseEdge that cause
18.60 + /// as in the \ref InDegMap and we use the reverseEdge that cause
18.61 /// unreliable functionality. Because the alteration observing signals
18.62 /// only erasing and adding but not the reversing it will stores bad
18.63 /// degrees. The sub graph adaptors cannot signal the alterations because
18.64 @@ -104,7 +104,7 @@
18.65 typedef _Container Container;
18.66 typedef _Item Item;
18.67
18.68 - /// \brief Exception which can be called from \e clear() and
18.69 + /// \brief Exception which can be called from \e clear() and
18.70 /// \e erase().
18.71 ///
18.72 /// From the \e clear() and \e erase() function only this
18.73 @@ -127,7 +127,7 @@
18.74 ///
18.75 /// The build() and clear() members are to notify the observer
18.76 /// about the container is built from an empty container or
18.77 - /// is cleared to an empty container.
18.78 + /// is cleared to an empty container.
18.79
18.80 class ObserverBase {
18.81 protected:
18.82 @@ -138,7 +138,7 @@
18.83 /// \brief Default constructor.
18.84 ///
18.85 /// Default constructor for ObserverBase.
18.86 - ///
18.87 + ///
18.88 ObserverBase() : _notifier(0) {}
18.89
18.90 /// \brief Constructor which attach the observer into notifier.
18.91 @@ -151,13 +151,13 @@
18.92 /// \brief Constructor which attach the obserever to the same notifier.
18.93 ///
18.94 /// Constructor which attach the obserever to the same notifier as
18.95 - /// the other observer is attached to.
18.96 + /// the other observer is attached to.
18.97 ObserverBase(const ObserverBase& copy) {
18.98 - if (copy.attached()) {
18.99 + if (copy.attached()) {
18.100 attach(*copy.notifier());
18.101 - }
18.102 + }
18.103 }
18.104 -
18.105 +
18.106 /// \brief Destructor
18.107 virtual ~ObserverBase() {
18.108 if (attached()) {
18.109 @@ -170,9 +170,9 @@
18.110 /// This member attaches the observer into an AlterationNotifier.
18.111 ///
18.112 void attach(AlterationNotifier& nf) {
18.113 - nf.attach(*this);
18.114 + nf.attach(*this);
18.115 }
18.116 -
18.117 +
18.118 /// \brief Detaches the observer into an AlterationNotifier.
18.119 ///
18.120 /// This member detaches the observer from an AlterationNotifier.
18.121 @@ -180,15 +180,15 @@
18.122 void detach() {
18.123 _notifier->detach(*this);
18.124 }
18.125 -
18.126 - /// \brief Gives back a pointer to the notifier which the map
18.127 +
18.128 + /// \brief Gives back a pointer to the notifier which the map
18.129 /// attached into.
18.130 ///
18.131 /// This function gives back a pointer to the notifier which the map
18.132 /// attached into.
18.133 ///
18.134 Notifier* notifier() const { return const_cast<Notifier*>(_notifier); }
18.135 -
18.136 +
18.137 /// Gives back true when the observer is attached into a notifier.
18.138 bool attached() const { return _notifier != 0; }
18.139
18.140 @@ -197,7 +197,7 @@
18.141 ObserverBase& operator=(const ObserverBase& copy);
18.142
18.143 protected:
18.144 -
18.145 +
18.146 Notifier* _notifier;
18.147 typename std::list<ObserverBase*>::iterator _index;
18.148
18.149 @@ -209,7 +209,7 @@
18.150 /// subclasses.
18.151 virtual void add(const Item&) = 0;
18.152
18.153 - /// \brief The member function to notificate the observer about
18.154 + /// \brief The member function to notificate the observer about
18.155 /// more item is added to the container.
18.156 ///
18.157 /// The add() member function notificates the observer about more item
18.158 @@ -222,10 +222,10 @@
18.159 ///
18.160 /// The erase() member function notificates the observer about an
18.161 /// item is erased from the container. It have to be overrided in
18.162 - /// the subclasses.
18.163 + /// the subclasses.
18.164 virtual void erase(const Item&) = 0;
18.165
18.166 - /// \brief The member function to notificate the observer about
18.167 + /// \brief The member function to notificate the observer about
18.168 /// more item is erased from the container.
18.169 ///
18.170 /// The erase() member function notificates the observer about more item
18.171 @@ -247,50 +247,50 @@
18.172 ///
18.173 /// The clear() member function notificates the observer about all
18.174 /// items are erased from the container. It have to be overrided in
18.175 - /// the subclasses.
18.176 + /// the subclasses.
18.177 virtual void clear() = 0;
18.178
18.179 };
18.180 -
18.181 +
18.182 protected:
18.183
18.184 const Container* container;
18.185
18.186 - typedef std::list<ObserverBase*> Observers;
18.187 + typedef std::list<ObserverBase*> Observers;
18.188 Observers _observers;
18.189
18.190 -
18.191 +
18.192 public:
18.193
18.194 /// \brief Default constructor.
18.195 ///
18.196 - /// The default constructor of the AlterationNotifier.
18.197 + /// The default constructor of the AlterationNotifier.
18.198 /// It creates an empty notifier.
18.199 - AlterationNotifier()
18.200 + AlterationNotifier()
18.201 : container(0) {}
18.202
18.203 /// \brief Constructor.
18.204 ///
18.205 /// Constructor with the observed container parameter.
18.206 - AlterationNotifier(const Container& _container)
18.207 + AlterationNotifier(const Container& _container)
18.208 : container(&_container) {}
18.209
18.210 - /// \brief Copy Constructor of the AlterationNotifier.
18.211 + /// \brief Copy Constructor of the AlterationNotifier.
18.212 ///
18.213 - /// Copy constructor of the AlterationNotifier.
18.214 + /// Copy constructor of the AlterationNotifier.
18.215 /// It creates only an empty notifier because the copiable
18.216 /// notifier's observers have to be registered still into that notifier.
18.217 - AlterationNotifier(const AlterationNotifier& _notifier)
18.218 + AlterationNotifier(const AlterationNotifier& _notifier)
18.219 : container(_notifier.container) {}
18.220
18.221 /// \brief Destructor.
18.222 - ///
18.223 + ///
18.224 /// Destructor of the AlterationNotifier.
18.225 ///
18.226 ~AlterationNotifier() {
18.227 typename Observers::iterator it;
18.228 for (it = _observers.begin(); it != _observers.end(); ++it) {
18.229 - (*it)->_notifier = 0;
18.230 + (*it)->_notifier = 0;
18.231 }
18.232 }
18.233
18.234 @@ -338,13 +338,13 @@
18.235 int maxId() const {
18.236 return container->maxId(Item());
18.237 }
18.238 -
18.239 +
18.240 protected:
18.241
18.242 void attach(ObserverBase& observer) {
18.243 observer._index = _observers.insert(_observers.begin(), &observer);
18.244 observer._notifier = this;
18.245 - }
18.246 + }
18.247
18.248 void detach(ObserverBase& observer) {
18.249 _observers.erase(observer._index);
18.250 @@ -353,13 +353,13 @@
18.251 }
18.252
18.253 public:
18.254 -
18.255 - /// \brief Notifies all the registed observers about an item added to
18.256 +
18.257 + /// \brief Notifies all the registed observers about an item added to
18.258 /// the container.
18.259 ///
18.260 - /// It notifies all the registed observers about an item added to
18.261 + /// It notifies all the registed observers about an item added to
18.262 /// the container.
18.263 - ///
18.264 + ///
18.265 void add(const Item& item) {
18.266 typename Observers::reverse_iterator it;
18.267 try {
18.268 @@ -373,14 +373,14 @@
18.269 }
18.270 throw;
18.271 }
18.272 - }
18.273 + }
18.274
18.275 - /// \brief Notifies all the registed observers about more item added to
18.276 + /// \brief Notifies all the registed observers about more item added to
18.277 /// the container.
18.278 ///
18.279 - /// It notifies all the registed observers about more item added to
18.280 + /// It notifies all the registed observers about more item added to
18.281 /// the container.
18.282 - ///
18.283 + ///
18.284 void add(const std::vector<Item>& items) {
18.285 typename Observers::reverse_iterator it;
18.286 try {
18.287 @@ -394,14 +394,14 @@
18.288 }
18.289 throw;
18.290 }
18.291 - }
18.292 + }
18.293
18.294 - /// \brief Notifies all the registed observers about an item erased from
18.295 + /// \brief Notifies all the registed observers about an item erased from
18.296 /// the container.
18.297 - ///
18.298 - /// It notifies all the registed observers about an item erased from
18.299 + ///
18.300 + /// It notifies all the registed observers about an item erased from
18.301 /// the container.
18.302 - ///
18.303 + ///
18.304 void erase(const Item& item) throw() {
18.305 typename Observers::iterator it = _observers.begin();
18.306 while (it != _observers.end()) {
18.307 @@ -416,12 +416,12 @@
18.308 }
18.309 }
18.310
18.311 - /// \brief Notifies all the registed observers about more item erased
18.312 + /// \brief Notifies all the registed observers about more item erased
18.313 /// from the container.
18.314 - ///
18.315 - /// It notifies all the registed observers about more item erased from
18.316 + ///
18.317 + /// It notifies all the registed observers about more item erased from
18.318 /// the container.
18.319 - ///
18.320 + ///
18.321 void erase(const std::vector<Item>& items) {
18.322 typename Observers::iterator it = _observers.begin();
18.323 while (it != _observers.end()) {
18.324 @@ -436,9 +436,9 @@
18.325 }
18.326 }
18.327
18.328 - /// \brief Notifies all the registed observers about the container is
18.329 + /// \brief Notifies all the registed observers about the container is
18.330 /// built.
18.331 - ///
18.332 + ///
18.333 /// Notifies all the registed observers about the container is built
18.334 /// from an empty container.
18.335 void build() {
18.336 @@ -456,7 +456,7 @@
18.337 }
18.338 }
18.339
18.340 - /// \brief Notifies all the registed observers about all items are
18.341 + /// \brief Notifies all the registed observers about all items are
18.342 /// erased.
18.343 ///
18.344 /// Notifies all the registed observers about all items are erased
19.1 --- a/lemon/bits/array_map.h Sun Jul 13 16:46:56 2008 +0100
19.2 +++ b/lemon/bits/array_map.h Sun Jul 13 19:51:02 2008 +0100
19.3 @@ -1,6 +1,6 @@
19.4 -/* -*- C++ -*-
19.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
19.6 *
19.7 - * This file is a part of LEMON, a generic C++ optimization library
19.8 + * This file is a part of LEMON, a generic C++ optimization library.
19.9 *
19.10 * Copyright (C) 2003-2008
19.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
19.12 @@ -38,16 +38,16 @@
19.13 ///
19.14 /// The ArrayMap template class is graph map structure what
19.15 /// automatically updates the map when a key is added to or erased from
19.16 - /// the map. This map uses the allocators to implement
19.17 + /// the map. This map uses the allocators to implement
19.18 /// the container functionality.
19.19 ///
19.20 /// The template parameters are the Graph the current Item type and
19.21 /// the Value type of the map.
19.22 template <typename _Graph, typename _Item, typename _Value>
19.23 - class ArrayMap
19.24 + class ArrayMap
19.25 : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
19.26 public:
19.27 - /// The graph type of the maps.
19.28 + /// The graph type of the maps.
19.29 typedef _Graph Graph;
19.30 /// The item type of the map.
19.31 typedef _Item Item;
19.32 @@ -69,7 +69,7 @@
19.33
19.34 /// The MapBase of the Map which imlements the core regisitry function.
19.35 typedef typename Notifier::ObserverBase Parent;
19.36 -
19.37 +
19.38 private:
19.39 typedef std::allocator<Value> Allocator;
19.40
19.41 @@ -84,31 +84,31 @@
19.42 Notifier* nf = Parent::notifier();
19.43 Item it;
19.44 for (nf->first(it); it != INVALID; nf->next(it)) {
19.45 - int id = nf->id(it);;
19.46 - allocator.construct(&(values[id]), Value());
19.47 - }
19.48 + int id = nf->id(it);;
19.49 + allocator.construct(&(values[id]), Value());
19.50 + }
19.51 }
19.52
19.53 - /// \brief Constructor to use default value to initialize the map.
19.54 + /// \brief Constructor to use default value to initialize the map.
19.55 ///
19.56 - /// It constructs a map and initialize all of the the map.
19.57 + /// It constructs a map and initialize all of the the map.
19.58 ArrayMap(const Graph& graph, const Value& value) {
19.59 Parent::attach(graph.notifier(Item()));
19.60 allocate_memory();
19.61 Notifier* nf = Parent::notifier();
19.62 Item it;
19.63 for (nf->first(it); it != INVALID; nf->next(it)) {
19.64 - int id = nf->id(it);;
19.65 - allocator.construct(&(values[id]), value);
19.66 - }
19.67 + int id = nf->id(it);;
19.68 + allocator.construct(&(values[id]), value);
19.69 + }
19.70 }
19.71
19.72 /// \brief Constructor to copy a map of the same map type.
19.73 ///
19.74 - /// Constructor to copy a map of the same map type.
19.75 + /// Constructor to copy a map of the same map type.
19.76 ArrayMap(const ArrayMap& copy) : Parent() {
19.77 if (copy.attached()) {
19.78 - attach(*copy.notifier());
19.79 + attach(*copy.notifier());
19.80 }
19.81 capacity = copy.capacity;
19.82 if (capacity == 0) return;
19.83 @@ -116,18 +116,18 @@
19.84 Notifier* nf = Parent::notifier();
19.85 Item it;
19.86 for (nf->first(it); it != INVALID; nf->next(it)) {
19.87 - int id = nf->id(it);;
19.88 - allocator.construct(&(values[id]), copy.values[id]);
19.89 + int id = nf->id(it);;
19.90 + allocator.construct(&(values[id]), copy.values[id]);
19.91 }
19.92 }
19.93
19.94 /// \brief Assign operator.
19.95 ///
19.96 /// This operator assigns for each item in the map the
19.97 - /// value mapped to the same item in the copied map.
19.98 + /// value mapped to the same item in the copied map.
19.99 /// The parameter map should be indiced with the same
19.100 /// itemset because this assign operator does not change
19.101 - /// the container of the map.
19.102 + /// the container of the map.
19.103 ArrayMap& operator=(const ArrayMap& cmap) {
19.104 return operator=<ArrayMap>(cmap);
19.105 }
19.106 @@ -138,7 +138,7 @@
19.107 /// The given parameter should be conform to the ReadMap
19.108 /// concecpt and could be indiced by the current item set of
19.109 /// the NodeMap. In this case the value for each item
19.110 - /// is assigned by the value of the given ReadMap.
19.111 + /// is assigned by the value of the given ReadMap.
19.112 template <typename CMap>
19.113 ArrayMap& operator=(const CMap& cmap) {
19.114 checkConcept<concepts::ReadMap<Key, _Value>, CMap>();
19.115 @@ -151,15 +151,15 @@
19.116 }
19.117
19.118 /// \brief The destructor of the map.
19.119 - ///
19.120 + ///
19.121 /// The destructor of the map.
19.122 - virtual ~ArrayMap() {
19.123 + virtual ~ArrayMap() {
19.124 if (attached()) {
19.125 - clear();
19.126 - detach();
19.127 + clear();
19.128 + detach();
19.129 }
19.130 }
19.131 -
19.132 +
19.133 protected:
19.134
19.135 using Parent::attach;
19.136 @@ -168,26 +168,26 @@
19.137
19.138 public:
19.139
19.140 - /// \brief The subscript operator.
19.141 + /// \brief The subscript operator.
19.142 ///
19.143 /// The subscript operator. The map can be subscripted by the
19.144 - /// actual keys of the graph.
19.145 + /// actual keys of the graph.
19.146 Value& operator[](const Key& key) {
19.147 int id = Parent::notifier()->id(key);
19.148 return values[id];
19.149 - }
19.150 -
19.151 + }
19.152 +
19.153 /// \brief The const subscript operator.
19.154 ///
19.155 /// The const subscript operator. The map can be subscripted by the
19.156 - /// actual keys of the graph.
19.157 + /// actual keys of the graph.
19.158 const Value& operator[](const Key& key) const {
19.159 int id = Parent::notifier()->id(key);
19.160 return values[id];
19.161 }
19.162
19.163 /// \brief Setter function of the map.
19.164 - ///
19.165 + ///
19.166 /// Setter function of the map. Equivalent with map[key] = val.
19.167 /// This is a compatibility feature with the not dereferable maps.
19.168 void set(const Key& key, const Value& val) {
19.169 @@ -197,81 +197,81 @@
19.170 protected:
19.171
19.172 /// \brief Adds a new key to the map.
19.173 - ///
19.174 + ///
19.175 /// It adds a new key to the map. It called by the observer notifier
19.176 - /// and it overrides the add() member function of the observer base.
19.177 + /// and it overrides the add() member function of the observer base.
19.178 virtual void add(const Key& key) {
19.179 Notifier* nf = Parent::notifier();
19.180 int id = nf->id(key);
19.181 if (id >= capacity) {
19.182 - int new_capacity = (capacity == 0 ? 1 : capacity);
19.183 - while (new_capacity <= id) {
19.184 - new_capacity <<= 1;
19.185 - }
19.186 - Value* new_values = allocator.allocate(new_capacity);
19.187 - Item it;
19.188 - for (nf->first(it); it != INVALID; nf->next(it)) {
19.189 - int jd = nf->id(it);;
19.190 - if (id != jd) {
19.191 - allocator.construct(&(new_values[jd]), values[jd]);
19.192 - allocator.destroy(&(values[jd]));
19.193 - }
19.194 - }
19.195 - if (capacity != 0) allocator.deallocate(values, capacity);
19.196 - values = new_values;
19.197 - capacity = new_capacity;
19.198 + int new_capacity = (capacity == 0 ? 1 : capacity);
19.199 + while (new_capacity <= id) {
19.200 + new_capacity <<= 1;
19.201 + }
19.202 + Value* new_values = allocator.allocate(new_capacity);
19.203 + Item it;
19.204 + for (nf->first(it); it != INVALID; nf->next(it)) {
19.205 + int jd = nf->id(it);;
19.206 + if (id != jd) {
19.207 + allocator.construct(&(new_values[jd]), values[jd]);
19.208 + allocator.destroy(&(values[jd]));
19.209 + }
19.210 + }
19.211 + if (capacity != 0) allocator.deallocate(values, capacity);
19.212 + values = new_values;
19.213 + capacity = new_capacity;
19.214 }
19.215 allocator.construct(&(values[id]), Value());
19.216 }
19.217
19.218 /// \brief Adds more new keys to the map.
19.219 - ///
19.220 + ///
19.221 /// It adds more new keys to the map. It called by the observer notifier
19.222 - /// and it overrides the add() member function of the observer base.
19.223 + /// and it overrides the add() member function of the observer base.
19.224 virtual void add(const std::vector<Key>& keys) {
19.225 Notifier* nf = Parent::notifier();
19.226 int max_id = -1;
19.227 for (int i = 0; i < int(keys.size()); ++i) {
19.228 - int id = nf->id(keys[i]);
19.229 - if (id > max_id) {
19.230 - max_id = id;
19.231 - }
19.232 + int id = nf->id(keys[i]);
19.233 + if (id > max_id) {
19.234 + max_id = id;
19.235 + }
19.236 }
19.237 if (max_id >= capacity) {
19.238 - int new_capacity = (capacity == 0 ? 1 : capacity);
19.239 - while (new_capacity <= max_id) {
19.240 - new_capacity <<= 1;
19.241 - }
19.242 - Value* new_values = allocator.allocate(new_capacity);
19.243 - Item it;
19.244 - for (nf->first(it); it != INVALID; nf->next(it)) {
19.245 - int id = nf->id(it);
19.246 - bool found = false;
19.247 - for (int i = 0; i < int(keys.size()); ++i) {
19.248 - int jd = nf->id(keys[i]);
19.249 - if (id == jd) {
19.250 - found = true;
19.251 - break;
19.252 - }
19.253 - }
19.254 - if (found) continue;
19.255 - allocator.construct(&(new_values[id]), values[id]);
19.256 - allocator.destroy(&(values[id]));
19.257 - }
19.258 - if (capacity != 0) allocator.deallocate(values, capacity);
19.259 - values = new_values;
19.260 - capacity = new_capacity;
19.261 + int new_capacity = (capacity == 0 ? 1 : capacity);
19.262 + while (new_capacity <= max_id) {
19.263 + new_capacity <<= 1;
19.264 + }
19.265 + Value* new_values = allocator.allocate(new_capacity);
19.266 + Item it;
19.267 + for (nf->first(it); it != INVALID; nf->next(it)) {
19.268 + int id = nf->id(it);
19.269 + bool found = false;
19.270 + for (int i = 0; i < int(keys.size()); ++i) {
19.271 + int jd = nf->id(keys[i]);
19.272 + if (id == jd) {
19.273 + found = true;
19.274 + break;
19.275 + }
19.276 + }
19.277 + if (found) continue;
19.278 + allocator.construct(&(new_values[id]), values[id]);
19.279 + allocator.destroy(&(values[id]));
19.280 + }
19.281 + if (capacity != 0) allocator.deallocate(values, capacity);
19.282 + values = new_values;
19.283 + capacity = new_capacity;
19.284 }
19.285 for (int i = 0; i < int(keys.size()); ++i) {
19.286 - int id = nf->id(keys[i]);
19.287 - allocator.construct(&(values[id]), Value());
19.288 + int id = nf->id(keys[i]);
19.289 + allocator.construct(&(values[id]), Value());
19.290 }
19.291 }
19.292 -
19.293 +
19.294 /// \brief Erase a key from the map.
19.295 ///
19.296 /// Erase a key from the map. It called by the observer notifier
19.297 - /// and it overrides the erase() member function of the observer base.
19.298 + /// and it overrides the erase() member function of the observer base.
19.299 virtual void erase(const Key& key) {
19.300 int id = Parent::notifier()->id(key);
19.301 allocator.destroy(&(values[id]));
19.302 @@ -280,67 +280,67 @@
19.303 /// \brief Erase more keys from the map.
19.304 ///
19.305 /// Erase more keys from the map. It called by the observer notifier
19.306 - /// and it overrides the erase() member function of the observer base.
19.307 + /// and it overrides the erase() member function of the observer base.
19.308 virtual void erase(const std::vector<Key>& keys) {
19.309 for (int i = 0; i < int(keys.size()); ++i) {
19.310 - int id = Parent::notifier()->id(keys[i]);
19.311 - allocator.destroy(&(values[id]));
19.312 + int id = Parent::notifier()->id(keys[i]);
19.313 + allocator.destroy(&(values[id]));
19.314 }
19.315 }
19.316
19.317 /// \brief Buildes the map.
19.318 - ///
19.319 + ///
19.320 /// It buildes the map. It called by the observer notifier
19.321 - /// and it overrides the build() member function of the observer base.
19.322 + /// and it overrides the build() member function of the observer base.
19.323 virtual void build() {
19.324 Notifier* nf = Parent::notifier();
19.325 allocate_memory();
19.326 Item it;
19.327 for (nf->first(it); it != INVALID; nf->next(it)) {
19.328 - int id = nf->id(it);;
19.329 - allocator.construct(&(values[id]), Value());
19.330 - }
19.331 + int id = nf->id(it);;
19.332 + allocator.construct(&(values[id]), Value());
19.333 + }
19.334 }
19.335
19.336 /// \brief Clear the map.
19.337 ///
19.338 /// It erase all items from the map. It called by the observer notifier
19.339 - /// and it overrides the clear() member function of the observer base.
19.340 - virtual void clear() {
19.341 + /// and it overrides the clear() member function of the observer base.
19.342 + virtual void clear() {
19.343 Notifier* nf = Parent::notifier();
19.344 if (capacity != 0) {
19.345 - Item it;
19.346 - for (nf->first(it); it != INVALID; nf->next(it)) {
19.347 - int id = nf->id(it);
19.348 - allocator.destroy(&(values[id]));
19.349 - }
19.350 - allocator.deallocate(values, capacity);
19.351 - capacity = 0;
19.352 + Item it;
19.353 + for (nf->first(it); it != INVALID; nf->next(it)) {
19.354 + int id = nf->id(it);
19.355 + allocator.destroy(&(values[id]));
19.356 + }
19.357 + allocator.deallocate(values, capacity);
19.358 + capacity = 0;
19.359 }
19.360 }
19.361
19.362 private:
19.363 -
19.364 +
19.365 void allocate_memory() {
19.366 int max_id = Parent::notifier()->maxId();
19.367 if (max_id == -1) {
19.368 - capacity = 0;
19.369 - values = 0;
19.370 - return;
19.371 + capacity = 0;
19.372 + values = 0;
19.373 + return;
19.374 }
19.375 capacity = 1;
19.376 while (capacity <= max_id) {
19.377 - capacity <<= 1;
19.378 + capacity <<= 1;
19.379 }
19.380 - values = allocator.allocate(capacity);
19.381 - }
19.382 + values = allocator.allocate(capacity);
19.383 + }
19.384
19.385 int capacity;
19.386 Value* values;
19.387 Allocator allocator;
19.388
19.389 - };
19.390 + };
19.391
19.392 }
19.393
19.394 -#endif
19.395 +#endif
20.1 --- a/lemon/bits/base_extender.h Sun Jul 13 16:46:56 2008 +0100
20.2 +++ b/lemon/bits/base_extender.h Sun Jul 13 19:51:02 2008 +0100
20.3 @@ -1,6 +1,6 @@
20.4 -/* -*- C++ -*-
20.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
20.6 *
20.7 - * This file is a part of LEMON, a generic C++ optimization library
20.8 + * This file is a part of LEMON, a generic C++ optimization library.
20.9 *
20.10 * Copyright (C) 2003-2008
20.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
20.12 @@ -63,14 +63,14 @@
20.13 Arc(Invalid i) : Edge(i), forward(true) {}
20.14
20.15 bool operator==(const Arc &that) const {
20.16 - return forward==that.forward && Edge(*this)==Edge(that);
20.17 + return forward==that.forward && Edge(*this)==Edge(that);
20.18 }
20.19 bool operator!=(const Arc &that) const {
20.20 - return forward!=that.forward || Edge(*this)!=Edge(that);
20.21 + return forward!=that.forward || Edge(*this)!=Edge(that);
20.22 }
20.23 bool operator<(const Arc &that) const {
20.24 - return forward<that.forward ||
20.25 - (!(that.forward<forward) && Edge(*this)<Edge(that));
20.26 + return forward<that.forward ||
20.27 + (!(that.forward<forward) && Edge(*this)<Edge(that));
20.28 }
20.29 };
20.30
20.31 @@ -117,59 +117,59 @@
20.32
20.33 void next(Arc &e) const {
20.34 if( e.forward ) {
20.35 - e.forward = false;
20.36 + e.forward = false;
20.37 }
20.38 else {
20.39 - Parent::next(e);
20.40 - e.forward = true;
20.41 + Parent::next(e);
20.42 + e.forward = true;
20.43 }
20.44 }
20.45
20.46 void firstOut(Arc &e, const Node &n) const {
20.47 Parent::firstIn(e,n);
20.48 if( Edge(e) != INVALID ) {
20.49 - e.forward = false;
20.50 + e.forward = false;
20.51 }
20.52 else {
20.53 - Parent::firstOut(e,n);
20.54 - e.forward = true;
20.55 + Parent::firstOut(e,n);
20.56 + e.forward = true;
20.57 }
20.58 }
20.59 void nextOut(Arc &e) const {
20.60 if( ! e.forward ) {
20.61 - Node n = Parent::target(e);
20.62 - Parent::nextIn(e);
20.63 - if( Edge(e) == INVALID ) {
20.64 - Parent::firstOut(e, n);
20.65 - e.forward = true;
20.66 - }
20.67 + Node n = Parent::target(e);
20.68 + Parent::nextIn(e);
20.69 + if( Edge(e) == INVALID ) {
20.70 + Parent::firstOut(e, n);
20.71 + e.forward = true;
20.72 + }
20.73 }
20.74 else {
20.75 - Parent::nextOut(e);
20.76 + Parent::nextOut(e);
20.77 }
20.78 }
20.79
20.80 void firstIn(Arc &e, const Node &n) const {
20.81 Parent::firstOut(e,n);
20.82 if( Edge(e) != INVALID ) {
20.83 - e.forward = false;
20.84 + e.forward = false;
20.85 }
20.86 else {
20.87 - Parent::firstIn(e,n);
20.88 - e.forward = true;
20.89 + Parent::firstIn(e,n);
20.90 + e.forward = true;
20.91 }
20.92 }
20.93 void nextIn(Arc &e) const {
20.94 if( ! e.forward ) {
20.95 - Node n = Parent::source(e);
20.96 - Parent::nextOut(e);
20.97 - if( Edge(e) == INVALID ) {
20.98 - Parent::firstIn(e, n);
20.99 - e.forward = true;
20.100 - }
20.101 + Node n = Parent::source(e);
20.102 + Parent::nextOut(e);
20.103 + if( Edge(e) == INVALID ) {
20.104 + Parent::firstIn(e, n);
20.105 + e.forward = true;
20.106 + }
20.107 }
20.108 else {
20.109 - Parent::nextIn(e);
20.110 + Parent::nextIn(e);
20.111 }
20.112 }
20.113
20.114 @@ -183,13 +183,13 @@
20.115
20.116 void nextInc(Edge &e, bool &d) const {
20.117 if (d) {
20.118 - Node s = Parent::source(e);
20.119 - Parent::nextOut(e);
20.120 - if (e != INVALID) return;
20.121 - d = false;
20.122 - Parent::firstIn(e, s);
20.123 + Node s = Parent::source(e);
20.124 + Parent::nextOut(e);
20.125 + if (e != INVALID) return;
20.126 + d = false;
20.127 + Parent::firstIn(e, s);
20.128 } else {
20.129 - Parent::nextIn(e);
20.130 + Parent::nextIn(e);
20.131 }
20.132 }
20.133
20.134 @@ -240,18 +240,18 @@
20.135
20.136 Arc findArc(Node s, Node t, Arc p = INVALID) const {
20.137 if (p == INVALID) {
20.138 - Edge arc = Parent::findArc(s, t);
20.139 - if (arc != INVALID) return direct(arc, true);
20.140 - arc = Parent::findArc(t, s);
20.141 - if (arc != INVALID) return direct(arc, false);
20.142 + Edge arc = Parent::findArc(s, t);
20.143 + if (arc != INVALID) return direct(arc, true);
20.144 + arc = Parent::findArc(t, s);
20.145 + if (arc != INVALID) return direct(arc, false);
20.146 } else if (direction(p)) {
20.147 - Edge arc = Parent::findArc(s, t, p);
20.148 - if (arc != INVALID) return direct(arc, true);
20.149 - arc = Parent::findArc(t, s);
20.150 - if (arc != INVALID) return direct(arc, false);
20.151 + Edge arc = Parent::findArc(s, t, p);
20.152 + if (arc != INVALID) return direct(arc, true);
20.153 + arc = Parent::findArc(t, s);
20.154 + if (arc != INVALID) return direct(arc, false);
20.155 } else {
20.156 - Edge arc = Parent::findArc(t, s, p);
20.157 - if (arc != INVALID) return direct(arc, false);
20.158 + Edge arc = Parent::findArc(t, s, p);
20.159 + if (arc != INVALID) return direct(arc, false);
20.160 }
20.161 return INVALID;
20.162 }
20.163 @@ -267,10 +267,10 @@
20.164 Edge arc = Parent::findArc(s, t, p);
20.165 if (arc != INVALID) return arc;
20.166 arc = Parent::findArc(t, s);
20.167 - if (arc != INVALID) return arc;
20.168 + if (arc != INVALID) return arc;
20.169 } else {
20.170 Edge arc = Parent::findArc(t, s, p);
20.171 - if (arc != INVALID) return arc;
20.172 + if (arc != INVALID) return arc;
20.173 }
20.174 } else {
20.175 return Parent::findArc(s, t, p);
20.176 @@ -299,12 +299,12 @@
20.177 public:
20.178 Red() {}
20.179 Red(const Node& node) : Node(node) {
20.180 - LEMON_ASSERT(Parent::red(node) || node == INVALID,
20.181 - typename Parent::NodeSetError());
20.182 + LEMON_ASSERT(Parent::red(node) || node == INVALID,
20.183 + typename Parent::NodeSetError());
20.184 }
20.185 Red& operator=(const Node& node) {
20.186 - LEMON_ASSERT(Parent::red(node) || node == INVALID,
20.187 - typename Parent::NodeSetError());
20.188 + LEMON_ASSERT(Parent::red(node) || node == INVALID,
20.189 + typename Parent::NodeSetError());
20.190 Node::operator=(node);
20.191 return *this;
20.192 }
20.193 @@ -331,12 +331,12 @@
20.194 public:
20.195 Blue() {}
20.196 Blue(const Node& node) : Node(node) {
20.197 - LEMON_ASSERT(Parent::blue(node) || node == INVALID,
20.198 - typename Parent::NodeSetError());
20.199 + LEMON_ASSERT(Parent::blue(node) || node == INVALID,
20.200 + typename Parent::NodeSetError());
20.201 }
20.202 Blue& operator=(const Node& node) {
20.203 - LEMON_ASSERT(Parent::blue(node) || node == INVALID,
20.204 - typename Parent::NodeSetError());
20.205 + LEMON_ASSERT(Parent::blue(node) || node == INVALID,
20.206 + typename Parent::NodeSetError());
20.207 Node::operator=(node);
20.208 return *this;
20.209 }
20.210 @@ -353,7 +353,7 @@
20.211 void next(Blue& node) const {
20.212 Parent::nextBlue(static_cast<Node&>(node));
20.213 }
20.214 -
20.215 +
20.216 int id(const Blue& node) const {
20.217 return Parent::redId(node);
20.218 }
20.219 @@ -367,19 +367,19 @@
20.220
20.221 void firstInc(Edge& arc, bool& dir, const Node& node) const {
20.222 if (Parent::red(node)) {
20.223 - Parent::firstFromRed(arc, node);
20.224 - dir = true;
20.225 + Parent::firstFromRed(arc, node);
20.226 + dir = true;
20.227 } else {
20.228 - Parent::firstFromBlue(arc, node);
20.229 - dir = static_cast<Edge&>(arc) == INVALID;
20.230 + Parent::firstFromBlue(arc, node);
20.231 + dir = static_cast<Edge&>(arc) == INVALID;
20.232 }
20.233 }
20.234 void nextInc(Edge& arc, bool& dir) const {
20.235 if (dir) {
20.236 - Parent::nextFromRed(arc);
20.237 + Parent::nextFromRed(arc);
20.238 } else {
20.239 - Parent::nextFromBlue(arc);
20.240 - if (arc == INVALID) dir = true;
20.241 + Parent::nextFromBlue(arc);
20.242 + if (arc == INVALID) dir = true;
20.243 }
20.244 }
20.245
20.246 @@ -389,20 +389,20 @@
20.247 bool forward;
20.248
20.249 Arc(const Edge& arc, bool _forward)
20.250 - : Edge(arc), forward(_forward) {}
20.251 + : Edge(arc), forward(_forward) {}
20.252
20.253 public:
20.254 Arc() {}
20.255 Arc (Invalid) : Edge(INVALID), forward(true) {}
20.256 bool operator==(const Arc& i) const {
20.257 - return Edge::operator==(i) && forward == i.forward;
20.258 + return Edge::operator==(i) && forward == i.forward;
20.259 }
20.260 bool operator!=(const Arc& i) const {
20.261 - return Edge::operator!=(i) || forward != i.forward;
20.262 + return Edge::operator!=(i) || forward != i.forward;
20.263 }
20.264 bool operator<(const Arc& i) const {
20.265 - return Edge::operator<(i) ||
20.266 - (!(i.forward<forward) && Edge(*this)<Edge(i));
20.267 + return Edge::operator<(i) ||
20.268 + (!(i.forward<forward) && Edge(*this)<Edge(i));
20.269 }
20.270 };
20.271
20.272 @@ -413,44 +413,44 @@
20.273
20.274 void next(Arc& arc) const {
20.275 if (!arc.forward) {
20.276 - Parent::next(static_cast<Edge&>(arc));
20.277 + Parent::next(static_cast<Edge&>(arc));
20.278 }
20.279 arc.forward = !arc.forward;
20.280 }
20.281
20.282 void firstOut(Arc& arc, const Node& node) const {
20.283 if (Parent::red(node)) {
20.284 - Parent::firstFromRed(arc, node);
20.285 - arc.forward = true;
20.286 + Parent::firstFromRed(arc, node);
20.287 + arc.forward = true;
20.288 } else {
20.289 - Parent::firstFromBlue(arc, node);
20.290 - arc.forward = static_cast<Edge&>(arc) == INVALID;
20.291 + Parent::firstFromBlue(arc, node);
20.292 + arc.forward = static_cast<Edge&>(arc) == INVALID;
20.293 }
20.294 }
20.295 void nextOut(Arc& arc) const {
20.296 if (arc.forward) {
20.297 - Parent::nextFromRed(arc);
20.298 + Parent::nextFromRed(arc);
20.299 } else {
20.300 - Parent::nextFromBlue(arc);
20.301 + Parent::nextFromBlue(arc);
20.302 arc.forward = static_cast<Edge&>(arc) == INVALID;
20.303 }
20.304 }
20.305
20.306 void firstIn(Arc& arc, const Node& node) const {
20.307 if (Parent::blue(node)) {
20.308 - Parent::firstFromBlue(arc, node);
20.309 - arc.forward = true;
20.310 + Parent::firstFromBlue(arc, node);
20.311 + arc.forward = true;
20.312 } else {
20.313 - Parent::firstFromRed(arc, node);
20.314 - arc.forward = static_cast<Edge&>(arc) == INVALID;
20.315 + Parent::firstFromRed(arc, node);
20.316 + arc.forward = static_cast<Edge&>(arc) == INVALID;
20.317 }
20.318 }
20.319 void nextIn(Arc& arc) const {
20.320 if (arc.forward) {
20.321 - Parent::nextFromBlue(arc);
20.322 + Parent::nextFromBlue(arc);
20.323 } else {
20.324 - Parent::nextFromRed(arc);
20.325 - arc.forward = static_cast<Edge&>(arc) == INVALID;
20.326 + Parent::nextFromRed(arc);
20.327 + arc.forward = static_cast<Edge&>(arc) == INVALID;
20.328 }
20.329 }
20.330
20.331 @@ -462,7 +462,7 @@
20.332 }
20.333
20.334 int id(const Arc& arc) const {
20.335 - return (Parent::id(static_cast<const Edge&>(arc)) << 1) +
20.336 + return (Parent::id(static_cast<const Edge&>(arc)) << 1) +
20.337 (arc.forward ? 0 : 1);
20.338 }
20.339 Arc arcFromId(int ix) const {
21.1 --- a/lemon/bits/bezier.h Sun Jul 13 16:46:56 2008 +0100
21.2 +++ b/lemon/bits/bezier.h Sun Jul 13 19:51:02 2008 +0100
21.3 @@ -1,6 +1,6 @@
21.4 -/* -*- C++ -*-
21.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
21.6 *
21.7 - * This file is a part of LEMON, a generic C++ optimization library
21.8 + * This file is a part of LEMON, a generic C++ optimization library.
21.9 *
21.10 * Copyright (C) 2003-2008
21.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
21.12 @@ -44,7 +44,7 @@
21.13
21.14 Bezier1() {}
21.15 Bezier1(Point _p1, Point _p2) :p1(_p1), p2(_p2) {}
21.16 -
21.17 +
21.18 Point operator()(double t) const
21.19 {
21.20 // return conv(conv(p1,p2,t),conv(p2,p3,t),t);
21.21 @@ -54,7 +54,7 @@
21.22 {
21.23 return Bezier1(p1,conv(p1,p2,t));
21.24 }
21.25 -
21.26 +
21.27 Bezier1 after(double t) const
21.28 {
21.29 return Bezier1(conv(p1,p2,t),p2);
21.30 @@ -87,7 +87,7 @@
21.31 Point r(conv(p2,p3,t));
21.32 return Bezier2(p1,q,conv(q,r,t));
21.33 }
21.34 -
21.35 +
21.36 Bezier2 after(double t) const
21.37 {
21.38 Point q(conv(p1,p2,t));
21.39 @@ -110,16 +110,16 @@
21.40 Bezier3() {}
21.41 Bezier3(Point _p1, Point _p2, Point _p3, Point _p4)
21.42 : p1(_p1), p2(_p2), p3(_p3), p4(_p4) {}
21.43 - Bezier3(const Bezier1 &b) : p1(b.p1), p2(conv(b.p1,b.p2,1.0/3.0)),
21.44 - p3(conv(b.p1,b.p2,2.0/3.0)), p4(b.p2) {}
21.45 + Bezier3(const Bezier1 &b) : p1(b.p1), p2(conv(b.p1,b.p2,1.0/3.0)),
21.46 + p3(conv(b.p1,b.p2,2.0/3.0)), p4(b.p2) {}
21.47 Bezier3(const Bezier2 &b) : p1(b.p1), p2(conv(b.p1,b.p2,2.0/3.0)),
21.48 - p3(conv(b.p2,b.p3,1.0/3.0)), p4(b.p3) {}
21.49 -
21.50 - Point operator()(double t) const
21.51 + p3(conv(b.p2,b.p3,1.0/3.0)), p4(b.p3) {}
21.52 +
21.53 + Point operator()(double t) const
21.54 {
21.55 // return Bezier2(conv(p1,p2,t),conv(p2,p3,t),conv(p3,p4,t))(t);
21.56 return ((1-t)*(1-t)*(1-t))*p1+(3*t*(1-t)*(1-t))*p2+
21.57 - (3*t*t*(1-t))*p3+(t*t*t)*p4;
21.58 + (3*t*t*(1-t))*p3+(t*t*t)*p4;
21.59 }
21.60 Bezier3 before(double t) const
21.61 {
21.62 @@ -131,7 +131,7 @@
21.63 Point c(conv(a,b,t));
21.64 return Bezier3(p1,p,a,c);
21.65 }
21.66 -
21.67 +
21.68 Bezier3 after(double t) const
21.69 {
21.70 Point p(conv(p1,p2,t));
21.71 @@ -146,13 +146,13 @@
21.72 Bezier3 operator()(double a,double b) const { return before(b).after(a/b); }
21.73 Bezier2 grad() const { return Bezier2(3.0*(p2-p1),3.0*(p3-p2),3.0*(p4-p3)); }
21.74 Bezier2 norm() const { return Bezier2(3.0*rot90(p2-p1),
21.75 - 3.0*rot90(p3-p2),
21.76 - 3.0*rot90(p4-p3)); }
21.77 + 3.0*rot90(p3-p2),
21.78 + 3.0*rot90(p4-p3)); }
21.79 Point grad(double t) const { return grad()(t); }
21.80 Point norm(double t) const { return rot90(grad(t)); }
21.81
21.82 template<class R,class F,class S,class D>
21.83 - R recSplit(F &_f,const S &_s,D _d) const
21.84 + R recSplit(F &_f,const S &_s,D _d) const
21.85 {
21.86 const Point a=(p1+p2)/2;
21.87 const Point b=(p2+p3)/2;
21.88 @@ -164,7 +164,7 @@
21.89 R f2=_f(Bezier3(e,d,c,p4),_d);
21.90 return _s(f1,f2);
21.91 }
21.92 -
21.93 +
21.94 };
21.95
21.96
22.1 --- a/lemon/bits/default_map.h Sun Jul 13 16:46:56 2008 +0100
22.2 +++ b/lemon/bits/default_map.h Sun Jul 13 19:51:02 2008 +0100
22.3 @@ -1,6 +1,6 @@
22.4 -/* -*- C++ -*-
22.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
22.6 *
22.7 - * This file is a part of LEMON, a generic C++ optimization library
22.8 + * This file is a part of LEMON, a generic C++ optimization library.
22.9 *
22.10 * Copyright (C) 2003-2008
22.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
22.12 @@ -29,8 +29,8 @@
22.13 ///\brief Graph maps that construct and destruct their elements dynamically.
22.14
22.15 namespace lemon {
22.16 -
22.17 -
22.18 +
22.19 +
22.20 //#ifndef LEMON_USE_DEBUG_MAP
22.21
22.22 template <typename _Graph, typename _Item, typename _Value>
22.23 @@ -140,28 +140,28 @@
22.24 typedef VectorMap<_Graph, _Item, _Ptr*> Map;
22.25 };
22.26
22.27 -// #else
22.28 +// #else
22.29
22.30 // template <typename _Graph, typename _Item, typename _Value>
22.31 // struct DefaultMapSelector {
22.32 // typedef DebugMap<_Graph, _Item, _Value> Map;
22.33 // };
22.34
22.35 -// #endif
22.36 +// #endif
22.37
22.38 /// \e
22.39 template <typename _Graph, typename _Item, typename _Value>
22.40 - class DefaultMap
22.41 + class DefaultMap
22.42 : public DefaultMapSelector<_Graph, _Item, _Value>::Map {
22.43 public:
22.44 typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent;
22.45 typedef DefaultMap<_Graph, _Item, _Value> Map;
22.46 -
22.47 +
22.48 typedef typename Parent::Graph Graph;
22.49 typedef typename Parent::Value Value;
22.50
22.51 explicit DefaultMap(const Graph& graph) : Parent(graph) {}
22.52 - DefaultMap(const Graph& graph, const Value& value)
22.53 + DefaultMap(const Graph& graph, const Value& value)
22.54 : Parent(graph, value) {}
22.55
22.56 DefaultMap& operator=(const DefaultMap& cmap) {
23.1 --- a/lemon/bits/graph_extender.h Sun Jul 13 16:46:56 2008 +0100
23.2 +++ b/lemon/bits/graph_extender.h Sun Jul 13 19:51:02 2008 +0100
23.3 @@ -1,6 +1,6 @@
23.4 -/* -*- C++ -*-
23.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
23.6 *
23.7 - * This file is a part of LEMON, a generic C++ optimization library
23.8 + * This file is a part of LEMON, a generic C++ optimization library.
23.9 *
23.10 * Copyright (C) 2003-2008
23.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
23.12 @@ -66,11 +66,11 @@
23.13
23.14 Node oppositeNode(const Node &node, const Arc &arc) const {
23.15 if (node == Parent::source(arc))
23.16 - return Parent::target(arc);
23.17 + return Parent::target(arc);
23.18 else if(node == Parent::target(arc))
23.19 - return Parent::source(arc);
23.20 + return Parent::source(arc);
23.21 else
23.22 - return INVALID;
23.23 + return INVALID;
23.24 }
23.25
23.26 // Alterable extension
23.27 @@ -89,12 +89,12 @@
23.28 NodeNotifier& notifier(Node) const {
23.29 return node_notifier;
23.30 }
23.31 -
23.32 +
23.33 ArcNotifier& notifier(Arc) const {
23.34 return arc_notifier;
23.35 }
23.36
23.37 - class NodeIt : public Node {
23.38 + class NodeIt : public Node {
23.39 const Digraph* _digraph;
23.40 public:
23.41
23.42 @@ -103,21 +103,21 @@
23.43 NodeIt(Invalid i) : Node(i) { }
23.44
23.45 explicit NodeIt(const Digraph& digraph) : _digraph(&digraph) {
23.46 - _digraph->first(static_cast<Node&>(*this));
23.47 + _digraph->first(static_cast<Node&>(*this));
23.48 }
23.49
23.50 - NodeIt(const Digraph& digraph, const Node& node)
23.51 - : Node(node), _digraph(&digraph) {}
23.52 + NodeIt(const Digraph& digraph, const Node& node)
23.53 + : Node(node), _digraph(&digraph) {}
23.54
23.55 - NodeIt& operator++() {
23.56 - _digraph->next(*this);
23.57 - return *this;
23.58 + NodeIt& operator++() {
23.59 + _digraph->next(*this);
23.60 + return *this;
23.61 }
23.62
23.63 };
23.64
23.65
23.66 - class ArcIt : public Arc {
23.67 + class ArcIt : public Arc {
23.68 const Digraph* _digraph;
23.69 public:
23.70
23.71 @@ -126,21 +126,21 @@
23.72 ArcIt(Invalid i) : Arc(i) { }
23.73
23.74 explicit ArcIt(const Digraph& digraph) : _digraph(&digraph) {
23.75 - _digraph->first(static_cast<Arc&>(*this));
23.76 + _digraph->first(static_cast<Arc&>(*this));
23.77 }
23.78
23.79 - ArcIt(const Digraph& digraph, const Arc& arc) :
23.80 - Arc(arc), _digraph(&digraph) { }
23.81 + ArcIt(const Digraph& digraph, const Arc& arc) :
23.82 + Arc(arc), _digraph(&digraph) { }
23.83
23.84 - ArcIt& operator++() {
23.85 - _digraph->next(*this);
23.86 - return *this;
23.87 + ArcIt& operator++() {
23.88 + _digraph->next(*this);
23.89 + return *this;
23.90 }
23.91
23.92 };
23.93
23.94
23.95 - class OutArcIt : public Arc {
23.96 + class OutArcIt : public Arc {
23.97 const Digraph* _digraph;
23.98 public:
23.99
23.100 @@ -148,23 +148,23 @@
23.101
23.102 OutArcIt(Invalid i) : Arc(i) { }
23.103
23.104 - OutArcIt(const Digraph& digraph, const Node& node)
23.105 - : _digraph(&digraph) {
23.106 - _digraph->firstOut(*this, node);
23.107 + OutArcIt(const Digraph& digraph, const Node& node)
23.108 + : _digraph(&digraph) {
23.109 + _digraph->firstOut(*this, node);
23.110 }
23.111
23.112 - OutArcIt(const Digraph& digraph, const Arc& arc)
23.113 - : Arc(arc), _digraph(&digraph) {}
23.114 + OutArcIt(const Digraph& digraph, const Arc& arc)
23.115 + : Arc(arc), _digraph(&digraph) {}
23.116
23.117 - OutArcIt& operator++() {
23.118 - _digraph->nextOut(*this);
23.119 - return *this;
23.120 + OutArcIt& operator++() {
23.121 + _digraph->nextOut(*this);
23.122 + return *this;
23.123 }
23.124
23.125 };
23.126
23.127
23.128 - class InArcIt : public Arc {
23.129 + class InArcIt : public Arc {
23.130 const Digraph* _digraph;
23.131 public:
23.132
23.133 @@ -172,17 +172,17 @@
23.134
23.135 InArcIt(Invalid i) : Arc(i) { }
23.136
23.137 - InArcIt(const Digraph& digraph, const Node& node)
23.138 - : _digraph(&digraph) {
23.139 - _digraph->firstIn(*this, node);
23.140 + InArcIt(const Digraph& digraph, const Node& node)
23.141 + : _digraph(&digraph) {
23.142 + _digraph->firstIn(*this, node);
23.143 }
23.144
23.145 - InArcIt(const Digraph& digraph, const Arc& arc) :
23.146 - Arc(arc), _digraph(&digraph) {}
23.147 + InArcIt(const Digraph& digraph, const Arc& arc) :
23.148 + Arc(arc), _digraph(&digraph) {}
23.149
23.150 - InArcIt& operator++() {
23.151 - _digraph->nextIn(*this);
23.152 - return *this;
23.153 + InArcIt& operator++() {
23.154 + _digraph->nextIn(*this);
23.155 + return *this;
23.156 }
23.157
23.158 };
23.159 @@ -215,51 +215,51 @@
23.160 return Parent::source(arc);
23.161 }
23.162
23.163 -
23.164 +
23.165 template <typename _Value>
23.166 - class NodeMap
23.167 + class NodeMap
23.168 : public MapExtender<DefaultMap<Digraph, Node, _Value> > {
23.169 public:
23.170 typedef DigraphExtender Digraph;
23.171 typedef MapExtender<DefaultMap<Digraph, Node, _Value> > Parent;
23.172
23.173 - explicit NodeMap(const Digraph& digraph)
23.174 - : Parent(digraph) {}
23.175 - NodeMap(const Digraph& digraph, const _Value& value)
23.176 - : Parent(digraph, value) {}
23.177 + explicit NodeMap(const Digraph& digraph)
23.178 + : Parent(digraph) {}
23.179 + NodeMap(const Digraph& digraph, const _Value& value)
23.180 + : Parent(digraph, value) {}
23.181
23.182 NodeMap& operator=(const NodeMap& cmap) {
23.183 - return operator=<NodeMap>(cmap);
23.184 + return operator=<NodeMap>(cmap);
23.185 }
23.186
23.187 template <typename CMap>
23.188 NodeMap& operator=(const CMap& cmap) {
23.189 Parent::operator=(cmap);
23.190 - return *this;
23.191 + return *this;
23.192 }
23.193
23.194 };
23.195
23.196 template <typename _Value>
23.197 - class ArcMap
23.198 + class ArcMap
23.199 : public MapExtender<DefaultMap<Digraph, Arc, _Value> > {
23.200 public:
23.201 typedef DigraphExtender Digraph;
23.202 typedef MapExtender<DefaultMap<Digraph, Arc, _Value> > Parent;
23.203
23.204 - explicit ArcMap(const Digraph& digraph)
23.205 - : Parent(digraph) {}
23.206 - ArcMap(const Digraph& digraph, const _Value& value)
23.207 - : Parent(digraph, value) {}
23.208 + explicit ArcMap(const Digraph& digraph)
23.209 + : Parent(digraph) {}
23.210 + ArcMap(const Digraph& digraph, const _Value& value)
23.211 + : Parent(digraph, value) {}
23.212
23.213 ArcMap& operator=(const ArcMap& cmap) {
23.214 - return operator=<ArcMap>(cmap);
23.215 + return operator=<ArcMap>(cmap);
23.216 }
23.217
23.218 template <typename CMap>
23.219 ArcMap& operator=(const CMap& cmap) {
23.220 Parent::operator=(cmap);
23.221 - return *this;
23.222 + return *this;
23.223 }
23.224 };
23.225
23.226 @@ -269,7 +269,7 @@
23.227 notifier(Node()).add(node);
23.228 return node;
23.229 }
23.230 -
23.231 +
23.232 Arc addArc(const Node& from, const Node& to) {
23.233 Arc arc = Parent::addArc(from, to);
23.234 notifier(Arc()).add(arc);
23.235 @@ -293,20 +293,20 @@
23.236 Arc arc;
23.237 Parent::firstOut(arc, node);
23.238 while (arc != INVALID ) {
23.239 - erase(arc);
23.240 - Parent::firstOut(arc, node);
23.241 - }
23.242 + erase(arc);
23.243 + Parent::firstOut(arc, node);
23.244 + }
23.245
23.246 Parent::firstIn(arc, node);
23.247 while (arc != INVALID ) {
23.248 - erase(arc);
23.249 - Parent::firstIn(arc, node);
23.250 + erase(arc);
23.251 + Parent::firstIn(arc, node);
23.252 }
23.253
23.254 notifier(Node()).erase(node);
23.255 Parent::erase(node);
23.256 }
23.257 -
23.258 +
23.259 void erase(const Arc& arc) {
23.260 notifier(Arc()).erase(arc);
23.261 Parent::erase(arc);
23.262 @@ -315,8 +315,8 @@
23.263 DigraphExtender() {
23.264 node_notifier.setContainer(*this);
23.265 arc_notifier.setContainer(*this);
23.266 - }
23.267 -
23.268 + }
23.269 +
23.270
23.271 ~DigraphExtender() {
23.272 arc_notifier.clear();
23.273 @@ -327,10 +327,10 @@
23.274 /// \ingroup _graphbits
23.275 ///
23.276 /// \brief Extender for the Graphs
23.277 - template <typename Base>
23.278 + template <typename Base>
23.279 class GraphExtender : public Base {
23.280 public:
23.281 -
23.282 +
23.283 typedef Base Parent;
23.284 typedef GraphExtender Graph;
23.285
23.286 @@ -340,7 +340,7 @@
23.287 typedef typename Parent::Arc Arc;
23.288 typedef typename Parent::Edge Edge;
23.289
23.290 - // Graph extension
23.291 + // Graph extension
23.292
23.293 int maxId(Node) const {
23.294 return Parent::maxNodeId();
23.295 @@ -368,11 +368,11 @@
23.296
23.297 Node oppositeNode(const Node &n, const Edge &e) const {
23.298 if( n == Parent::u(e))
23.299 - return Parent::v(e);
23.300 + return Parent::v(e);
23.301 else if( n == Parent::v(e))
23.302 - return Parent::u(e);
23.303 + return Parent::u(e);
23.304 else
23.305 - return INVALID;
23.306 + return INVALID;
23.307 }
23.308
23.309 Arc oppositeArc(const Arc &arc) const {
23.310 @@ -402,7 +402,7 @@
23.311 NodeNotifier& notifier(Node) const {
23.312 return node_notifier;
23.313 }
23.314 -
23.315 +
23.316 ArcNotifier& notifier(Arc) const {
23.317 return arc_notifier;
23.318 }
23.319 @@ -413,7 +413,7 @@
23.320
23.321
23.322
23.323 - class NodeIt : public Node {
23.324 + class NodeIt : public Node {
23.325 const Graph* _graph;
23.326 public:
23.327
23.328 @@ -422,21 +422,21 @@
23.329 NodeIt(Invalid i) : Node(i) { }
23.330
23.331 explicit NodeIt(const Graph& graph) : _graph(&graph) {
23.332 - _graph->first(static_cast<Node&>(*this));
23.333 + _graph->first(static_cast<Node&>(*this));
23.334 }
23.335
23.336 - NodeIt(const Graph& graph, const Node& node)
23.337 - : Node(node), _graph(&graph) {}
23.338 + NodeIt(const Graph& graph, const Node& node)
23.339 + : Node(node), _graph(&graph) {}
23.340
23.341 - NodeIt& operator++() {
23.342 - _graph->next(*this);
23.343 - return *this;
23.344 + NodeIt& operator++() {
23.345 + _graph->next(*this);
23.346 + return *this;
23.347 }
23.348
23.349 };
23.350
23.351
23.352 - class ArcIt : public Arc {
23.353 + class ArcIt : public Arc {
23.354 const Graph* _graph;
23.355 public:
23.356
23.357 @@ -445,21 +445,21 @@
23.358 ArcIt(Invalid i) : Arc(i) { }
23.359
23.360 explicit ArcIt(const Graph& graph) : _graph(&graph) {
23.361 - _graph->first(static_cast<Arc&>(*this));
23.362 + _graph->first(static_cast<Arc&>(*this));
23.363 }
23.364
23.365 - ArcIt(const Graph& graph, const Arc& arc) :
23.366 - Arc(arc), _graph(&graph) { }
23.367 + ArcIt(const Graph& graph, const Arc& arc) :
23.368 + Arc(arc), _graph(&graph) { }
23.369
23.370 - ArcIt& operator++() {
23.371 - _graph->next(*this);
23.372 - return *this;
23.373 + ArcIt& operator++() {
23.374 + _graph->next(*this);
23.375 + return *this;
23.376 }
23.377
23.378 };
23.379
23.380
23.381 - class OutArcIt : public Arc {
23.382 + class OutArcIt : public Arc {
23.383 const Graph* _graph;
23.384 public:
23.385
23.386 @@ -467,23 +467,23 @@
23.387
23.388 OutArcIt(Invalid i) : Arc(i) { }
23.389
23.390 - OutArcIt(const Graph& graph, const Node& node)
23.391 - : _graph(&graph) {
23.392 - _graph->firstOut(*this, node);
23.393 + OutArcIt(const Graph& graph, const Node& node)
23.394 + : _graph(&graph) {
23.395 + _graph->firstOut(*this, node);
23.396 }
23.397
23.398 - OutArcIt(const Graph& graph, const Arc& arc)
23.399 - : Arc(arc), _graph(&graph) {}
23.400 + OutArcIt(const Graph& graph, const Arc& arc)
23.401 + : Arc(arc), _graph(&graph) {}
23.402
23.403 - OutArcIt& operator++() {
23.404 - _graph->nextOut(*this);
23.405 - return *this;
23.406 + OutArcIt& operator++() {
23.407 + _graph->nextOut(*this);
23.408 + return *this;
23.409 }
23.410
23.411 };
23.412
23.413
23.414 - class InArcIt : public Arc {
23.415 + class InArcIt : public Arc {
23.416 const Graph* _graph;
23.417 public:
23.418
23.419 @@ -491,23 +491,23 @@
23.420
23.421 InArcIt(Invalid i) : Arc(i) { }
23.422
23.423 - InArcIt(const Graph& graph, const Node& node)
23.424 - : _graph(&graph) {
23.425 - _graph->firstIn(*this, node);
23.426 + InArcIt(const Graph& graph, const Node& node)
23.427 + : _graph(&graph) {
23.428 + _graph->firstIn(*this, node);
23.429 }
23.430
23.431 - InArcIt(const Graph& graph, const Arc& arc) :
23.432 - Arc(arc), _graph(&graph) {}
23.433 + InArcIt(const Graph& graph, const Arc& arc) :
23.434 + Arc(arc), _graph(&graph) {}
23.435
23.436 - InArcIt& operator++() {
23.437 - _graph->nextIn(*this);
23.438 - return *this;
23.439 + InArcIt& operator++() {
23.440 + _graph->nextIn(*this);
23.441 + return *this;
23.442 }
23.443
23.444 };
23.445
23.446
23.447 - class EdgeIt : public Parent::Edge {
23.448 + class EdgeIt : public Parent::Edge {
23.449 const Graph* _graph;
23.450 public:
23.451
23.452 @@ -516,15 +516,15 @@
23.453 EdgeIt(Invalid i) : Edge(i) { }
23.454
23.455 explicit EdgeIt(const Graph& graph) : _graph(&graph) {
23.456 - _graph->first(static_cast<Edge&>(*this));
23.457 + _graph->first(static_cast<Edge&>(*this));
23.458 }
23.459
23.460 - EdgeIt(const Graph& graph, const Edge& edge) :
23.461 - Edge(edge), _graph(&graph) { }
23.462 + EdgeIt(const Graph& graph, const Edge& edge) :
23.463 + Edge(edge), _graph(&graph) { }
23.464
23.465 - EdgeIt& operator++() {
23.466 - _graph->next(*this);
23.467 - return *this;
23.468 + EdgeIt& operator++() {
23.469 + _graph->next(*this);
23.470 + return *this;
23.471 }
23.472
23.473 };
23.474 @@ -540,17 +540,17 @@
23.475 IncEdgeIt(Invalid i) : Edge(i), _direction(false) { }
23.476
23.477 IncEdgeIt(const Graph& graph, const Node &node) : _graph(&graph) {
23.478 - _graph->firstInc(*this, _direction, node);
23.479 + _graph->firstInc(*this, _direction, node);
23.480 }
23.481
23.482 IncEdgeIt(const Graph& graph, const Edge &edge, const Node &node)
23.483 - : _graph(&graph), Edge(edge) {
23.484 - _direction = (_graph->source(edge) == node);
23.485 + : _graph(&graph), Edge(edge) {
23.486 + _direction = (_graph->source(edge) == node);
23.487 }
23.488
23.489 IncEdgeIt& operator++() {
23.490 - _graph->nextInc(*this, _direction);
23.491 - return *this;
23.492 + _graph->nextInc(*this, _direction);
23.493 + return *this;
23.494 }
23.495 };
23.496
23.497 @@ -598,74 +598,74 @@
23.498 // Mappable extension
23.499
23.500 template <typename _Value>
23.501 - class NodeMap
23.502 + class NodeMap
23.503 : public MapExtender<DefaultMap<Graph, Node, _Value> > {
23.504 public:
23.505 typedef GraphExtender Graph;
23.506 typedef MapExtender<DefaultMap<Graph, Node, _Value> > Parent;
23.507
23.508 - NodeMap(const Graph& graph)
23.509 - : Parent(graph) {}
23.510 - NodeMap(const Graph& graph, const _Value& value)
23.511 - : Parent(graph, value) {}
23.512 + NodeMap(const Graph& graph)
23.513 + : Parent(graph) {}
23.514 + NodeMap(const Graph& graph, const _Value& value)
23.515 + : Parent(graph, value) {}
23.516
23.517 NodeMap& operator=(const NodeMap& cmap) {
23.518 - return operator=<NodeMap>(cmap);
23.519 + return operator=<NodeMap>(cmap);
23.520 }
23.521
23.522 template <typename CMap>
23.523 NodeMap& operator=(const CMap& cmap) {
23.524 Parent::operator=(cmap);
23.525 - return *this;
23.526 + return *this;
23.527 }
23.528
23.529 };
23.530
23.531 template <typename _Value>
23.532 - class ArcMap
23.533 + class ArcMap
23.534 : public MapExtender<DefaultMap<Graph, Arc, _Value> > {
23.535 public:
23.536 typedef GraphExtender Graph;
23.537 typedef MapExtender<DefaultMap<Graph, Arc, _Value> > Parent;
23.538
23.539 - ArcMap(const Graph& graph)
23.540 - : Parent(graph) {}
23.541 - ArcMap(const Graph& graph, const _Value& value)
23.542 - : Parent(graph, value) {}
23.543 + ArcMap(const Graph& graph)
23.544 + : Parent(graph) {}
23.545 + ArcMap(const Graph& graph, const _Value& value)
23.546 + : Parent(graph, value) {}
23.547
23.548 ArcMap& operator=(const ArcMap& cmap) {
23.549 - return operator=<ArcMap>(cmap);
23.550 + return operator=<ArcMap>(cmap);
23.551 }
23.552
23.553 template <typename CMap>
23.554 ArcMap& operator=(const CMap& cmap) {
23.555 Parent::operator=(cmap);
23.556 - return *this;
23.557 + return *this;
23.558 }
23.559 };
23.560
23.561
23.562 template <typename _Value>
23.563 - class EdgeMap
23.564 + class EdgeMap
23.565 : public MapExtender<DefaultMap<Graph, Edge, _Value> > {
23.566 public:
23.567 typedef GraphExtender Graph;
23.568 typedef MapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
23.569
23.570 - EdgeMap(const Graph& graph)
23.571 - : Parent(graph) {}
23.572 + EdgeMap(const Graph& graph)
23.573 + : Parent(graph) {}
23.574
23.575 - EdgeMap(const Graph& graph, const _Value& value)
23.576 - : Parent(graph, value) {}
23.577 + EdgeMap(const Graph& graph, const _Value& value)
23.578 + : Parent(graph, value) {}
23.579
23.580 EdgeMap& operator=(const EdgeMap& cmap) {
23.581 - return operator=<EdgeMap>(cmap);
23.582 + return operator=<EdgeMap>(cmap);
23.583 }
23.584
23.585 template <typename CMap>
23.586 EdgeMap& operator=(const CMap& cmap) {
23.587 Parent::operator=(cmap);
23.588 - return *this;
23.589 + return *this;
23.590 }
23.591
23.592 };
23.593 @@ -683,11 +683,11 @@
23.594 notifier(Edge()).add(edge);
23.595 std::vector<Arc> ev;
23.596 ev.push_back(Parent::direct(edge, true));
23.597 - ev.push_back(Parent::direct(edge, false));
23.598 + ev.push_back(Parent::direct(edge, false));
23.599 notifier(Arc()).add(ev);
23.600 return edge;
23.601 }
23.602 -
23.603 +
23.604 void clear() {
23.605 notifier(Arc()).clear();
23.606 notifier(Edge()).clear();
23.607 @@ -696,7 +696,7 @@
23.608 }
23.609
23.610 template <typename Graph, typename NodeRefMap, typename EdgeRefMap>
23.611 - void build(const Graph& graph, NodeRefMap& nodeRef,
23.612 + void build(const Graph& graph, NodeRefMap& nodeRef,
23.613 EdgeRefMap& edgeRef) {
23.614 Parent::build(graph, nodeRef, edgeRef);
23.615 notifier(Node()).build();
23.616 @@ -708,14 +708,14 @@
23.617 Arc arc;
23.618 Parent::firstOut(arc, node);
23.619 while (arc != INVALID ) {
23.620 - erase(arc);
23.621 - Parent::firstOut(arc, node);
23.622 - }
23.623 + erase(arc);
23.624 + Parent::firstOut(arc, node);
23.625 + }
23.626
23.627 Parent::firstIn(arc, node);
23.628 while (arc != INVALID ) {
23.629 - erase(arc);
23.630 - Parent::firstIn(arc, node);
23.631 + erase(arc);
23.632 + Parent::firstIn(arc, node);
23.633 }
23.634
23.635 notifier(Node()).erase(node);
23.636 @@ -725,23 +725,23 @@
23.637 void erase(const Edge& edge) {
23.638 std::vector<Arc> av;
23.639 av.push_back(Parent::direct(edge, true));
23.640 - av.push_back(Parent::direct(edge, false));
23.641 + av.push_back(Parent::direct(edge, false));
23.642 notifier(Arc()).erase(av);
23.643 notifier(Edge()).erase(edge);
23.644 Parent::erase(edge);
23.645 }
23.646
23.647 GraphExtender() {
23.648 - node_notifier.setContainer(*this);
23.649 + node_notifier.setContainer(*this);
23.650 arc_notifier.setContainer(*this);
23.651 edge_notifier.setContainer(*this);
23.652 - }
23.653 + }
23.654
23.655 ~GraphExtender() {
23.656 edge_notifier.clear();
23.657 arc_notifier.clear();
23.658 - node_notifier.clear();
23.659 - }
23.660 + node_notifier.clear();
23.661 + }
23.662
23.663 };
23.664
24.1 --- a/lemon/bits/invalid.h Sun Jul 13 16:46:56 2008 +0100
24.2 +++ b/lemon/bits/invalid.h Sun Jul 13 19:51:02 2008 +0100
24.3 @@ -1,6 +1,6 @@
24.4 -/* -*- C++ -*-
24.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
24.6 *
24.7 - * This file is a part of LEMON, a generic C++ optimization library
24.8 + * This file is a part of LEMON, a generic C++ optimization library.
24.9 *
24.10 * Copyright (C) 2003-2008
24.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
24.12 @@ -34,7 +34,7 @@
24.13 bool operator!=(Invalid) { return false; }
24.14 bool operator< (Invalid) { return false; }
24.15 };
24.16 -
24.17 +
24.18 /// \brief Invalid iterators.
24.19 ///
24.20 /// \ref Invalid is a global type that converts to each iterator
24.21 @@ -52,4 +52,4 @@
24.22 } //namespace lemon
24.23
24.24 #endif
24.25 -
24.26 +
25.1 --- a/lemon/bits/map_extender.h Sun Jul 13 16:46:56 2008 +0100
25.2 +++ b/lemon/bits/map_extender.h Sun Jul 13 19:51:02 2008 +0100
25.3 @@ -1,6 +1,6 @@
25.4 -/* -*- C++ -*-
25.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
25.6 *
25.7 - * This file is a part of LEMON, a generic C++ optimization library
25.8 + * This file is a part of LEMON, a generic C++ optimization library.
25.9 *
25.10 * Copyright (C) 2003-2008
25.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
25.12 @@ -32,7 +32,7 @@
25.13 namespace lemon {
25.14
25.15 /// \ingroup graphbits
25.16 - ///
25.17 + ///
25.18 /// \brief Extender for maps
25.19 template <typename _Map>
25.20 class MapExtender : public _Map {
25.21 @@ -56,10 +56,10 @@
25.22
25.23 public:
25.24
25.25 - MapExtender(const Graph& graph)
25.26 + MapExtender(const Graph& graph)
25.27 : Parent(graph) {}
25.28
25.29 - MapExtender(const Graph& graph, const Value& value)
25.30 + MapExtender(const Graph& graph, const Value& value)
25.31 : Parent(graph, value) {}
25.32
25.33 MapExtender& operator=(const MapExtender& cmap) {
25.34 @@ -70,14 +70,14 @@
25.35 MapExtender& operator=(const CMap& cmap) {
25.36 Parent::operator=(cmap);
25.37 return *this;
25.38 - }
25.39 + }
25.40
25.41 class MapIt : public Item {
25.42 public:
25.43 -
25.44 +
25.45 typedef Item Parent;
25.46 typedef typename Map::Value Value;
25.47 -
25.48 +
25.49 MapIt() {}
25.50
25.51 MapIt(Invalid i) : Parent(i) { }
25.52 @@ -86,29 +86,29 @@
25.53 map.notifier()->first(*this);
25.54 }
25.55
25.56 - MapIt(const Map& _map, const Item& item)
25.57 - : Parent(item), map(_map) {}
25.58 + MapIt(const Map& _map, const Item& item)
25.59 + : Parent(item), map(_map) {}
25.60
25.61 - MapIt& operator++() {
25.62 - map.notifier()->next(*this);
25.63 - return *this;
25.64 + MapIt& operator++() {
25.65 + map.notifier()->next(*this);
25.66 + return *this;
25.67 }
25.68 -
25.69 +
25.70 typename MapTraits<Map>::ConstReturnValue operator*() const {
25.71 - return map[*this];
25.72 + return map[*this];
25.73 }
25.74
25.75 typename MapTraits<Map>::ReturnValue operator*() {
25.76 - return map[*this];
25.77 + return map[*this];
25.78 }
25.79 -
25.80 +
25.81 void set(const Value& value) {
25.82 - map.set(*this, value);
25.83 + map.set(*this, value);
25.84 }
25.85 -
25.86 +
25.87 protected:
25.88 Map& map;
25.89 -
25.90 +
25.91 };
25.92
25.93 class ConstMapIt : public Item {
25.94 @@ -117,7 +117,7 @@
25.95 typedef Item Parent;
25.96
25.97 typedef typename Map::Value Value;
25.98 -
25.99 +
25.100 ConstMapIt() {}
25.101
25.102 ConstMapIt(Invalid i) : Parent(i) { }
25.103 @@ -126,16 +126,16 @@
25.104 map.notifier()->first(*this);
25.105 }
25.106
25.107 - ConstMapIt(const Map& _map, const Item& item)
25.108 - : Parent(item), map(_map) {}
25.109 + ConstMapIt(const Map& _map, const Item& item)
25.110 + : Parent(item), map(_map) {}
25.111
25.112 - ConstMapIt& operator++() {
25.113 - map.notifier()->next(*this);
25.114 - return *this;
25.115 + ConstMapIt& operator++() {
25.116 + map.notifier()->next(*this);
25.117 + return *this;
25.118 }
25.119
25.120 typename MapTraits<Map>::ConstReturnValue operator*() const {
25.121 - return map[*this];
25.122 + return map[*this];
25.123 }
25.124
25.125 protected:
25.126 @@ -144,9 +144,9 @@
25.127
25.128 class ItemIt : public Item {
25.129 public:
25.130 -
25.131 +
25.132 typedef Item Parent;
25.133 -
25.134 +
25.135 ItemIt() {}
25.136
25.137 ItemIt(Invalid i) : Parent(i) { }
25.138 @@ -155,22 +155,22 @@
25.139 map.notifier()->first(*this);
25.140 }
25.141
25.142 - ItemIt(const Map& _map, const Item& item)
25.143 - : Parent(item), map(_map) {}
25.144 + ItemIt(const Map& _map, const Item& item)
25.145 + : Parent(item), map(_map) {}
25.146
25.147 - ItemIt& operator++() {
25.148 - map.notifier()->next(*this);
25.149 - return *this;
25.150 + ItemIt& operator++() {
25.151 + map.notifier()->next(*this);
25.152 + return *this;
25.153 }
25.154
25.155 protected:
25.156 const Map& map;
25.157 -
25.158 +
25.159 };
25.160 };
25.161
25.162 /// \ingroup graphbits
25.163 - ///
25.164 + ///
25.165 /// \brief Extender for maps which use a subset of the items.
25.166 template <typename _Graph, typename _Map>
25.167 class SubMapExtender : public _Map {
25.168 @@ -194,10 +194,10 @@
25.169
25.170 public:
25.171
25.172 - SubMapExtender(const Graph& _graph)
25.173 + SubMapExtender(const Graph& _graph)
25.174 : Parent(_graph), graph(_graph) {}
25.175
25.176 - SubMapExtender(const Graph& _graph, const Value& _value)
25.177 + SubMapExtender(const Graph& _graph, const Value& _value)
25.178 : Parent(_graph, _value), graph(_graph) {}
25.179
25.180 SubMapExtender& operator=(const SubMapExtender& cmap) {
25.181 @@ -212,14 +212,14 @@
25.182 Parent::set(it, cmap[it]);
25.183 }
25.184 return *this;
25.185 - }
25.186 + }
25.187
25.188 class MapIt : public Item {
25.189 public:
25.190 -
25.191 +
25.192 typedef Item Parent;
25.193 typedef typename Map::Value Value;
25.194 -
25.195 +
25.196 MapIt() {}
25.197
25.198 MapIt(Invalid i) : Parent(i) { }
25.199 @@ -228,29 +228,29 @@
25.200 map.graph.first(*this);
25.201 }
25.202
25.203 - MapIt(const Map& _map, const Item& item)
25.204 - : Parent(item), map(_map) {}
25.205 + MapIt(const Map& _map, const Item& item)
25.206 + : Parent(item), map(_map) {}
25.207
25.208 - MapIt& operator++() {
25.209 - map.graph.next(*this);
25.210 - return *this;
25.211 + MapIt& operator++() {
25.212 + map.graph.next(*this);
25.213 + return *this;
25.214 }
25.215 -
25.216 +
25.217 typename MapTraits<Map>::ConstReturnValue operator*() const {
25.218 - return map[*this];
25.219 + return map[*this];
25.220 }
25.221
25.222 typename MapTraits<Map>::ReturnValue operator*() {
25.223 - return map[*this];
25.224 + return map[*this];
25.225 }
25.226 -
25.227 +
25.228 void set(const Value& value) {
25.229 - map.set(*this, value);
25.230 + map.set(*this, value);
25.231 }
25.232 -
25.233 +
25.234 protected:
25.235 Map& map;
25.236 -
25.237 +
25.238 };
25.239
25.240 class ConstMapIt : public Item {
25.241 @@ -259,7 +259,7 @@
25.242 typedef Item Parent;
25.243
25.244 typedef typename Map::Value Value;
25.245 -
25.246 +
25.247 ConstMapIt() {}
25.248
25.249 ConstMapIt(Invalid i) : Parent(i) { }
25.250 @@ -268,16 +268,16 @@
25.251 map.graph.first(*this);
25.252 }
25.253
25.254 - ConstMapIt(const Map& _map, const Item& item)
25.255 - : Parent(item), map(_map) {}
25.256 + ConstMapIt(const Map& _map, const Item& item)
25.257 + : Parent(item), map(_map) {}
25.258
25.259 - ConstMapIt& operator++() {
25.260 - map.graph.next(*this);
25.261 - return *this;
25.262 + ConstMapIt& operator++() {
25.263 + map.graph.next(*this);
25.264 + return *this;
25.265 }
25.266
25.267 typename MapTraits<Map>::ConstReturnValue operator*() const {
25.268 - return map[*this];
25.269 + return map[*this];
25.270 }
25.271
25.272 protected:
25.273 @@ -286,9 +286,9 @@
25.274
25.275 class ItemIt : public Item {
25.276 public:
25.277 -
25.278 +
25.279 typedef Item Parent;
25.280 -
25.281 +
25.282 ItemIt() {}
25.283
25.284 ItemIt(Invalid i) : Parent(i) { }
25.285 @@ -297,23 +297,23 @@
25.286 map.graph.first(*this);
25.287 }
25.288
25.289 - ItemIt(const Map& _map, const Item& item)
25.290 - : Parent(item), map(_map) {}
25.291 + ItemIt(const Map& _map, const Item& item)
25.292 + : Parent(item), map(_map) {}
25.293
25.294 - ItemIt& operator++() {
25.295 - map.graph.next(*this);
25.296 - return *this;
25.297 + ItemIt& operator++() {
25.298 + map.graph.next(*this);
25.299 + return *this;
25.300 }
25.301
25.302 protected:
25.303 const Map& map;
25.304 -
25.305 +
25.306 };
25.307 -
25.308 +
25.309 private:
25.310
25.311 const Graph& graph;
25.312 -
25.313 +
25.314 };
25.315
25.316 }
26.1 --- a/lemon/bits/path_dump.h Sun Jul 13 16:46:56 2008 +0100
26.2 +++ b/lemon/bits/path_dump.h Sun Jul 13 19:51:02 2008 +0100
26.3 @@ -1,6 +1,6 @@
26.4 -/* -*- C++ -*-
26.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
26.6 *
26.7 - * This file is a part of LEMON, a generic C++ optimization library
26.8 + * This file is a part of LEMON, a generic C++ optimization library.
26.9 *
26.10 * Copyright (C) 2003-2008
26.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
26.12 @@ -53,7 +53,7 @@
26.13 public:
26.14 RevArcIt() {}
26.15 RevArcIt(Invalid) : path(0), current(INVALID) {}
26.16 - RevArcIt(const PredMapPath& _path)
26.17 + RevArcIt(const PredMapPath& _path)
26.18 : path(&_path), current(_path.target) {
26.19 if (path->predMap[current] == INVALID) current = INVALID;
26.20 }
26.21 @@ -68,18 +68,18 @@
26.22 return *this;
26.23 }
26.24
26.25 - bool operator==(const RevArcIt& e) const {
26.26 - return current == e.current;
26.27 + bool operator==(const RevArcIt& e) const {
26.28 + return current == e.current;
26.29 }
26.30
26.31 bool operator!=(const RevArcIt& e) const {
26.32 - return current != e.current;
26.33 + return current != e.current;
26.34 }
26.35
26.36 - bool operator<(const RevArcIt& e) const {
26.37 - return current < e.current;
26.38 + bool operator<(const RevArcIt& e) const {
26.39 + return current < e.current;
26.40 }
26.41 -
26.42 +
26.43 private:
26.44 const PredMapPath* path;
26.45 typename Digraph::Node current;
26.46 @@ -101,11 +101,11 @@
26.47 typedef typename Digraph::Arc Arc;
26.48 typedef _PredMatrixMap PredMatrixMap;
26.49
26.50 - PredMatrixMapPath(const Digraph& _digraph,
26.51 + PredMatrixMapPath(const Digraph& _digraph,
26.52 const PredMatrixMap& _predMatrixMap,
26.53 - typename Digraph::Node _source,
26.54 + typename Digraph::Node _source,
26.55 typename Digraph::Node _target)
26.56 - : digraph(_digraph), predMatrixMap(_predMatrixMap),
26.57 + : digraph(_digraph), predMatrixMap(_predMatrixMap),
26.58 source(_source), target(_target) {}
26.59
26.60 int length() const {
26.61 @@ -127,9 +127,9 @@
26.62 public:
26.63 RevArcIt() {}
26.64 RevArcIt(Invalid) : path(0), current(INVALID) {}
26.65 - RevArcIt(const PredMatrixMapPath& _path)
26.66 + RevArcIt(const PredMatrixMapPath& _path)
26.67 : path(&_path), current(_path.target) {
26.68 - if (path->predMatrixMap(path->source, current) == INVALID)
26.69 + if (path->predMatrixMap(path->source, current) == INVALID)
26.70 current = INVALID;
26.71 }
26.72
26.73 @@ -138,25 +138,25 @@
26.74 }
26.75
26.76 RevArcIt& operator++() {
26.77 - current =
26.78 + current =
26.79 path->digraph.source(path->predMatrixMap(path->source, current));
26.80 - if (path->predMatrixMap(path->source, current) == INVALID)
26.81 + if (path->predMatrixMap(path->source, current) == INVALID)
26.82 current = INVALID;
26.83 return *this;
26.84 }
26.85
26.86 - bool operator==(const RevArcIt& e) const {
26.87 - return current == e.current;
26.88 + bool operator==(const RevArcIt& e) const {
26.89 + return current == e.current;
26.90 }
26.91
26.92 bool operator!=(const RevArcIt& e) const {
26.93 - return current != e.current;
26.94 + return current != e.current;
26.95 }
26.96
26.97 - bool operator<(const RevArcIt& e) const {
26.98 - return current < e.current;
26.99 + bool operator<(const RevArcIt& e) const {
26.100 + return current < e.current;
26.101 }
26.102 -
26.103 +
26.104 private:
26.105 const PredMatrixMapPath* path;
26.106 typename Digraph::Node current;
27.1 --- a/lemon/bits/traits.h Sun Jul 13 16:46:56 2008 +0100
27.2 +++ b/lemon/bits/traits.h Sun Jul 13 19:51:02 2008 +0100
27.3 @@ -1,7 +1,6 @@
27.4 -
27.5 -/* -*- C++ -*-
27.6 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
27.7 *
27.8 - * This file is a part of LEMON, a generic C++ optimization library
27.9 + * This file is a part of LEMON, a generic C++ optimization library.
27.10 *
27.11 * Copyright (C) 2003-2008
27.12 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
27.13 @@ -29,7 +28,7 @@
27.14 namespace lemon {
27.15 template <typename _Graph, typename _Item>
27.16 class ItemSetTraits {};
27.17 -
27.18 +
27.19
27.20 template <typename Graph, typename Enable = void>
27.21 struct NodeNotifierIndicator {
27.22 @@ -37,16 +36,16 @@
27.23 };
27.24 template <typename Graph>
27.25 struct NodeNotifierIndicator<
27.26 - Graph,
27.27 + Graph,
27.28 typename enable_if<typename Graph::NodeNotifier::Notifier, void>::type
27.29 - > {
27.30 + > {
27.31 typedef typename Graph::NodeNotifier Type;
27.32 };
27.33
27.34 template <typename _Graph>
27.35 class ItemSetTraits<_Graph, typename _Graph::Node> {
27.36 public:
27.37 -
27.38 +
27.39 typedef _Graph Graph;
27.40
27.41 typedef typename Graph::Node Item;
27.42 @@ -57,13 +56,13 @@
27.43 template <typename _Value>
27.44 class Map : public Graph::template NodeMap<_Value> {
27.45 public:
27.46 - typedef typename Graph::template NodeMap<_Value> Parent;
27.47 - typedef typename Graph::template NodeMap<_Value> Type;
27.48 + typedef typename Graph::template NodeMap<_Value> Parent;
27.49 + typedef typename Graph::template NodeMap<_Value> Type;
27.50 typedef typename Parent::Value Value;
27.51
27.52 Map(const Graph& _digraph) : Parent(_digraph) {}
27.53 - Map(const Graph& _digraph, const Value& _value)
27.54 - : Parent(_digraph, _value) {}
27.55 + Map(const Graph& _digraph, const Value& _value)
27.56 + : Parent(_digraph, _value) {}
27.57
27.58 };
27.59
27.60 @@ -75,16 +74,16 @@
27.61 };
27.62 template <typename Graph>
27.63 struct ArcNotifierIndicator<
27.64 - Graph,
27.65 + Graph,
27.66 typename enable_if<typename Graph::ArcNotifier::Notifier, void>::type
27.67 - > {
27.68 + > {
27.69 typedef typename Graph::ArcNotifier Type;
27.70 };
27.71
27.72 template <typename _Graph>
27.73 class ItemSetTraits<_Graph, typename _Graph::Arc> {
27.74 public:
27.75 -
27.76 +
27.77 typedef _Graph Graph;
27.78
27.79 typedef typename Graph::Arc Item;
27.80 @@ -95,13 +94,13 @@
27.81 template <typename _Value>
27.82 class Map : public Graph::template ArcMap<_Value> {
27.83 public:
27.84 - typedef typename Graph::template ArcMap<_Value> Parent;
27.85 - typedef typename Graph::template ArcMap<_Value> Type;
27.86 + typedef typename Graph::template ArcMap<_Value> Parent;
27.87 + typedef typename Graph::template ArcMap<_Value> Type;
27.88 typedef typename Parent::Value Value;
27.89
27.90 Map(const Graph& _digraph) : Parent(_digraph) {}
27.91 - Map(const Graph& _digraph, const Value& _value)
27.92 - : Parent(_digraph, _value) {}
27.93 + Map(const Graph& _digraph, const Value& _value)
27.94 + : Parent(_digraph, _value) {}
27.95 };
27.96
27.97 };
27.98 @@ -112,16 +111,16 @@
27.99 };
27.100 template <typename Graph>
27.101 struct EdgeNotifierIndicator<
27.102 - Graph,
27.103 + Graph,
27.104 typename enable_if<typename Graph::EdgeNotifier::Notifier, void>::type
27.105 - > {
27.106 + > {
27.107 typedef typename Graph::EdgeNotifier Type;
27.108 };
27.109
27.110 template <typename _Graph>
27.111 class ItemSetTraits<_Graph, typename _Graph::Edge> {
27.112 public:
27.113 -
27.114 +
27.115 typedef _Graph Graph;
27.116
27.117 typedef typename Graph::Edge Item;
27.118 @@ -132,13 +131,13 @@
27.119 template <typename _Value>
27.120 class Map : public Graph::template EdgeMap<_Value> {
27.121 public:
27.122 - typedef typename Graph::template EdgeMap<_Value> Parent;
27.123 - typedef typename Graph::template EdgeMap<_Value> Type;
27.124 + typedef typename Graph::template EdgeMap<_Value> Parent;
27.125 + typedef typename Graph::template EdgeMap<_Value> Type;
27.126 typedef typename Parent::Value Value;
27.127
27.128 Map(const Graph& _digraph) : Parent(_digraph) {}
27.129 - Map(const Graph& _digraph, const Value& _value)
27.130 - : Parent(_digraph, _value) {}
27.131 + Map(const Graph& _digraph, const Value& _value)
27.132 + : Parent(_digraph, _value) {}
27.133 };
27.134
27.135 };
27.136 @@ -156,17 +155,17 @@
27.137
27.138 template <typename Map>
27.139 struct MapTraits<
27.140 - Map, typename enable_if<typename Map::ReferenceMapTag, void>::type >
27.141 + Map, typename enable_if<typename Map::ReferenceMapTag, void>::type >
27.142 {
27.143 typedef True ReferenceMapTag;
27.144 -
27.145 +
27.146 typedef typename Map::Key Key;
27.147 typedef typename Map::Value Value;
27.148
27.149 typedef typename Map::ConstReference ConstReturnValue;
27.150 typedef typename Map::Reference ReturnValue;
27.151
27.152 - typedef typename Map::ConstReference ConstReference;
27.153 + typedef typename Map::ConstReference ConstReference;
27.154 typedef typename Map::Reference Reference;
27.155 };
27.156
27.157 @@ -184,11 +183,11 @@
27.158
27.159 template <typename MatrixMap>
27.160 struct MatrixMapTraits<
27.161 - MatrixMap, typename enable_if<typename MatrixMap::ReferenceMapTag,
27.162 - void>::type >
27.163 + MatrixMap, typename enable_if<typename MatrixMap::ReferenceMapTag,
27.164 + void>::type >
27.165 {
27.166 typedef True ReferenceMapTag;
27.167 -
27.168 +
27.169 typedef typename MatrixMap::FirstKey FirstKey;
27.170 typedef typename MatrixMap::SecondKey SecondKey;
27.171 typedef typename MatrixMap::Value Value;
27.172 @@ -196,7 +195,7 @@
27.173 typedef typename MatrixMap::ConstReference ConstReturnValue;
27.174 typedef typename MatrixMap::Reference ReturnValue;
27.175
27.176 - typedef typename MatrixMap::ConstReference ConstReference;
27.177 + typedef typename MatrixMap::ConstReference ConstReference;
27.178 typedef typename MatrixMap::Reference Reference;
27.179 };
27.180
27.181 @@ -209,7 +208,7 @@
27.182
27.183 template <typename Graph>
27.184 struct NodeNumTagIndicator<
27.185 - Graph,
27.186 + Graph,
27.187 typename enable_if<typename Graph::NodeNumTag, void>::type
27.188 > {
27.189 static const bool value = true;
27.190 @@ -222,7 +221,7 @@
27.191
27.192 template <typename Graph>
27.193 struct EdgeNumTagIndicator<
27.194 - Graph,
27.195 + Graph,
27.196 typename enable_if<typename Graph::EdgeNumTag, void>::type
27.197 > {
27.198 static const bool value = true;
27.199 @@ -235,7 +234,7 @@
27.200
27.201 template <typename Graph>
27.202 struct FindEdgeTagIndicator<
27.203 - Graph,
27.204 + Graph,
27.205 typename enable_if<typename Graph::FindEdgeTag, void>::type
27.206 > {
27.207 static const bool value = true;
27.208 @@ -248,7 +247,7 @@
27.209
27.210 template <typename Graph>
27.211 struct UndirectedTagIndicator<
27.212 - Graph,
27.213 + Graph,
27.214 typename enable_if<typename Graph::UndirectedTag, void>::type
27.215 > {
27.216 static const bool value = true;
27.217 @@ -261,7 +260,7 @@
27.218
27.219 template <typename Graph>
27.220 struct BuildTagIndicator<
27.221 - Graph,
27.222 + Graph,
27.223 typename enable_if<typename Graph::BuildTag, void>::type
27.224 > {
27.225 static const bool value = true;
28.1 --- a/lemon/bits/utility.h Sun Jul 13 16:46:56 2008 +0100
28.2 +++ b/lemon/bits/utility.h Sun Jul 13 19:51:02 2008 +0100
28.3 @@ -1,6 +1,6 @@
28.4 -/* -*- C++ -*-
28.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
28.6 *
28.7 - * This file is a part of LEMON, a generic C++ optimization library
28.8 + * This file is a part of LEMON, a generic C++ optimization library.
28.9 *
28.10 * Copyright (C) 2003-2008
28.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
28.12 @@ -83,13 +83,13 @@
28.13 template<int T> struct dummy { dummy(int) {} };
28.14
28.15 /**************** enable_if from BOOST ****************/
28.16 -
28.17 +
28.18 template <typename Type, typename T = void>
28.19 struct exists {
28.20 typedef T type;
28.21 };
28.22
28.23 -
28.24 +
28.25 template <bool B, class T = void>
28.26 struct enable_if_c {
28.27 typedef T type;
28.28 @@ -98,7 +98,7 @@
28.29 template <class T>
28.30 struct enable_if_c<false, T> {};
28.31
28.32 - template <class Cond, class T = void>
28.33 + template <class Cond, class T = void>
28.34 struct enable_if : public enable_if_c<Cond::value, T> {};
28.35
28.36 template <bool B, class T>
28.37 @@ -109,7 +109,7 @@
28.38 template <class T>
28.39 struct lazy_enable_if_c<false, T> {};
28.40
28.41 - template <class Cond, class T>
28.42 + template <class Cond, class T>
28.43 struct lazy_enable_if : public lazy_enable_if_c<Cond::value, T> {};
28.44
28.45
28.46 @@ -121,7 +121,7 @@
28.47 template <class T>
28.48 struct disable_if_c<true, T> {};
28.49
28.50 - template <class Cond, class T = void>
28.51 + template <class Cond, class T = void>
28.52 struct disable_if : public disable_if_c<Cond::value, T> {};
28.53
28.54 template <bool B, class T>
28.55 @@ -132,7 +132,7 @@
28.56 template <class T>
28.57 struct lazy_disable_if_c<true, T> {};
28.58
28.59 - template <class Cond, class T>
28.60 + template <class Cond, class T>
28.61 struct lazy_disable_if : public lazy_disable_if_c<Cond::value, T> {};
28.62
28.63 } // namespace lemon
29.1 --- a/lemon/bits/vector_map.h Sun Jul 13 16:46:56 2008 +0100
29.2 +++ b/lemon/bits/vector_map.h Sun Jul 13 19:51:02 2008 +0100
29.3 @@ -1,6 +1,6 @@
29.4 -/* -*- C++ -*-
29.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
29.6 *
29.7 - * This file is a part of LEMON, a generic C++ optimization library
29.8 + * This file is a part of LEMON, a generic C++ optimization library.
29.9 *
29.10 * Copyright (C) 2003-2008
29.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
29.12 @@ -49,16 +49,16 @@
29.13 /// \tparam _Value The value type of the map.
29.14 /// \todo Fix the doc: there is _Graph parameter instead of _Notifier.
29.15 template <typename _Graph, typename _Item, typename _Value>
29.16 - class VectorMap
29.17 + class VectorMap
29.18 : public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase {
29.19 private:
29.20 -
29.21 +
29.22 /// The container type of the map.
29.23 - typedef std::vector<_Value> Container;
29.24 + typedef std::vector<_Value> Container;
29.25
29.26 public:
29.27
29.28 - /// The graph type of the map.
29.29 + /// The graph type of the map.
29.30 typedef _Graph Graph;
29.31 /// The item type of the map.
29.32 typedef _Item Item;
29.33 @@ -93,9 +93,9 @@
29.34 container.resize(Parent::notifier()->maxId() + 1);
29.35 }
29.36
29.37 - /// \brief Constructor uses given value to initialize the map.
29.38 + /// \brief Constructor uses given value to initialize the map.
29.39 ///
29.40 - /// It constructs a map uses a given value to initialize the map.
29.41 + /// It constructs a map uses a given value to initialize the map.
29.42 /// It adds all the items of the graph to the map.
29.43 VectorMap(const Graph& graph, const Value& value) {
29.44 Parent::attach(graph.notifier(Item()));
29.45 @@ -107,18 +107,18 @@
29.46 /// Copy constructor.
29.47 VectorMap(const VectorMap& _copy) : Parent() {
29.48 if (_copy.attached()) {
29.49 - Parent::attach(*_copy.notifier());
29.50 - container = _copy.container;
29.51 + Parent::attach(*_copy.notifier());
29.52 + container = _copy.container;
29.53 }
29.54 }
29.55
29.56 /// \brief Assign operator.
29.57 ///
29.58 /// This operator assigns for each item in the map the
29.59 - /// value mapped to the same item in the copied map.
29.60 + /// value mapped to the same item in the copied map.
29.61 /// The parameter map should be indiced with the same
29.62 /// itemset because this assign operator does not change
29.63 - /// the container of the map.
29.64 + /// the container of the map.
29.65 VectorMap& operator=(const VectorMap& cmap) {
29.66 return operator=<VectorMap>(cmap);
29.67 }
29.68 @@ -129,7 +129,7 @@
29.69 /// The given parameter should be conform to the ReadMap
29.70 /// concecpt and could be indiced by the current item set of
29.71 /// the NodeMap. In this case the value for each item
29.72 - /// is assigned by the value of the given ReadMap.
29.73 + /// is assigned by the value of the given ReadMap.
29.74 template <typename CMap>
29.75 VectorMap& operator=(const CMap& cmap) {
29.76 checkConcept<concepts::ReadMap<Key, _Value>, CMap>();
29.77 @@ -140,21 +140,21 @@
29.78 }
29.79 return *this;
29.80 }
29.81 -
29.82 +
29.83 public:
29.84
29.85 /// \brief The subcript operator.
29.86 ///
29.87 /// The subscript operator. The map can be subscripted by the
29.88 - /// actual items of the graph.
29.89 + /// actual items of the graph.
29.90 Reference operator[](const Key& key) {
29.91 return container[Parent::notifier()->id(key)];
29.92 - }
29.93 -
29.94 + }
29.95 +
29.96 /// \brief The const subcript operator.
29.97 ///
29.98 /// The const subscript operator. The map can be subscripted by the
29.99 - /// actual items of the graph.
29.100 + /// actual items of the graph.
29.101 ConstReference operator[](const Key& key) const {
29.102 return container[Parent::notifier()->id(key)];
29.103 }
29.104 @@ -170,20 +170,20 @@
29.105 protected:
29.106
29.107 /// \brief Adds a new key to the map.
29.108 - ///
29.109 + ///
29.110 /// It adds a new key to the map. It called by the observer notifier
29.111 - /// and it overrides the add() member function of the observer base.
29.112 + /// and it overrides the add() member function of the observer base.
29.113 virtual void add(const Key& key) {
29.114 int id = Parent::notifier()->id(key);
29.115 if (id >= int(container.size())) {
29.116 - container.resize(id + 1);
29.117 + container.resize(id + 1);
29.118 }
29.119 }
29.120
29.121 /// \brief Adds more new keys to the map.
29.122 - ///
29.123 + ///
29.124 /// It adds more new keys to the map. It called by the observer notifier
29.125 - /// and it overrides the add() member function of the observer base.
29.126 + /// and it overrides the add() member function of the observer base.
29.127 virtual void add(const std::vector<Key>& keys) {
29.128 int max = container.size() - 1;
29.129 for (int i = 0; i < int(keys.size()); ++i) {
29.130 @@ -198,7 +198,7 @@
29.131 /// \brief Erase a key from the map.
29.132 ///
29.133 /// Erase a key from the map. It called by the observer notifier
29.134 - /// and it overrides the erase() member function of the observer base.
29.135 + /// and it overrides the erase() member function of the observer base.
29.136 virtual void erase(const Key& key) {
29.137 container[Parent::notifier()->id(key)] = Value();
29.138 }
29.139 @@ -206,18 +206,18 @@
29.140 /// \brief Erase more keys from the map.
29.141 ///
29.142 /// Erase more keys from the map. It called by the observer notifier
29.143 - /// and it overrides the erase() member function of the observer base.
29.144 + /// and it overrides the erase() member function of the observer base.
29.145 virtual void erase(const std::vector<Key>& keys) {
29.146 for (int i = 0; i < int(keys.size()); ++i) {
29.147 - container[Parent::notifier()->id(keys[i])] = Value();
29.148 + container[Parent::notifier()->id(keys[i])] = Value();
29.149 }
29.150 }
29.151 -
29.152 +
29.153 /// \brief Buildes the map.
29.154 - ///
29.155 + ///
29.156 /// It buildes the map. It called by the observer notifier
29.157 /// and it overrides the build() member function of the observer base.
29.158 - virtual void build() {
29.159 + virtual void build() {
29.160 int size = Parent::notifier()->maxId() + 1;
29.161 container.reserve(size);
29.162 container.resize(size);
29.163 @@ -226,13 +226,13 @@
29.164 /// \brief Clear the map.
29.165 ///
29.166 /// It erase all items from the map. It called by the observer notifier
29.167 - /// and it overrides the clear() member function of the observer base.
29.168 - virtual void clear() {
29.169 + /// and it overrides the clear() member function of the observer base.
29.170 + virtual void clear() {
29.171 container.clear();
29.172 }
29.173 -
29.174 +
29.175 private:
29.176 -
29.177 +
29.178 Container container;
29.179
29.180 };
30.1 --- a/lemon/color.cc Sun Jul 13 16:46:56 2008 +0100
30.2 +++ b/lemon/color.cc Sun Jul 13 19:51:02 2008 +0100
30.3 @@ -1,6 +1,6 @@
30.4 -/* -*- C++ -*-
30.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
30.6 *
30.7 - * This file is a part of LEMON, a generic C++ optimization library
30.8 + * This file is a part of LEMON, a generic C++ optimization library.
30.9 *
30.10 * Copyright (C) 2003-2008
30.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
30.12 @@ -24,7 +24,7 @@
30.13 namespace lemon {
30.14
30.15 const Color WHITE(1,1,1);
30.16 -
30.17 +
30.18 const Color BLACK(0,0,0);
30.19 const Color RED(1,0,0);
30.20 const Color GREEN(0,1,0);
30.21 @@ -40,5 +40,5 @@
30.22 const Color DARK_YELLOW(.5,.5,0);
30.23 const Color DARK_MAGENTA(.5,0,.5);
30.24 const Color DARK_CYAN(0,.5,.5);
30.25 -
30.26 +
30.27 } //namespace lemon
31.1 --- a/lemon/color.h Sun Jul 13 16:46:56 2008 +0100
31.2 +++ b/lemon/color.h Sun Jul 13 19:51:02 2008 +0100
31.3 @@ -1,6 +1,6 @@
31.4 -/* -*- C++ -*-
31.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
31.6 *
31.7 - * This file is a part of LEMON, a generic C++ optimization library
31.8 + * This file is a part of LEMON, a generic C++ optimization library.
31.9 *
31.10 * Copyright (C) 2003-2008
31.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
31.12 @@ -62,7 +62,7 @@
31.13 };
31.14
31.15 /// White color constant
31.16 - extern const Color WHITE;
31.17 + extern const Color WHITE;
31.18 /// Black color constant
31.19 extern const Color BLACK;
31.20 /// Red color constant
31.21 @@ -130,14 +130,14 @@
31.22 colors.push_back(Color(1,1,0));
31.23 colors.push_back(Color(1,0,1));
31.24 colors.push_back(Color(0,1,1));
31.25 -
31.26 +
31.27 colors.push_back(Color(.5,0,0));
31.28 colors.push_back(Color(0,.5,0));
31.29 colors.push_back(Color(0,0,.5));
31.30 colors.push_back(Color(.5,.5,0));
31.31 colors.push_back(Color(.5,0,.5));
31.32 colors.push_back(Color(0,.5,.5));
31.33 -
31.34 +
31.35 colors.push_back(Color(.5,.5,.5));
31.36 colors.push_back(Color(1,.5,.5));
31.37 colors.push_back(Color(.5,1,.5));
31.38 @@ -145,7 +145,7 @@
31.39 colors.push_back(Color(1,1,.5));
31.40 colors.push_back(Color(1,.5,1));
31.41 colors.push_back(Color(.5,1,1));
31.42 -
31.43 +
31.44 colors.push_back(Color(1,.5,0));
31.45 colors.push_back(Color(.5,1,0));
31.46 colors.push_back(Color(1,0,.5));
31.47 @@ -171,7 +171,7 @@
31.48 colors[i%colors.size()]=c;
31.49 }
31.50 ///Adds a new color to the end of the color list.
31.51 - void add(const Color &c)
31.52 + void add(const Color &c)
31.53 {
31.54 colors.push_back(c);
31.55 }
31.56 @@ -186,7 +186,7 @@
31.57
31.58 ///Returns a \ref Color which is as different from the given parameter
31.59 ///as it is possible.
31.60 - inline Color distantColor(const Color &c)
31.61 + inline Color distantColor(const Color &c)
31.62 {
31.63 return Color(c.red()<.5?1:0,c.green()<.5?1:0,c.blue()<.5?1:0);
31.64 }
32.1 --- a/lemon/concept_check.h Sun Jul 13 16:46:56 2008 +0100
32.2 +++ b/lemon/concept_check.h Sun Jul 13 19:51:02 2008 +0100
32.3 @@ -1,6 +1,6 @@
32.4 -/* -*- C++ -*-
32.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
32.6 *
32.7 - * This file is a part of LEMON, a generic C++ optimization library
32.8 + * This file is a part of LEMON, a generic C++ optimization library.
32.9 *
32.10 * Copyright (C) 2003-2008
32.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
32.12 @@ -36,7 +36,7 @@
32.13 ///\file
32.14 ///\brief Basic utilities for concept checking.
32.15 ///
32.16 -///\todo Are we still using BOOST concept checking utility?
32.17 +///\todo Are we still using BOOST concept checking utility?
32.18 ///Is the BOOST copyright notice necessary?
32.19
32.20 #ifndef LEMON_CONCEPT_CHECK_H
33.1 --- a/lemon/concepts/digraph.h Sun Jul 13 16:46:56 2008 +0100
33.2 +++ b/lemon/concepts/digraph.h Sun Jul 13 19:51:02 2008 +0100
33.3 @@ -1,6 +1,6 @@
33.4 -/* -*- C++ -*-
33.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
33.6 *
33.7 - * This file is a part of LEMON, a generic C++ optimization library
33.8 + * This file is a part of LEMON, a generic C++ optimization library.
33.9 *
33.10 * Copyright (C) 2003-2008
33.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
33.12 @@ -46,13 +46,13 @@
33.13 class Digraph {
33.14 private:
33.15 ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
33.16 -
33.17 +
33.18 ///Digraphs are \e not copy constructible. Use DigraphCopy() instead.
33.19 ///
33.20 Digraph(const Digraph &) {};
33.21 ///\brief Assignment of \ref Digraph "Digraph"s to another ones are
33.22 ///\e not allowed. Use DigraphCopy() instead.
33.23 -
33.24 +
33.25 ///Assignment of \ref Digraph "Digraph"s to another ones are
33.26 ///\e not allowed. Use DigraphCopy() instead.
33.27
33.28 @@ -95,23 +95,23 @@
33.29 bool operator==(Node) const { return true; }
33.30
33.31 /// Inequality operator
33.32 -
33.33 +
33.34 /// \sa operator==(Node n)
33.35 ///
33.36 bool operator!=(Node) const { return true; }
33.37
33.38 - /// Artificial ordering operator.
33.39 -
33.40 - /// To allow the use of digraph descriptors as key type in std::map or
33.41 - /// similar associative container we require this.
33.42 - ///
33.43 - /// \note This operator only have to define some strict ordering of
33.44 - /// the items; this order has nothing to do with the iteration
33.45 - /// ordering of the items.
33.46 - bool operator<(Node) const { return false; }
33.47 + /// Artificial ordering operator.
33.48 +
33.49 + /// To allow the use of digraph descriptors as key type in std::map or
33.50 + /// similar associative container we require this.
33.51 + ///
33.52 + /// \note This operator only have to define some strict ordering of
33.53 + /// the items; this order has nothing to do with the iteration
33.54 + /// ordering of the items.
33.55 + bool operator<(Node) const { return false; }
33.56
33.57 };
33.58 -
33.59 +
33.60 /// This iterator goes through each node.
33.61
33.62 /// This iterator goes through each node.
33.63 @@ -129,7 +129,7 @@
33.64 /// to an undefined value.
33.65 NodeIt() { }
33.66 /// Copy constructor.
33.67 -
33.68 +
33.69 /// Copy constructor.
33.70 ///
33.71 NodeIt(const NodeIt& n) : Node(n) { }
33.72 @@ -145,9 +145,9 @@
33.73 NodeIt(const Digraph&) { }
33.74 /// Node -> NodeIt conversion.
33.75
33.76 - /// Sets the iterator to the node of \c the digraph pointed by
33.77 - /// the trivial iterator.
33.78 - /// This feature necessitates that each time we
33.79 + /// Sets the iterator to the node of \c the digraph pointed by
33.80 + /// the trivial iterator.
33.81 + /// This feature necessitates that each time we
33.82 /// iterate the arc-set, the iteration order is the same.
33.83 NodeIt(const Digraph&, const Node&) { }
33.84 /// Next node.
33.85 @@ -156,8 +156,8 @@
33.86 ///
33.87 NodeIt& operator++() { return *this; }
33.88 };
33.89 -
33.90 -
33.91 +
33.92 +
33.93 /// Class for identifying an arc of the digraph
33.94
33.95 /// This class identifies an arc of the digraph. It also serves
33.96 @@ -191,17 +191,17 @@
33.97 ///
33.98 bool operator!=(Arc) const { return true; }
33.99
33.100 - /// Artificial ordering operator.
33.101 -
33.102 - /// To allow the use of digraph descriptors as key type in std::map or
33.103 - /// similar associative container we require this.
33.104 - ///
33.105 - /// \note This operator only have to define some strict ordering of
33.106 - /// the items; this order has nothing to do with the iteration
33.107 - /// ordering of the items.
33.108 - bool operator<(Arc) const { return false; }
33.109 + /// Artificial ordering operator.
33.110 +
33.111 + /// To allow the use of digraph descriptors as key type in std::map or
33.112 + /// similar associative container we require this.
33.113 + ///
33.114 + /// \note This operator only have to define some strict ordering of
33.115 + /// the items; this order has nothing to do with the iteration
33.116 + /// ordering of the items.
33.117 + bool operator<(Arc) const { return false; }
33.118 };
33.119 -
33.120 +
33.121 /// This iterator goes trough the outgoing arcs of a node.
33.122
33.123 /// This iterator goes trough the \e outgoing arcs of a certain node
33.124 @@ -213,7 +213,7 @@
33.125 /// int count=0;
33.126 /// for (Digraph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
33.127 ///\endcode
33.128 -
33.129 +
33.130 class OutArcIt : public Arc {
33.131 public:
33.132 /// Default constructor
33.133 @@ -232,19 +232,19 @@
33.134 ///
33.135 OutArcIt(Invalid) { }
33.136 /// This constructor sets the iterator to the first outgoing arc.
33.137 -
33.138 +
33.139 /// This constructor sets the iterator to the first outgoing arc of
33.140 /// the node.
33.141 OutArcIt(const Digraph&, const Node&) { }
33.142 /// Arc -> OutArcIt conversion
33.143
33.144 /// Sets the iterator to the value of the trivial iterator.
33.145 - /// This feature necessitates that each time we
33.146 + /// This feature necessitates that each time we
33.147 /// iterate the arc-set, the iteration order is the same.
33.148 OutArcIt(const Digraph&, const Arc&) { }
33.149 ///Next outgoing arc
33.150 -
33.151 - /// Assign the iterator to the next
33.152 +
33.153 + /// Assign the iterator to the next
33.154 /// outgoing arc of the corresponding node.
33.155 OutArcIt& operator++() { return *this; }
33.156 };
33.157 @@ -279,14 +279,14 @@
33.158 ///
33.159 InArcIt(Invalid) { }
33.160 /// This constructor sets the iterator to first incoming arc.
33.161 -
33.162 +
33.163 /// This constructor set the iterator to the first incoming arc of
33.164 /// the node.
33.165 InArcIt(const Digraph&, const Node&) { }
33.166 /// Arc -> InArcIt conversion
33.167
33.168 /// Sets the iterator to the value of the trivial iterator \c e.
33.169 - /// This feature necessitates that each time we
33.170 + /// This feature necessitates that each time we
33.171 /// iterate the arc-set, the iteration order is the same.
33.172 InArcIt(const Digraph&, const Arc&) { }
33.173 /// Next incoming arc
33.174 @@ -322,18 +322,18 @@
33.175 ///
33.176 ArcIt(Invalid) { }
33.177 /// This constructor sets the iterator to the first arc.
33.178 -
33.179 +
33.180 /// This constructor sets the iterator to the first arc of \c g.
33.181 ///@param g the digraph
33.182 ArcIt(const Digraph& g) { ignore_unused_variable_warning(g); }
33.183 /// Arc -> ArcIt conversion
33.184
33.185 /// Sets the iterator to the value of the trivial iterator \c e.
33.186 - /// This feature necessitates that each time we
33.187 + /// This feature necessitates that each time we
33.188 /// iterate the arc-set, the iteration order is the same.
33.189 - ArcIt(const Digraph&, const Arc&) { }
33.190 + ArcIt(const Digraph&, const Arc&) { }
33.191 ///Next arc
33.192 -
33.193 +
33.194 /// Assign the iterator to the next arc.
33.195 ArcIt& operator++() { return *this; }
33.196 };
33.197 @@ -349,26 +349,26 @@
33.198 Node source(Arc) const { return INVALID; }
33.199
33.200 /// \brief Returns the ID of the node.
33.201 - int id(Node) const { return -1; }
33.202 + int id(Node) const { return -1; }
33.203
33.204 /// \brief Returns the ID of the arc.
33.205 - int id(Arc) const { return -1; }
33.206 + int id(Arc) const { return -1; }
33.207
33.208 /// \brief Returns the node with the given ID.
33.209 ///
33.210 /// \pre The argument should be a valid node ID in the graph.
33.211 - Node nodeFromId(int) const { return INVALID; }
33.212 + Node nodeFromId(int) const { return INVALID; }
33.213
33.214 /// \brief Returns the arc with the given ID.
33.215 ///
33.216 /// \pre The argument should be a valid arc ID in the graph.
33.217 - Arc arcFromId(int) const { return INVALID; }
33.218 + Arc arcFromId(int) const { return INVALID; }
33.219
33.220 /// \brief Returns an upper bound on the node IDs.
33.221 - int maxNodeId() const { return -1; }
33.222 + int maxNodeId() const { return -1; }
33.223
33.224 /// \brief Returns an upper bound on the arc IDs.
33.225 - int maxArcId() const { return -1; }
33.226 + int maxArcId() const { return -1; }
33.227
33.228 void first(Node&) const {}
33.229 void next(Node&) const {}
33.230 @@ -389,9 +389,9 @@
33.231 Arc fromId(int, Arc) const { return INVALID; }
33.232
33.233 // Dummy parameter.
33.234 - int maxId(Node) const { return -1; }
33.235 + int maxId(Node) const { return -1; }
33.236 // Dummy parameter.
33.237 - int maxId(Arc) const { return -1; }
33.238 + int maxId(Arc) const { return -1; }
33.239
33.240 /// \brief The base node of the iterator.
33.241 ///
33.242 @@ -423,10 +423,10 @@
33.243 Node oppositeNode(const Node&, const Arc&) const { return INVALID; }
33.244
33.245 /// \brief Read write map of the nodes to type \c T.
33.246 - ///
33.247 + ///
33.248 /// ReadWrite map of the nodes to type \c T.
33.249 /// \sa Reference
33.250 - template<class T>
33.251 + template<class T>
33.252 class NodeMap : public ReadWriteMap< Node, T > {
33.253 public:
33.254
33.255 @@ -439,9 +439,9 @@
33.256 NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
33.257 ///Assignment operator
33.258 template <typename CMap>
33.259 - NodeMap& operator=(const CMap&) {
33.260 + NodeMap& operator=(const CMap&) {
33.261 checkConcept<ReadMap<Node, T>, CMap>();
33.262 - return *this;
33.263 + return *this;
33.264 }
33.265 };
33.266
33.267 @@ -449,7 +449,7 @@
33.268 ///
33.269 /// Reference map of the arcs to type \c T.
33.270 /// \sa Reference
33.271 - template<class T>
33.272 + template<class T>
33.273 class ArcMap : public ReadWriteMap<Arc,T> {
33.274 public:
33.275
33.276 @@ -461,9 +461,9 @@
33.277 ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
33.278 ///Assignment operator
33.279 template <typename CMap>
33.280 - ArcMap& operator=(const CMap&) {
33.281 + ArcMap& operator=(const CMap&) {
33.282 checkConcept<ReadMap<Arc, T>, CMap>();
33.283 - return *this;
33.284 + return *this;
33.285 }
33.286 };
33.287
33.288 @@ -471,14 +471,14 @@
33.289 struct Constraints {
33.290 void constraints() {
33.291 checkConcept<IterableDigraphComponent<>, _Digraph>();
33.292 - checkConcept<IDableDigraphComponent<>, _Digraph>();
33.293 + checkConcept<IDableDigraphComponent<>, _Digraph>();
33.294 checkConcept<MappableDigraphComponent<>, _Digraph>();
33.295 }
33.296 };
33.297
33.298 };
33.299 -
33.300 - } //namespace concepts
33.301 +
33.302 + } //namespace concepts
33.303 } //namespace lemon
33.304
33.305
34.1 --- a/lemon/concepts/graph.h Sun Jul 13 16:46:56 2008 +0100
34.2 +++ b/lemon/concepts/graph.h Sun Jul 13 19:51:02 2008 +0100
34.3 @@ -1,6 +1,6 @@
34.4 -/* -*- C++ -*-
34.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
34.6 *
34.7 - * This file is a part of LEMON, a generic C++ optimization library
34.8 + * This file is a part of LEMON, a generic C++ optimization library.
34.9 *
34.10 * Copyright (C) 2003-2008
34.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
34.12 @@ -65,23 +65,23 @@
34.13 /// OutArcIt iterates on the same edges but with opposite
34.14 /// direction. The IncEdgeIt iterates also on the same edges
34.15 /// as the OutArcIt and InArcIt but it is not convertible to Arc just
34.16 - /// to Edge.
34.17 + /// to Edge.
34.18 class Graph {
34.19 public:
34.20 /// \brief The undirected graph should be tagged by the
34.21 /// UndirectedTag.
34.22 ///
34.23 /// The undirected graph should be tagged by the UndirectedTag. This
34.24 - /// tag helps the enable_if technics to make compile time
34.25 - /// specializations for undirected graphs.
34.26 + /// tag helps the enable_if technics to make compile time
34.27 + /// specializations for undirected graphs.
34.28 typedef True UndirectedTag;
34.29
34.30 - /// \brief The base type of node iterators,
34.31 + /// \brief The base type of node iterators,
34.32 /// or in other words, the trivial node iterator.
34.33 ///
34.34 /// This is the base type of each node iterator,
34.35 /// thus each kind of node iterator converts to this.
34.36 - /// More precisely each kind of node iterator should be inherited
34.37 + /// More precisely each kind of node iterator should be inherited
34.38 /// from the trivial node iterator.
34.39 class Node {
34.40 public:
34.41 @@ -108,23 +108,23 @@
34.42 bool operator==(Node) const { return true; }
34.43
34.44 /// Inequality operator
34.45 -
34.46 +
34.47 /// \sa operator==(Node n)
34.48 ///
34.49 bool operator!=(Node) const { return true; }
34.50
34.51 - /// Artificial ordering operator.
34.52 -
34.53 - /// To allow the use of graph descriptors as key type in std::map or
34.54 - /// similar associative container we require this.
34.55 - ///
34.56 - /// \note This operator only have to define some strict ordering of
34.57 - /// the items; this order has nothing to do with the iteration
34.58 - /// ordering of the items.
34.59 - bool operator<(Node) const { return false; }
34.60 + /// Artificial ordering operator.
34.61 +
34.62 + /// To allow the use of graph descriptors as key type in std::map or
34.63 + /// similar associative container we require this.
34.64 + ///
34.65 + /// \note This operator only have to define some strict ordering of
34.66 + /// the items; this order has nothing to do with the iteration
34.67 + /// ordering of the items.
34.68 + bool operator<(Node) const { return false; }
34.69
34.70 };
34.71 -
34.72 +
34.73 /// This iterator goes through each node.
34.74
34.75 /// This iterator goes through each node.
34.76 @@ -142,7 +142,7 @@
34.77 /// to an undefined value.
34.78 NodeIt() { }
34.79 /// Copy constructor.
34.80 -
34.81 +
34.82 /// Copy constructor.
34.83 ///
34.84 NodeIt(const NodeIt& n) : Node(n) { }
34.85 @@ -158,9 +158,9 @@
34.86 NodeIt(const Graph&) { }
34.87 /// Node -> NodeIt conversion.
34.88
34.89 - /// Sets the iterator to the node of \c the graph pointed by
34.90 - /// the trivial iterator.
34.91 - /// This feature necessitates that each time we
34.92 + /// Sets the iterator to the node of \c the graph pointed by
34.93 + /// the trivial iterator.
34.94 + /// This feature necessitates that each time we
34.95 /// iterate the arc-set, the iteration order is the same.
34.96 NodeIt(const Graph&, const Node&) { }
34.97 /// Next node.
34.98 @@ -169,8 +169,8 @@
34.99 ///
34.100 NodeIt& operator++() { return *this; }
34.101 };
34.102 -
34.103 -
34.104 +
34.105 +
34.106 /// The base type of the edge iterators.
34.107
34.108 /// The base type of the edge iterators.
34.109 @@ -203,15 +203,15 @@
34.110 ///
34.111 bool operator!=(Edge) const { return true; }
34.112
34.113 - /// Artificial ordering operator.
34.114 -
34.115 - /// To allow the use of graph descriptors as key type in std::map or
34.116 - /// similar associative container we require this.
34.117 - ///
34.118 - /// \note This operator only have to define some strict ordering of
34.119 - /// the items; this order has nothing to do with the iteration
34.120 - /// ordering of the items.
34.121 - bool operator<(Edge) const { return false; }
34.122 + /// Artificial ordering operator.
34.123 +
34.124 + /// To allow the use of graph descriptors as key type in std::map or
34.125 + /// similar associative container we require this.
34.126 + ///
34.127 + /// \note This operator only have to define some strict ordering of
34.128 + /// the items; this order has nothing to do with the iteration
34.129 + /// ordering of the items.
34.130 + bool operator<(Edge) const { return false; }
34.131 };
34.132
34.133 /// This iterator goes through each edge.
34.134 @@ -241,32 +241,32 @@
34.135 ///
34.136 EdgeIt(Invalid) { }
34.137 /// This constructor sets the iterator to the first edge.
34.138 -
34.139 +
34.140 /// This constructor sets the iterator to the first edge.
34.141 EdgeIt(const Graph&) { }
34.142 /// Edge -> EdgeIt conversion
34.143
34.144 /// Sets the iterator to the value of the trivial iterator.
34.145 /// This feature necessitates that each time we
34.146 - /// iterate the edge-set, the iteration order is the
34.147 - /// same.
34.148 - EdgeIt(const Graph&, const Edge&) { }
34.149 + /// iterate the edge-set, the iteration order is the
34.150 + /// same.
34.151 + EdgeIt(const Graph&, const Edge&) { }
34.152 /// Next edge
34.153 -
34.154 +
34.155 /// Assign the iterator to the next edge.
34.156 EdgeIt& operator++() { return *this; }
34.157 };
34.158
34.159 - /// \brief This iterator goes trough the incident undirected
34.160 + /// \brief This iterator goes trough the incident undirected
34.161 /// arcs of a node.
34.162 ///
34.163 /// This iterator goes trough the incident edges
34.164 - /// of a certain node of a graph. You should assume that the
34.165 + /// of a certain node of a graph. You should assume that the
34.166 /// loop arcs will be iterated twice.
34.167 - ///
34.168 + ///
34.169 /// Its usage is quite simple, for example you can compute the
34.170 /// degree (i.e. count the number of incident arcs of a node \c n
34.171 - /// in graph \c g of type \c Graph as follows.
34.172 + /// in graph \c g of type \c Graph as follows.
34.173 ///
34.174 ///\code
34.175 /// int count=0;
34.176 @@ -290,20 +290,20 @@
34.177 ///
34.178 IncEdgeIt(Invalid) { }
34.179 /// This constructor sets the iterator to first incident arc.
34.180 -
34.181 +
34.182 /// This constructor set the iterator to the first incident arc of
34.183 /// the node.
34.184 IncEdgeIt(const Graph&, const Node&) { }
34.185 /// Edge -> IncEdgeIt conversion
34.186
34.187 /// Sets the iterator to the value of the trivial iterator \c e.
34.188 - /// This feature necessitates that each time we
34.189 + /// This feature necessitates that each time we
34.190 /// iterate the arc-set, the iteration order is the same.
34.191 IncEdgeIt(const Graph&, const Edge&) { }
34.192 /// Next incident arc
34.193
34.194 /// Assign the iterator to the next incident arc
34.195 - /// of the corresponding node.
34.196 + /// of the corresponding node.
34.197 IncEdgeIt& operator++() { return *this; }
34.198 };
34.199
34.200 @@ -340,17 +340,17 @@
34.201 ///
34.202 bool operator!=(Arc) const { return true; }
34.203
34.204 - /// Artificial ordering operator.
34.205 -
34.206 - /// To allow the use of graph descriptors as key type in std::map or
34.207 - /// similar associative container we require this.
34.208 - ///
34.209 - /// \note This operator only have to define some strict ordering of
34.210 - /// the items; this order has nothing to do with the iteration
34.211 - /// ordering of the items.
34.212 - bool operator<(Arc) const { return false; }
34.213 -
34.214 - };
34.215 + /// Artificial ordering operator.
34.216 +
34.217 + /// To allow the use of graph descriptors as key type in std::map or
34.218 + /// similar associative container we require this.
34.219 + ///
34.220 + /// \note This operator only have to define some strict ordering of
34.221 + /// the items; this order has nothing to do with the iteration
34.222 + /// ordering of the items.
34.223 + bool operator<(Arc) const { return false; }
34.224 +
34.225 + };
34.226 /// This iterator goes through each directed arc.
34.227
34.228 /// This iterator goes through each arc of a graph.
34.229 @@ -378,22 +378,22 @@
34.230 ///
34.231 ArcIt(Invalid) { }
34.232 /// This constructor sets the iterator to the first arc.
34.233 -
34.234 +
34.235 /// This constructor sets the iterator to the first arc of \c g.
34.236 ///@param g the graph
34.237 ArcIt(const Graph &g) { ignore_unused_variable_warning(g); }
34.238 /// Arc -> ArcIt conversion
34.239
34.240 /// Sets the iterator to the value of the trivial iterator \c e.
34.241 - /// This feature necessitates that each time we
34.242 + /// This feature necessitates that each time we
34.243 /// iterate the arc-set, the iteration order is the same.
34.244 - ArcIt(const Graph&, const Arc&) { }
34.245 + ArcIt(const Graph&, const Arc&) { }
34.246 ///Next arc
34.247 -
34.248 +
34.249 /// Assign the iterator to the next arc.
34.250 ArcIt& operator++() { return *this; }
34.251 };
34.252 -
34.253 +
34.254 /// This iterator goes trough the outgoing directed arcs of a node.
34.255
34.256 /// This iterator goes trough the \e outgoing arcs of a certain node
34.257 @@ -405,7 +405,7 @@
34.258 /// int count=0;
34.259 /// for (Graph::OutArcIt e(g, n); e!=INVALID; ++e) ++count;
34.260 ///\endcode
34.261 -
34.262 +
34.263 class OutArcIt : public Arc {
34.264 public:
34.265 /// Default constructor
34.266 @@ -424,24 +424,24 @@
34.267 ///
34.268 OutArcIt(Invalid) { }
34.269 /// This constructor sets the iterator to the first outgoing arc.
34.270 -
34.271 +
34.272 /// This constructor sets the iterator to the first outgoing arc of
34.273 /// the node.
34.274 ///@param n the node
34.275 ///@param g the graph
34.276 OutArcIt(const Graph& n, const Node& g) {
34.277 - ignore_unused_variable_warning(n);
34.278 - ignore_unused_variable_warning(g);
34.279 - }
34.280 + ignore_unused_variable_warning(n);
34.281 + ignore_unused_variable_warning(g);
34.282 + }
34.283 /// Arc -> OutArcIt conversion
34.284
34.285 /// Sets the iterator to the value of the trivial iterator.
34.286 - /// This feature necessitates that each time we
34.287 + /// This feature necessitates that each time we
34.288 /// iterate the arc-set, the iteration order is the same.
34.289 OutArcIt(const Graph&, const Arc&) { }
34.290 ///Next outgoing arc
34.291 -
34.292 - /// Assign the iterator to the next
34.293 +
34.294 + /// Assign the iterator to the next
34.295 /// outgoing arc of the corresponding node.
34.296 OutArcIt& operator++() { return *this; }
34.297 };
34.298 @@ -476,19 +476,19 @@
34.299 ///
34.300 InArcIt(Invalid) { }
34.301 /// This constructor sets the iterator to first incoming arc.
34.302 -
34.303 +
34.304 /// This constructor set the iterator to the first incoming arc of
34.305 /// the node.
34.306 ///@param n the node
34.307 ///@param g the graph
34.308 - InArcIt(const Graph& g, const Node& n) {
34.309 - ignore_unused_variable_warning(n);
34.310 - ignore_unused_variable_warning(g);
34.311 - }
34.312 + InArcIt(const Graph& g, const Node& n) {
34.313 + ignore_unused_variable_warning(n);
34.314 + ignore_unused_variable_warning(g);
34.315 + }
34.316 /// Arc -> InArcIt conversion
34.317
34.318 /// Sets the iterator to the value of the trivial iterator \c e.
34.319 - /// This feature necessitates that each time we
34.320 + /// This feature necessitates that each time we
34.321 /// iterate the arc-set, the iteration order is the same.
34.322 InArcIt(const Graph&, const Arc&) { }
34.323 /// Next incoming arc
34.324 @@ -499,10 +499,10 @@
34.325 };
34.326
34.327 /// \brief Read write map of the nodes to type \c T.
34.328 - ///
34.329 + ///
34.330 /// ReadWrite map of the nodes to type \c T.
34.331 /// \sa Reference
34.332 - template<class T>
34.333 + template<class T>
34.334 class NodeMap : public ReadWriteMap< Node, T >
34.335 {
34.336 public:
34.337 @@ -516,9 +516,9 @@
34.338 NodeMap(const NodeMap& nm) : ReadWriteMap< Node, T >(nm) { }
34.339 ///Assignment operator
34.340 template <typename CMap>
34.341 - NodeMap& operator=(const CMap&) {
34.342 + NodeMap& operator=(const CMap&) {
34.343 checkConcept<ReadMap<Node, T>, CMap>();
34.344 - return *this;
34.345 + return *this;
34.346 }
34.347 };
34.348
34.349 @@ -526,7 +526,7 @@
34.350 ///
34.351 /// Reference map of the directed arcs to type \c T.
34.352 /// \sa Reference
34.353 - template<class T>
34.354 + template<class T>
34.355 class ArcMap : public ReadWriteMap<Arc,T>
34.356 {
34.357 public:
34.358 @@ -539,9 +539,9 @@
34.359 ArcMap(const ArcMap& em) : ReadWriteMap<Arc,T>(em) { }
34.360 ///Assignment operator
34.361 template <typename CMap>
34.362 - ArcMap& operator=(const CMap&) {
34.363 + ArcMap& operator=(const CMap&) {
34.364 checkConcept<ReadMap<Arc, T>, CMap>();
34.365 - return *this;
34.366 + return *this;
34.367 }
34.368 };
34.369
34.370 @@ -549,7 +549,7 @@
34.371
34.372 /// Reference map of the arcs to type \c T.
34.373 /// \sa Reference
34.374 - template<class T>
34.375 + template<class T>
34.376 class EdgeMap : public ReadWriteMap<Edge,T>
34.377 {
34.378 public:
34.379 @@ -562,9 +562,9 @@
34.380 EdgeMap(const EdgeMap& em) : ReadWriteMap<Edge,T>(em) {}
34.381 ///Assignment operator
34.382 template <typename CMap>
34.383 - EdgeMap& operator=(const CMap&) {
34.384 + EdgeMap& operator=(const CMap&) {
34.385 checkConcept<ReadMap<Edge, T>, CMap>();
34.386 - return *this;
34.387 + return *this;
34.388 }
34.389 };
34.390
34.391 @@ -573,7 +573,7 @@
34.392 /// Direct the given edge. The returned arc source
34.393 /// will be the given node.
34.394 Arc direct(const Edge&, const Node&) const {
34.395 - return INVALID;
34.396 + return INVALID;
34.397 }
34.398
34.399 /// \brief Direct the given edge.
34.400 @@ -583,7 +583,7 @@
34.401 /// from the bool parameter. The source of the edge and
34.402 /// the directed arc is the same when the given bool is true.
34.403 Arc direct(const Edge&, bool) const {
34.404 - return INVALID;
34.405 + return INVALID;
34.406 }
34.407
34.408 /// \brief Returns true if the arc has default orientation.
34.409 @@ -625,37 +625,37 @@
34.410 Node target(Arc) const { return INVALID; }
34.411
34.412 /// \brief Returns the id of the node.
34.413 - int id(Node) const { return -1; }
34.414 + int id(Node) const { return -1; }
34.415
34.416 /// \brief Returns the id of the edge.
34.417 - int id(Edge) const { return -1; }
34.418 + int id(Edge) const { return -1; }
34.419
34.420 /// \brief Returns the id of the arc.
34.421 - int id(Arc) const { return -1; }
34.422 + int id(Arc) const { return -1; }
34.423
34.424 /// \brief Returns the node with the given id.
34.425 ///
34.426 /// \pre The argument should be a valid node id in the graph.
34.427 - Node nodeFromId(int) const { return INVALID; }
34.428 + Node nodeFromId(int) const { return INVALID; }
34.429
34.430 /// \brief Returns the edge with the given id.
34.431 ///
34.432 /// \pre The argument should be a valid edge id in the graph.
34.433 - Edge edgeFromId(int) const { return INVALID; }
34.434 + Edge edgeFromId(int) const { return INVALID; }
34.435
34.436 /// \brief Returns the arc with the given id.
34.437 ///
34.438 /// \pre The argument should be a valid arc id in the graph.
34.439 - Arc arcFromId(int) const { return INVALID; }
34.440 + Arc arcFromId(int) const { return INVALID; }
34.441
34.442 /// \brief Returns an upper bound on the node IDs.
34.443 - int maxNodeId() const { return -1; }
34.444 + int maxNodeId() const { return -1; }
34.445
34.446 /// \brief Returns an upper bound on the edge IDs.
34.447 - int maxEdgeId() const { return -1; }
34.448 + int maxEdgeId() const { return -1; }
34.449
34.450 /// \brief Returns an upper bound on the arc IDs.
34.451 - int maxArcId() const { return -1; }
34.452 + int maxArcId() const { return -1; }
34.453
34.454 void first(Node&) const {}
34.455 void next(Node&) const {}
34.456 @@ -683,61 +683,61 @@
34.457 Arc fromId(int, Arc) const { return INVALID; }
34.458
34.459 // Dummy parameter.
34.460 - int maxId(Node) const { return -1; }
34.461 + int maxId(Node) const { return -1; }
34.462 // Dummy parameter.
34.463 - int maxId(Edge) const { return -1; }
34.464 + int maxId(Edge) const { return -1; }
34.465 // Dummy parameter.
34.466 - int maxId(Arc) const { return -1; }
34.467 + int maxId(Arc) const { return -1; }
34.468
34.469 /// \brief Base node of the iterator
34.470 ///
34.471 /// Returns the base node (the source in this case) of the iterator
34.472 Node baseNode(OutArcIt e) const {
34.473 - return source(e);
34.474 + return source(e);
34.475 }
34.476 /// \brief Running node of the iterator
34.477 ///
34.478 /// Returns the running node (the target in this case) of the
34.479 /// iterator
34.480 Node runningNode(OutArcIt e) const {
34.481 - return target(e);
34.482 + return target(e);
34.483 }
34.484
34.485 /// \brief Base node of the iterator
34.486 ///
34.487 /// Returns the base node (the target in this case) of the iterator
34.488 Node baseNode(InArcIt e) const {
34.489 - return target(e);
34.490 + return target(e);
34.491 }
34.492 /// \brief Running node of the iterator
34.493 ///
34.494 /// Returns the running node (the source in this case) of the
34.495 /// iterator
34.496 Node runningNode(InArcIt e) const {
34.497 - return source(e);
34.498 + return source(e);
34.499 }
34.500
34.501 /// \brief Base node of the iterator
34.502 ///
34.503 /// Returns the base node of the iterator
34.504 Node baseNode(IncEdgeIt) const {
34.505 - return INVALID;
34.506 + return INVALID;
34.507 }
34.508 -
34.509 +
34.510 /// \brief Running node of the iterator
34.511 ///
34.512 /// Returns the running node of the iterator
34.513 Node runningNode(IncEdgeIt) const {
34.514 - return INVALID;
34.515 + return INVALID;
34.516 }
34.517
34.518 template <typename _Graph>
34.519 struct Constraints {
34.520 - void constraints() {
34.521 - checkConcept<IterableGraphComponent<>, _Graph>();
34.522 - checkConcept<IDableGraphComponent<>, _Graph>();
34.523 - checkConcept<MappableGraphComponent<>, _Graph>();
34.524 - }
34.525 + void constraints() {
34.526 + checkConcept<IterableGraphComponent<>, _Graph>();
34.527 + checkConcept<IDableGraphComponent<>, _Graph>();
34.528 + checkConcept<MappableGraphComponent<>, _Graph>();
34.529 + }
34.530 };
34.531
34.532 };
35.1 --- a/lemon/concepts/graph_components.h Sun Jul 13 16:46:56 2008 +0100
35.2 +++ b/lemon/concepts/graph_components.h Sun Jul 13 19:51:02 2008 +0100
35.3 @@ -1,6 +1,6 @@
35.4 -/* -*- C++ -*-
35.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
35.6 *
35.7 - * This file is a part of LEMON, a generic C++ optimization library
35.8 + * This file is a part of LEMON, a generic C++ optimization library.
35.9 *
35.10 * Copyright (C) 2003-2008
35.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
35.12 @@ -49,7 +49,7 @@
35.13 class GraphItem {
35.14 public:
35.15 /// \brief Default constructor.
35.16 - ///
35.17 + ///
35.18 /// \warning The default constructor is not required to set
35.19 /// the item to some well-defined value. So you should consider it
35.20 /// as uninitialized.
35.21 @@ -66,7 +66,7 @@
35.22 GraphItem(Invalid) {}
35.23 /// \brief Assign operator for nodes.
35.24 ///
35.25 - /// The nodes are assignable.
35.26 + /// The nodes are assignable.
35.27 ///
35.28 GraphItem& operator=(GraphItem const&) { return *this; }
35.29 /// \brief Equality operator.
35.30 @@ -92,27 +92,27 @@
35.31
35.32 template<typename _GraphItem>
35.33 struct Constraints {
35.34 - void constraints() {
35.35 - _GraphItem i1;
35.36 - _GraphItem i2 = i1;
35.37 - _GraphItem i3 = INVALID;
35.38 -
35.39 - i1 = i2 = i3;
35.40 + void constraints() {
35.41 + _GraphItem i1;
35.42 + _GraphItem i2 = i1;
35.43 + _GraphItem i3 = INVALID;
35.44
35.45 - bool b;
35.46 - // b = (ia == ib) && (ia != ib) && (ia < ib);
35.47 - b = (ia == ib) && (ia != ib);
35.48 - b = (ia == INVALID) && (ib != INVALID);
35.49 + i1 = i2 = i3;
35.50 +
35.51 + bool b;
35.52 + // b = (ia == ib) && (ia != ib) && (ia < ib);
35.53 + b = (ia == ib) && (ia != ib);
35.54 + b = (ia == INVALID) && (ib != INVALID);
35.55 b = (ia < ib);
35.56 - }
35.57 + }
35.58
35.59 - const _GraphItem &ia;
35.60 - const _GraphItem &ib;
35.61 + const _GraphItem &ia;
35.62 + const _GraphItem &ib;
35.63 };
35.64 };
35.65
35.66 /// \brief An empty base directed graph class.
35.67 - ///
35.68 + ///
35.69 /// This class provides the minimal set of features needed for a
35.70 /// directed graph structure. All digraph concepts have to be
35.71 /// conform to this base directed graph. It just provides types
35.72 @@ -122,16 +122,16 @@
35.73 public:
35.74
35.75 typedef BaseDigraphComponent Digraph;
35.76 -
35.77 +
35.78 /// \brief Node class of the digraph.
35.79 ///
35.80 - /// This class represents the Nodes of the digraph.
35.81 + /// This class represents the Nodes of the digraph.
35.82 ///
35.83 typedef GraphItem<'n'> Node;
35.84
35.85 /// \brief Arc class of the digraph.
35.86 ///
35.87 - /// This class represents the Arcs of the digraph.
35.88 + /// This class represents the Arcs of the digraph.
35.89 ///
35.90 typedef GraphItem<'e'> Arc;
35.91
35.92 @@ -156,27 +156,27 @@
35.93
35.94 template <typename _Digraph>
35.95 struct Constraints {
35.96 - typedef typename _Digraph::Node Node;
35.97 - typedef typename _Digraph::Arc Arc;
35.98 -
35.99 - void constraints() {
35.100 - checkConcept<GraphItem<'n'>, Node>();
35.101 - checkConcept<GraphItem<'a'>, Arc>();
35.102 - {
35.103 - Node n;
35.104 - Arc e(INVALID);
35.105 - n = digraph.source(e);
35.106 - n = digraph.target(e);
35.107 + typedef typename _Digraph::Node Node;
35.108 + typedef typename _Digraph::Arc Arc;
35.109 +
35.110 + void constraints() {
35.111 + checkConcept<GraphItem<'n'>, Node>();
35.112 + checkConcept<GraphItem<'a'>, Arc>();
35.113 + {
35.114 + Node n;
35.115 + Arc e(INVALID);
35.116 + n = digraph.source(e);
35.117 + n = digraph.target(e);
35.118 n = digraph.oppositeNode(n, e);
35.119 - }
35.120 - }
35.121 -
35.122 - const _Digraph& digraph;
35.123 + }
35.124 + }
35.125 +
35.126 + const _Digraph& digraph;
35.127 };
35.128 };
35.129
35.130 /// \brief An empty base undirected graph class.
35.131 - ///
35.132 + ///
35.133 /// This class provides the minimal set of features needed for an
35.134 /// undirected graph structure. All undirected graph concepts have
35.135 /// to be conform to this base graph. It just provides types for
35.136 @@ -199,7 +199,7 @@
35.137 public:
35.138 typedef GraphItem<'u'> Parent;
35.139 /// \brief Default constructor.
35.140 - ///
35.141 + ///
35.142 /// \warning The default constructor is not required to set
35.143 /// the item to some well-defined value. So you should consider it
35.144 /// as uninitialized.
35.145 @@ -217,12 +217,12 @@
35.146 /// \brief Converter from arc to edge.
35.147 ///
35.148 /// Besides the core graph item functionality each arc should
35.149 - /// be convertible to the represented edge.
35.150 + /// be convertible to the represented edge.
35.151 Edge(const Arc&) {}
35.152 /// \brief Assign arc to edge.
35.153 ///
35.154 /// Besides the core graph item functionality each arc should
35.155 - /// be convertible to the represented edge.
35.156 + /// be convertible to the represented edge.
35.157 Edge& operator=(const Arc&) { return *this; }
35.158 };
35.159
35.160 @@ -237,13 +237,13 @@
35.161 ///
35.162 /// Returns the directed arc from its direction and the
35.163 /// represented edge.
35.164 - Arc direct(const Edge&, bool) const { return INVALID;}
35.165 + Arc direct(const Edge&, bool) const { return INVALID;}
35.166
35.167 /// \brief Returns the directed arc.
35.168 ///
35.169 /// Returns the directed arc from its source and the
35.170 /// represented edge.
35.171 - Arc direct(const Edge&, const Node&) const { return INVALID;}
35.172 + Arc direct(const Edge&, const Node&) const { return INVALID;}
35.173
35.174 /// \brief Returns the opposite arc.
35.175 ///
35.176 @@ -260,38 +260,38 @@
35.177 ///
35.178 /// Gives back the other ending of an edge.
35.179 Node v(const Edge&) const { return INVALID;}
35.180 -
35.181 +
35.182 template <typename _Graph>
35.183 struct Constraints {
35.184 - typedef typename _Graph::Node Node;
35.185 - typedef typename _Graph::Arc Arc;
35.186 - typedef typename _Graph::Edge Edge;
35.187 -
35.188 - void constraints() {
35.189 + typedef typename _Graph::Node Node;
35.190 + typedef typename _Graph::Arc Arc;
35.191 + typedef typename _Graph::Edge Edge;
35.192 +
35.193 + void constraints() {
35.194 checkConcept<BaseDigraphComponent, _Graph>();
35.195 - checkConcept<GraphItem<'u'>, Edge>();
35.196 - {
35.197 - Node n;
35.198 - Edge ue(INVALID);
35.199 + checkConcept<GraphItem<'u'>, Edge>();
35.200 + {
35.201 + Node n;
35.202 + Edge ue(INVALID);
35.203 Arc e;
35.204 - n = graph.u(ue);
35.205 - n = graph.v(ue);
35.206 + n = graph.u(ue);
35.207 + n = graph.v(ue);
35.208 e = graph.direct(ue, true);
35.209 e = graph.direct(ue, n);
35.210 e = graph.oppositeArc(e);
35.211 ue = e;
35.212 bool d = graph.direction(e);
35.213 ignore_unused_variable_warning(d);
35.214 - }
35.215 - }
35.216 -
35.217 - const _Graph& graph;
35.218 + }
35.219 + }
35.220 +
35.221 + const _Graph& graph;
35.222 };
35.223
35.224 };
35.225
35.226 /// \brief An empty idable base digraph class.
35.227 - ///
35.228 + ///
35.229 /// This class provides beside the core digraph features
35.230 /// core id functions for the digraph structure.
35.231 /// The most of the base digraphs should be conform to this concept.
35.232 @@ -304,9 +304,9 @@
35.233 typedef typename Base::Node Node;
35.234 typedef typename Base::Arc Arc;
35.235
35.236 - /// \brief Gives back an unique integer id for the Node.
35.237 + /// \brief Gives back an unique integer id for the Node.
35.238 ///
35.239 - /// Gives back an unique integer id for the Node.
35.240 + /// Gives back an unique integer id for the Node.
35.241 ///
35.242 int id(const Node&) const { return -1;}
35.243
35.244 @@ -314,12 +314,12 @@
35.245 ///
35.246 /// Gives back the node by the unique id.
35.247 /// If the digraph does not contain node with the given id
35.248 - /// then the result of the function is undetermined.
35.249 + /// then the result of the function is undetermined.
35.250 Node nodeFromId(int) const { return INVALID;}
35.251
35.252 - /// \brief Gives back an unique integer id for the Arc.
35.253 + /// \brief Gives back an unique integer id for the Arc.
35.254 ///
35.255 - /// Gives back an unique integer id for the Arc.
35.256 + /// Gives back an unique integer id for the Arc.
35.257 ///
35.258 int id(const Arc&) const { return -1;}
35.259
35.260 @@ -327,7 +327,7 @@
35.261 ///
35.262 /// Gives back the arc by the unique id.
35.263 /// If the digraph does not contain arc with the given id
35.264 - /// then the result of the function is undetermined.
35.265 + /// then the result of the function is undetermined.
35.266 Arc arcFromId(int) const { return INVALID;}
35.267
35.268 /// \brief Gives back an integer greater or equal to the maximum
35.269 @@ -347,29 +347,29 @@
35.270 template <typename _Digraph>
35.271 struct Constraints {
35.272
35.273 - void constraints() {
35.274 - checkConcept<Base, _Digraph >();
35.275 - typename _Digraph::Node node;
35.276 - int nid = digraph.id(node);
35.277 - nid = digraph.id(node);
35.278 - node = digraph.nodeFromId(nid);
35.279 - typename _Digraph::Arc arc;
35.280 - int eid = digraph.id(arc);
35.281 - eid = digraph.id(arc);
35.282 - arc = digraph.arcFromId(eid);
35.283 + void constraints() {
35.284 + checkConcept<Base, _Digraph >();
35.285 + typename _Digraph::Node node;
35.286 + int nid = digraph.id(node);
35.287 + nid = digraph.id(node);
35.288 + node = digraph.nodeFromId(nid);
35.289 + typename _Digraph::Arc arc;
35.290 + int eid = digraph.id(arc);
35.291 + eid = digraph.id(arc);
35.292 + arc = digraph.arcFromId(eid);
35.293
35.294 - nid = digraph.maxNodeId();
35.295 - ignore_unused_variable_warning(nid);
35.296 - eid = digraph.maxArcId();
35.297 - ignore_unused_variable_warning(eid);
35.298 - }
35.299 + nid = digraph.maxNodeId();
35.300 + ignore_unused_variable_warning(nid);
35.301 + eid = digraph.maxArcId();
35.302 + ignore_unused_variable_warning(eid);
35.303 + }
35.304
35.305 - const _Digraph& digraph;
35.306 + const _Digraph& digraph;
35.307 };
35.308 };
35.309
35.310 /// \brief An empty idable base undirected graph class.
35.311 - ///
35.312 + ///
35.313 /// This class provides beside the core undirected graph features
35.314 /// core id functions for the undirected graph structure. The
35.315 /// most of the base undirected graphs should be conform to this
35.316 @@ -383,9 +383,9 @@
35.317
35.318 using IDableDigraphComponent<_Base>::id;
35.319
35.320 - /// \brief Gives back an unique integer id for the Edge.
35.321 + /// \brief Gives back an unique integer id for the Edge.
35.322 ///
35.323 - /// Gives back an unique integer id for the Edge.
35.324 + /// Gives back an unique integer id for the Edge.
35.325 ///
35.326 int id(const Edge&) const { return -1;}
35.327
35.328 @@ -406,18 +406,18 @@
35.329 template <typename _Graph>
35.330 struct Constraints {
35.331
35.332 - void constraints() {
35.333 - checkConcept<Base, _Graph >();
35.334 - checkConcept<IDableDigraphComponent<Base>, _Graph >();
35.335 - typename _Graph::Edge edge;
35.336 - int ueid = graph.id(edge);
35.337 - ueid = graph.id(edge);
35.338 - edge = graph.edgeFromId(ueid);
35.339 - ueid = graph.maxEdgeId();
35.340 - ignore_unused_variable_warning(ueid);
35.341 - }
35.342 + void constraints() {
35.343 + checkConcept<Base, _Graph >();
35.344 + checkConcept<IDableDigraphComponent<Base>, _Graph >();
35.345 + typename _Graph::Edge edge;
35.346 + int ueid = graph.id(edge);
35.347 + ueid = graph.id(edge);
35.348 + edge = graph.edgeFromId(ueid);
35.349 + ueid = graph.maxEdgeId();
35.350 + ignore_unused_variable_warning(ueid);
35.351 + }
35.352
35.353 - const _Graph& graph;
35.354 + const _Graph& graph;
35.355 };
35.356 };
35.357
35.358 @@ -450,52 +450,52 @@
35.359 GraphItemIt(Invalid) {}
35.360 /// \brief Assign operator for items.
35.361 ///
35.362 - /// The items are assignable.
35.363 + /// The items are assignable.
35.364 ///
35.365 - GraphItemIt& operator=(const GraphItemIt&) { return *this; }
35.366 + GraphItemIt& operator=(const GraphItemIt&) { return *this; }
35.367 /// \brief Next item.
35.368 - ///
35.369 + ///
35.370 /// Assign the iterator to the next item.
35.371 ///
35.372 GraphItemIt& operator++() { return *this; }
35.373 /// \brief Equality operator
35.374 - ///
35.375 + ///
35.376 /// Two iterators are equal if and only if they point to the
35.377 /// same object or both are invalid.
35.378 bool operator==(const GraphItemIt&) const { return true;}
35.379 /// \brief Inequality operator
35.380 - ///
35.381 + ///
35.382 /// \sa operator==(Node n)
35.383 ///
35.384 bool operator!=(const GraphItemIt&) const { return true;}
35.385 -
35.386 +
35.387 template<typename _GraphItemIt>
35.388 struct Constraints {
35.389 - void constraints() {
35.390 - _GraphItemIt it1(g);
35.391 - _GraphItemIt it2;
35.392 + void constraints() {
35.393 + _GraphItemIt it1(g);
35.394 + _GraphItemIt it2;
35.395
35.396 - it2 = ++it1;
35.397 - ++it2 = it1;
35.398 - ++(++it1);
35.399 + it2 = ++it1;
35.400 + ++it2 = it1;
35.401 + ++(++it1);
35.402
35.403 - _Item bi = it1;
35.404 - bi = it2;
35.405 - }
35.406 - _Graph& g;
35.407 + _Item bi = it1;
35.408 + bi = it2;
35.409 + }
35.410 + _Graph& g;
35.411 };
35.412 };
35.413
35.414 /// \brief Skeleton class for graph InArcIt and OutArcIt
35.415 ///
35.416 /// \note Because InArcIt and OutArcIt may not inherit from the same
35.417 - /// base class, the _selector is a additional template parameter. For
35.418 - /// InArcIt you should instantiate it with character 'i' and for
35.419 + /// base class, the _selector is a additional template parameter. For
35.420 + /// InArcIt you should instantiate it with character 'i' and for
35.421 /// OutArcIt with 'o'.
35.422 template <typename _Graph,
35.423 - typename _Item = typename _Graph::Arc,
35.424 - typename _Base = typename _Graph::Node,
35.425 - char _selector = '0'>
35.426 + typename _Item = typename _Graph::Arc,
35.427 + typename _Base = typename _Graph::Node,
35.428 + char _selector = '0'>
35.429 class GraphIncIt : public _Item {
35.430 public:
35.431 /// \brief Default constructor.
35.432 @@ -508,10 +508,10 @@
35.433 /// Copy constructor.
35.434 ///
35.435 GraphIncIt(GraphIncIt const& gi) : _Item(gi) {}
35.436 - /// \brief Sets the iterator to the first arc incoming into or outgoing
35.437 + /// \brief Sets the iterator to the first arc incoming into or outgoing
35.438 /// from the node.
35.439 ///
35.440 - /// Sets the iterator to the first arc incoming into or outgoing
35.441 + /// Sets the iterator to the first arc incoming into or outgoing
35.442 /// from the node.
35.443 ///
35.444 explicit GraphIncIt(const _Graph&, const _Base&) {}
35.445 @@ -522,9 +522,9 @@
35.446 GraphIncIt(Invalid) {}
35.447 /// \brief Assign operator for iterators.
35.448 ///
35.449 - /// The iterators are assignable.
35.450 + /// The iterators are assignable.
35.451 ///
35.452 - GraphIncIt& operator=(GraphIncIt const&) { return *this; }
35.453 + GraphIncIt& operator=(GraphIncIt const&) { return *this; }
35.454 /// \brief Next item.
35.455 ///
35.456 /// Assign the iterator to the next item.
35.457 @@ -545,23 +545,23 @@
35.458
35.459 template <typename _GraphIncIt>
35.460 struct Constraints {
35.461 - void constraints() {
35.462 - checkConcept<GraphItem<_selector>, _GraphIncIt>();
35.463 - _GraphIncIt it1(graph, node);
35.464 - _GraphIncIt it2;
35.465 + void constraints() {
35.466 + checkConcept<GraphItem<_selector>, _GraphIncIt>();
35.467 + _GraphIncIt it1(graph, node);
35.468 + _GraphIncIt it2;
35.469
35.470 - it2 = ++it1;
35.471 - ++it2 = it1;
35.472 - ++(++it1);
35.473 - _Item e = it1;
35.474 - e = it2;
35.475 + it2 = ++it1;
35.476 + ++it2 = it1;
35.477 + ++(++it1);
35.478 + _Item e = it1;
35.479 + e = it2;
35.480
35.481 - }
35.482 + }
35.483
35.484 - _Item arc;
35.485 - _Base node;
35.486 - _Graph graph;
35.487 - _GraphIncIt it;
35.488 + _Item arc;
35.489 + _Base node;
35.490 + _Graph graph;
35.491 + _GraphIncIt it;
35.492 };
35.493 };
35.494
35.495 @@ -575,7 +575,7 @@
35.496 class IterableDigraphComponent : public _Base {
35.497
35.498 public:
35.499 -
35.500 +
35.501 typedef _Base Base;
35.502 typedef typename Base::Node Node;
35.503 typedef typename Base::Arc Arc;
35.504 @@ -583,33 +583,33 @@
35.505 typedef IterableDigraphComponent Digraph;
35.506
35.507 /// \name Base iteration
35.508 - ///
35.509 + ///
35.510 /// This interface provides functions for iteration on digraph items
35.511 ///
35.512 - /// @{
35.513 + /// @{
35.514
35.515 /// \brief Gives back the first node in the iterating order.
35.516 - ///
35.517 + ///
35.518 /// Gives back the first node in the iterating order.
35.519 - ///
35.520 + ///
35.521 void first(Node&) const {}
35.522
35.523 /// \brief Gives back the next node in the iterating order.
35.524 ///
35.525 /// Gives back the next node in the iterating order.
35.526 - ///
35.527 + ///
35.528 void next(Node&) const {}
35.529
35.530 /// \brief Gives back the first arc in the iterating order.
35.531 ///
35.532 /// Gives back the first arc in the iterating order.
35.533 - ///
35.534 + ///
35.535 void first(Arc&) const {}
35.536
35.537 /// \brief Gives back the next arc in the iterating order.
35.538 ///
35.539 /// Gives back the next arc in the iterating order.
35.540 - ///
35.541 + ///
35.542 void next(Arc&) const {}
35.543
35.544
35.545 @@ -617,7 +617,7 @@
35.546 /// node.
35.547 ///
35.548 /// Gives back the first of the arcs point to the given node.
35.549 - ///
35.550 + ///
35.551 void firstIn(Arc&, const Node&) const {}
35.552
35.553 /// \brief Gives back the next of the arcs points to the given
35.554 @@ -629,22 +629,22 @@
35.555
35.556 /// \brief Gives back the first of the arcs start from the
35.557 /// given node.
35.558 - ///
35.559 + ///
35.560 /// Gives back the first of the arcs start from the given node.
35.561 - ///
35.562 + ///
35.563 void firstOut(Arc&, const Node&) const {}
35.564
35.565 /// \brief Gives back the next of the arcs start from the given
35.566 /// node.
35.567 ///
35.568 /// Gives back the next of the arcs start from the given node.
35.569 - ///
35.570 + ///
35.571 void nextOut(Arc&) const {}
35.572
35.573 /// @}
35.574
35.575 /// \name Class based iteration
35.576 - ///
35.577 + ///
35.578 /// This interface provides functions for iteration on digraph items
35.579 ///
35.580 /// @{
35.581 @@ -699,13 +699,13 @@
35.582
35.583 /// @}
35.584
35.585 - template <typename _Digraph>
35.586 + template <typename _Digraph>
35.587 struct Constraints {
35.588 - void constraints() {
35.589 - checkConcept<Base, _Digraph>();
35.590 + void constraints() {
35.591 + checkConcept<Base, _Digraph>();
35.592
35.593 {
35.594 - typename _Digraph::Node node(INVALID);
35.595 + typename _Digraph::Node node(INVALID);
35.596 typename _Digraph::Arc arc(INVALID);
35.597 {
35.598 digraph.first(node);
35.599 @@ -723,16 +723,16 @@
35.600 digraph.firstOut(arc, node);
35.601 digraph.nextOut(arc);
35.602 }
35.603 - }
35.604 + }
35.605
35.606 {
35.607 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Arc>,
35.608 typename _Digraph::ArcIt >();
35.609 checkConcept<GraphItemIt<_Digraph, typename _Digraph::Node>,
35.610 typename _Digraph::NodeIt >();
35.611 - checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
35.612 + checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
35.613 typename _Digraph::Node, 'i'>, typename _Digraph::InArcIt>();
35.614 - checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
35.615 + checkConcept<GraphIncIt<_Digraph, typename _Digraph::Arc,
35.616 typename _Digraph::Node, 'o'>, typename _Digraph::OutArcIt>();
35.617
35.618 typename _Digraph::Node n;
35.619 @@ -745,9 +745,9 @@
35.620 ignore_unused_variable_warning(n);
35.621 }
35.622 }
35.623 -
35.624 - const _Digraph& digraph;
35.625 -
35.626 +
35.627 + const _Digraph& digraph;
35.628 +
35.629 };
35.630 };
35.631
35.632 @@ -765,13 +765,13 @@
35.633 typedef typename Base::Arc Arc;
35.634 typedef typename Base::Edge Edge;
35.635
35.636 -
35.637 +
35.638 typedef IterableGraphComponent Graph;
35.639
35.640 /// \name Base iteration
35.641 - ///
35.642 + ///
35.643 /// This interface provides functions for iteration on graph items
35.644 - /// @{
35.645 + /// @{
35.646
35.647 using IterableDigraphComponent<_Base>::first;
35.648 using IterableDigraphComponent<_Base>::next;
35.649 @@ -780,14 +780,14 @@
35.650 /// order.
35.651 ///
35.652 /// Gives back the first edge in the iterating order.
35.653 - ///
35.654 + ///
35.655 void first(Edge&) const {}
35.656
35.657 /// \brief Gives back the next edge in the iterating
35.658 /// order.
35.659 ///
35.660 /// Gives back the next edge in the iterating order.
35.661 - ///
35.662 + ///
35.663 void next(Edge&) const {}
35.664
35.665
35.666 @@ -814,7 +814,7 @@
35.667 /// @}
35.668
35.669 /// \name Class based iteration
35.670 - ///
35.671 + ///
35.672 /// This interface provides functions for iteration on graph items
35.673 ///
35.674 /// @{
35.675 @@ -841,10 +841,10 @@
35.676
35.677 /// @}
35.678
35.679 - template <typename _Graph>
35.680 + template <typename _Graph>
35.681 struct Constraints {
35.682 - void constraints() {
35.683 - checkConcept<IterableDigraphComponent<Base>, _Graph>();
35.684 + void constraints() {
35.685 + checkConcept<IterableDigraphComponent<Base>, _Graph>();
35.686
35.687 {
35.688 typename _Graph::Node node(INVALID);
35.689 @@ -858,29 +858,29 @@
35.690 graph.firstInc(edge, dir, node);
35.691 graph.nextInc(edge, dir);
35.692 }
35.693 -
35.694 - }
35.695 -
35.696 +
35.697 + }
35.698 +
35.699 {
35.700 checkConcept<GraphItemIt<_Graph, typename _Graph::Edge>,
35.701 typename _Graph::EdgeIt >();
35.702 - checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
35.703 + checkConcept<GraphIncIt<_Graph, typename _Graph::Edge,
35.704 typename _Graph::Node, 'u'>, typename _Graph::IncEdgeIt>();
35.705 -
35.706 +
35.707 typename _Graph::Node n;
35.708 typename _Graph::IncEdgeIt ueit(INVALID);
35.709 n = graph.baseNode(ueit);
35.710 n = graph.runningNode(ueit);
35.711 }
35.712 }
35.713 -
35.714 - const _Graph& graph;
35.715 -
35.716 +
35.717 + const _Graph& graph;
35.718 +
35.719 };
35.720 };
35.721
35.722 /// \brief An empty alteration notifier digraph class.
35.723 - ///
35.724 + ///
35.725 /// This class provides beside the core digraph features alteration
35.726 /// notifier interface for the digraph structure. This implements
35.727 /// an observer-notifier pattern for each digraph item. More
35.728 @@ -897,48 +897,48 @@
35.729
35.730
35.731 /// The node observer registry.
35.732 - typedef AlterationNotifier<AlterableDigraphComponent, Node>
35.733 + typedef AlterationNotifier<AlterableDigraphComponent, Node>
35.734 NodeNotifier;
35.735 /// The arc observer registry.
35.736 - typedef AlterationNotifier<AlterableDigraphComponent, Arc>
35.737 + typedef AlterationNotifier<AlterableDigraphComponent, Arc>
35.738 ArcNotifier;
35.739 -
35.740 +
35.741 /// \brief Gives back the node alteration notifier.
35.742 ///
35.743 /// Gives back the node alteration notifier.
35.744 NodeNotifier& notifier(Node) const {
35.745 - return NodeNotifier();
35.746 + return NodeNotifier();
35.747 }
35.748 -
35.749 +
35.750 /// \brief Gives back the arc alteration notifier.
35.751 ///
35.752 /// Gives back the arc alteration notifier.
35.753 ArcNotifier& notifier(Arc) const {
35.754 - return ArcNotifier();
35.755 + return ArcNotifier();
35.756 }
35.757
35.758 - template <typename _Digraph>
35.759 + template <typename _Digraph>
35.760 struct Constraints {
35.761 - void constraints() {
35.762 - checkConcept<Base, _Digraph>();
35.763 - typename _Digraph::NodeNotifier& nn
35.764 + void constraints() {
35.765 + checkConcept<Base, _Digraph>();
35.766 + typename _Digraph::NodeNotifier& nn
35.767 = digraph.notifier(typename _Digraph::Node());
35.768
35.769 - typename _Digraph::ArcNotifier& en
35.770 + typename _Digraph::ArcNotifier& en
35.771 = digraph.notifier(typename _Digraph::Arc());
35.772 -
35.773 +
35.774 ignore_unused_variable_warning(nn);
35.775 ignore_unused_variable_warning(en);
35.776 - }
35.777 -
35.778 - const _Digraph& digraph;
35.779 -
35.780 + }
35.781 +
35.782 + const _Digraph& digraph;
35.783 +
35.784 };
35.785 -
35.786 +
35.787 };
35.788
35.789 /// \brief An empty alteration notifier undirected graph class.
35.790 - ///
35.791 + ///
35.792 /// This class provides beside the core graph features alteration
35.793 /// notifier interface for the graph structure. This implements
35.794 /// an observer-notifier pattern for each graph item. More
35.795 @@ -954,33 +954,33 @@
35.796
35.797
35.798 /// The arc observer registry.
35.799 - typedef AlterationNotifier<AlterableGraphComponent, Edge>
35.800 + typedef AlterationNotifier<AlterableGraphComponent, Edge>
35.801 EdgeNotifier;
35.802 -
35.803 +
35.804 /// \brief Gives back the arc alteration notifier.
35.805 ///
35.806 /// Gives back the arc alteration notifier.
35.807 EdgeNotifier& notifier(Edge) const {
35.808 - return EdgeNotifier();
35.809 + return EdgeNotifier();
35.810 }
35.811
35.812 - template <typename _Graph>
35.813 + template <typename _Graph>
35.814 struct Constraints {
35.815 - void constraints() {
35.816 - checkConcept<AlterableGraphComponent<Base>, _Graph>();
35.817 - typename _Graph::EdgeNotifier& uen
35.818 + void constraints() {
35.819 + checkConcept<AlterableGraphComponent<Base>, _Graph>();
35.820 + typename _Graph::EdgeNotifier& uen
35.821 = graph.notifier(typename _Graph::Edge());
35.822 ignore_unused_variable_warning(uen);
35.823 - }
35.824 -
35.825 - const _Graph& graph;
35.826 -
35.827 + }
35.828 +
35.829 + const _Graph& graph;
35.830 +
35.831 };
35.832 -
35.833 +
35.834 };
35.835
35.836 /// \brief Class describing the concept of graph maps
35.837 - ///
35.838 + ///
35.839 /// This class describes the common interface of the graph maps
35.840 /// (NodeMap, ArcMap), that is \ref maps-page "maps" which can be used to
35.841 /// associate data to graph descriptors (nodes or arcs).
35.842 @@ -1009,39 +1009,39 @@
35.843 ///
35.844 /// Copy Constructor.
35.845 GraphMap(const GraphMap&) : Parent() {}
35.846 -
35.847 +
35.848 /// \brief Assign operator.
35.849 ///
35.850 /// Assign operator. It does not mofify the underlying graph,
35.851 /// it just iterates on the current item set and set the map
35.852 - /// with the value returned by the assigned map.
35.853 + /// with the value returned by the assigned map.
35.854 template <typename CMap>
35.855 - GraphMap& operator=(const CMap&) {
35.856 + GraphMap& operator=(const CMap&) {
35.857 checkConcept<ReadMap<Key, Value>, CMap>();
35.858 return *this;
35.859 }
35.860
35.861 template<typename _Map>
35.862 struct Constraints {
35.863 - void constraints() {
35.864 - checkConcept<ReadWriteMap<Key, Value>, _Map >();
35.865 - // Construction with a graph parameter
35.866 - _Map a(g);
35.867 - // Constructor with a graph and a default value parameter
35.868 - _Map a2(g,t);
35.869 - // Copy constructor.
35.870 - _Map b(c);
35.871 -
35.872 + void constraints() {
35.873 + checkConcept<ReadWriteMap<Key, Value>, _Map >();
35.874 + // Construction with a graph parameter
35.875 + _Map a(g);
35.876 + // Constructor with a graph and a default value parameter
35.877 + _Map a2(g,t);
35.878 + // Copy constructor.
35.879 + _Map b(c);
35.880 +
35.881 ReadMap<Key, Value> cmap;
35.882 b = cmap;
35.883
35.884 - ignore_unused_variable_warning(a2);
35.885 - ignore_unused_variable_warning(b);
35.886 - }
35.887 + ignore_unused_variable_warning(a2);
35.888 + ignore_unused_variable_warning(b);
35.889 + }
35.890
35.891 - const _Map &c;
35.892 - const Graph &g;
35.893 - const typename GraphMap::Value &t;
35.894 + const _Map &c;
35.895 + const Graph &g;
35.896 + const typename GraphMap::Value &t;
35.897 };
35.898
35.899 };
35.900 @@ -1070,28 +1070,28 @@
35.901 public:
35.902 typedef GraphMap<MappableDigraphComponent, Node, _Value> Parent;
35.903
35.904 - /// \brief Construct a new map.
35.905 - ///
35.906 - /// Construct a new map for the digraph.
35.907 - explicit NodeMap(const MappableDigraphComponent& digraph)
35.908 + /// \brief Construct a new map.
35.909 + ///
35.910 + /// Construct a new map for the digraph.
35.911 + explicit NodeMap(const MappableDigraphComponent& digraph)
35.912 : Parent(digraph) {}
35.913
35.914 - /// \brief Construct a new map with default value.
35.915 - ///
35.916 - /// Construct a new map for the digraph and initalise the values.
35.917 - NodeMap(const MappableDigraphComponent& digraph, const _Value& value)
35.918 + /// \brief Construct a new map with default value.
35.919 + ///
35.920 + /// Construct a new map for the digraph and initalise the values.
35.921 + NodeMap(const MappableDigraphComponent& digraph, const _Value& value)
35.922 : Parent(digraph, value) {}
35.923
35.924 - /// \brief Copy constructor.
35.925 - ///
35.926 - /// Copy Constructor.
35.927 - NodeMap(const NodeMap& nm) : Parent(nm) {}
35.928 + /// \brief Copy constructor.
35.929 + ///
35.930 + /// Copy Constructor.
35.931 + NodeMap(const NodeMap& nm) : Parent(nm) {}
35.932
35.933 - /// \brief Assign operator.
35.934 - ///
35.935 - /// Assign operator.
35.936 + /// \brief Assign operator.
35.937 + ///
35.938 + /// Assign operator.
35.939 template <typename CMap>
35.940 - NodeMap& operator=(const CMap&) {
35.941 + NodeMap& operator=(const CMap&) {
35.942 checkConcept<ReadMap<Node, _Value>, CMap>();
35.943 return *this;
35.944 }
35.945 @@ -1107,28 +1107,28 @@
35.946 public:
35.947 typedef GraphMap<MappableDigraphComponent, Arc, _Value> Parent;
35.948
35.949 - /// \brief Construct a new map.
35.950 - ///
35.951 - /// Construct a new map for the digraph.
35.952 - explicit ArcMap(const MappableDigraphComponent& digraph)
35.953 + /// \brief Construct a new map.
35.954 + ///
35.955 + /// Construct a new map for the digraph.
35.956 + explicit ArcMap(const MappableDigraphComponent& digraph)
35.957 : Parent(digraph) {}
35.958
35.959 - /// \brief Construct a new map with default value.
35.960 - ///
35.961 - /// Construct a new map for the digraph and initalise the values.
35.962 - ArcMap(const MappableDigraphComponent& digraph, const _Value& value)
35.963 + /// \brief Construct a new map with default value.
35.964 + ///
35.965 + /// Construct a new map for the digraph and initalise the values.
35.966 + ArcMap(const MappableDigraphComponent& digraph, const _Value& value)
35.967 : Parent(digraph, value) {}
35.968
35.969 - /// \brief Copy constructor.
35.970 - ///
35.971 - /// Copy Constructor.
35.972 - ArcMap(const ArcMap& nm) : Parent(nm) {}
35.973 + /// \brief Copy constructor.
35.974 + ///
35.975 + /// Copy Constructor.
35.976 + ArcMap(const ArcMap& nm) : Parent(nm) {}
35.977
35.978 - /// \brief Assign operator.
35.979 - ///
35.980 - /// Assign operator.
35.981 + /// \brief Assign operator.
35.982 + ///
35.983 + /// Assign operator.
35.984 template <typename CMap>
35.985 - ArcMap& operator=(const CMap&) {
35.986 + ArcMap& operator=(const CMap&) {
35.987 checkConcept<ReadMap<Arc, _Value>, CMap>();
35.988 return *this;
35.989 }
35.990 @@ -1139,44 +1139,44 @@
35.991 template <typename _Digraph>
35.992 struct Constraints {
35.993
35.994 - struct Dummy {
35.995 - int value;
35.996 - Dummy() : value(0) {}
35.997 - Dummy(int _v) : value(_v) {}
35.998 - };
35.999 + struct Dummy {
35.1000 + int value;
35.1001 + Dummy() : value(0) {}
35.1002 + Dummy(int _v) : value(_v) {}
35.1003 + };
35.1004
35.1005 - void constraints() {
35.1006 - checkConcept<Base, _Digraph>();
35.1007 - { // int map test
35.1008 - typedef typename _Digraph::template NodeMap<int> IntNodeMap;
35.1009 - checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>,
35.1010 - IntNodeMap >();
35.1011 - } { // bool map test
35.1012 - typedef typename _Digraph::template NodeMap<bool> BoolNodeMap;
35.1013 - checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>,
35.1014 - BoolNodeMap >();
35.1015 - } { // Dummy map test
35.1016 - typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap;
35.1017 - checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>,
35.1018 - DummyNodeMap >();
35.1019 - }
35.1020 + void constraints() {
35.1021 + checkConcept<Base, _Digraph>();
35.1022 + { // int map test
35.1023 + typedef typename _Digraph::template NodeMap<int> IntNodeMap;
35.1024 + checkConcept<GraphMap<_Digraph, typename _Digraph::Node, int>,
35.1025 + IntNodeMap >();
35.1026 + } { // bool map test
35.1027 + typedef typename _Digraph::template NodeMap<bool> BoolNodeMap;
35.1028 + checkConcept<GraphMap<_Digraph, typename _Digraph::Node, bool>,
35.1029 + BoolNodeMap >();
35.1030 + } { // Dummy map test
35.1031 + typedef typename _Digraph::template NodeMap<Dummy> DummyNodeMap;
35.1032 + checkConcept<GraphMap<_Digraph, typename _Digraph::Node, Dummy>,
35.1033 + DummyNodeMap >();
35.1034 + }
35.1035
35.1036 - { // int map test
35.1037 - typedef typename _Digraph::template ArcMap<int> IntArcMap;
35.1038 - checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>,
35.1039 - IntArcMap >();
35.1040 - } { // bool map test
35.1041 - typedef typename _Digraph::template ArcMap<bool> BoolArcMap;
35.1042 - checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>,
35.1043 - BoolArcMap >();
35.1044 - } { // Dummy map test
35.1045 - typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap;
35.1046 - checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>,
35.1047 - DummyArcMap >();
35.1048 - }
35.1049 - }
35.1050 + { // int map test
35.1051 + typedef typename _Digraph::template ArcMap<int> IntArcMap;
35.1052 + checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, int>,
35.1053 + IntArcMap >();
35.1054 + } { // bool map test
35.1055 + typedef typename _Digraph::template ArcMap<bool> BoolArcMap;
35.1056 + checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, bool>,
35.1057 + BoolArcMap >();
35.1058 + } { // Dummy map test
35.1059 + typedef typename _Digraph::template ArcMap<Dummy> DummyArcMap;
35.1060 + checkConcept<GraphMap<_Digraph, typename _Digraph::Arc, Dummy>,
35.1061 + DummyArcMap >();
35.1062 + }
35.1063 + }
35.1064
35.1065 - _Digraph& digraph;
35.1066 + _Digraph& digraph;
35.1067 };
35.1068 };
35.1069
35.1070 @@ -1199,32 +1199,32 @@
35.1071 /// ReadWrite map of the edges.
35.1072 ///
35.1073 template <typename _Value>
35.1074 - class EdgeMap : public GraphMap<Graph, Edge, _Value> {
35.1075 + class EdgeMap : public GraphMap<Graph, Edge, _Value> {
35.1076 public:
35.1077 typedef GraphMap<MappableGraphComponent, Edge, _Value> Parent;
35.1078
35.1079 - /// \brief Construct a new map.
35.1080 - ///
35.1081 - /// Construct a new map for the graph.
35.1082 - explicit EdgeMap(const MappableGraphComponent& graph)
35.1083 + /// \brief Construct a new map.
35.1084 + ///
35.1085 + /// Construct a new map for the graph.
35.1086 + explicit EdgeMap(const MappableGraphComponent& graph)
35.1087 : Parent(graph) {}
35.1088
35.1089 - /// \brief Construct a new map with default value.
35.1090 - ///
35.1091 - /// Construct a new map for the graph and initalise the values.
35.1092 - EdgeMap(const MappableGraphComponent& graph, const _Value& value)
35.1093 + /// \brief Construct a new map with default value.
35.1094 + ///
35.1095 + /// Construct a new map for the graph and initalise the values.
35.1096 + EdgeMap(const MappableGraphComponent& graph, const _Value& value)
35.1097 : Parent(graph, value) {}
35.1098
35.1099 - /// \brief Copy constructor.
35.1100 - ///
35.1101 - /// Copy Constructor.
35.1102 - EdgeMap(const EdgeMap& nm) : Parent(nm) {}
35.1103 + /// \brief Copy constructor.
35.1104 + ///
35.1105 + /// Copy Constructor.
35.1106 + EdgeMap(const EdgeMap& nm) : Parent(nm) {}
35.1107
35.1108 - /// \brief Assign operator.
35.1109 - ///
35.1110 - /// Assign operator.
35.1111 + /// \brief Assign operator.
35.1112 + ///
35.1113 + /// Assign operator.
35.1114 template <typename CMap>
35.1115 - EdgeMap& operator=(const CMap&) {
35.1116 + EdgeMap& operator=(const CMap&) {
35.1117 checkConcept<ReadMap<Edge, _Value>, CMap>();
35.1118 return *this;
35.1119 }
35.1120 @@ -1235,31 +1235,31 @@
35.1121 template <typename _Graph>
35.1122 struct Constraints {
35.1123
35.1124 - struct Dummy {
35.1125 - int value;
35.1126 - Dummy() : value(0) {}
35.1127 - Dummy(int _v) : value(_v) {}
35.1128 - };
35.1129 + struct Dummy {
35.1130 + int value;
35.1131 + Dummy() : value(0) {}
35.1132 + Dummy(int _v) : value(_v) {}
35.1133 + };
35.1134
35.1135 - void constraints() {
35.1136 - checkConcept<MappableGraphComponent<Base>, _Graph>();
35.1137 + void constraints() {
35.1138 + checkConcept<MappableGraphComponent<Base>, _Graph>();
35.1139
35.1140 - { // int map test
35.1141 - typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
35.1142 - checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
35.1143 - IntEdgeMap >();
35.1144 - } { // bool map test
35.1145 - typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
35.1146 - checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
35.1147 - BoolEdgeMap >();
35.1148 - } { // Dummy map test
35.1149 - typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
35.1150 - checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
35.1151 - DummyEdgeMap >();
35.1152 - }
35.1153 - }
35.1154 + { // int map test
35.1155 + typedef typename _Graph::template EdgeMap<int> IntEdgeMap;
35.1156 + checkConcept<GraphMap<_Graph, typename _Graph::Edge, int>,
35.1157 + IntEdgeMap >();
35.1158 + } { // bool map test
35.1159 + typedef typename _Graph::template EdgeMap<bool> BoolEdgeMap;
35.1160 + checkConcept<GraphMap<_Graph, typename _Graph::Edge, bool>,
35.1161 + BoolEdgeMap >();
35.1162 + } { // Dummy map test
35.1163 + typedef typename _Graph::template EdgeMap<Dummy> DummyEdgeMap;
35.1164 + checkConcept<GraphMap<_Graph, typename _Graph::Edge, Dummy>,
35.1165 + DummyEdgeMap >();
35.1166 + }
35.1167 + }
35.1168
35.1169 - _Graph& graph;
35.1170 + _Graph& graph;
35.1171 };
35.1172 };
35.1173
35.1174 @@ -1282,28 +1282,28 @@
35.1175 /// Adds a new node to the digraph.
35.1176 ///
35.1177 Node addNode() {
35.1178 - return INVALID;
35.1179 + return INVALID;
35.1180 }
35.1181 -
35.1182 +
35.1183 /// \brief Adds a new arc connects the given two nodes.
35.1184 ///
35.1185 /// Adds a new arc connects the the given two nodes.
35.1186 Arc addArc(const Node&, const Node&) {
35.1187 - return INVALID;
35.1188 + return INVALID;
35.1189 }
35.1190
35.1191 template <typename _Digraph>
35.1192 struct Constraints {
35.1193 - void constraints() {
35.1194 + void constraints() {
35.1195 checkConcept<Base, _Digraph>();
35.1196 - typename _Digraph::Node node_a, node_b;
35.1197 - node_a = digraph.addNode();
35.1198 - node_b = digraph.addNode();
35.1199 - typename _Digraph::Arc arc;
35.1200 - arc = digraph.addArc(node_a, node_b);
35.1201 - }
35.1202 + typename _Digraph::Node node_a, node_b;
35.1203 + node_a = digraph.addNode();
35.1204 + node_b = digraph.addNode();
35.1205 + typename _Digraph::Arc arc;
35.1206 + arc = digraph.addArc(node_a, node_b);
35.1207 + }
35.1208
35.1209 - _Digraph& digraph;
35.1210 + _Digraph& digraph;
35.1211 };
35.1212 };
35.1213
35.1214 @@ -1327,33 +1327,33 @@
35.1215 /// Adds a new node to the graph.
35.1216 ///
35.1217 Node addNode() {
35.1218 - return INVALID;
35.1219 + return INVALID;
35.1220 }
35.1221 -
35.1222 +
35.1223 /// \brief Adds a new arc connects the given two nodes.
35.1224 ///
35.1225 /// Adds a new arc connects the the given two nodes.
35.1226 Edge addArc(const Node&, const Node&) {
35.1227 - return INVALID;
35.1228 + return INVALID;
35.1229 }
35.1230
35.1231 template <typename _Graph>
35.1232 struct Constraints {
35.1233 - void constraints() {
35.1234 - checkConcept<Base, _Graph>();
35.1235 - typename _Graph::Node node_a, node_b;
35.1236 - node_a = graph.addNode();
35.1237 - node_b = graph.addNode();
35.1238 - typename _Graph::Edge edge;
35.1239 - edge = graph.addEdge(node_a, node_b);
35.1240 - }
35.1241 + void constraints() {
35.1242 + checkConcept<Base, _Graph>();
35.1243 + typename _Graph::Node node_a, node_b;
35.1244 + node_a = graph.addNode();
35.1245 + node_b = graph.addNode();
35.1246 + typename _Graph::Edge edge;
35.1247 + edge = graph.addEdge(node_a, node_b);
35.1248 + }
35.1249
35.1250 - _Graph& graph;
35.1251 + _Graph& graph;
35.1252 };
35.1253 };
35.1254
35.1255 /// \brief An empty erasable digraph class.
35.1256 - ///
35.1257 + ///
35.1258 /// This class provides beside the core digraph features core erase
35.1259 /// functions for the digraph structure. The main difference between
35.1260 /// the base and this interface is that the digraph alterations
35.1261 @@ -1368,9 +1368,9 @@
35.1262
35.1263 /// \brief Erase a node from the digraph.
35.1264 ///
35.1265 - /// Erase a node from the digraph. This function should
35.1266 + /// Erase a node from the digraph. This function should
35.1267 /// erase all arcs connecting to the node.
35.1268 - void erase(const Node&) {}
35.1269 + void erase(const Node&) {}
35.1270
35.1271 /// \brief Erase an arc from the digraph.
35.1272 ///
35.1273 @@ -1380,20 +1380,20 @@
35.1274
35.1275 template <typename _Digraph>
35.1276 struct Constraints {
35.1277 - void constraints() {
35.1278 + void constraints() {
35.1279 checkConcept<Base, _Digraph>();
35.1280 - typename _Digraph::Node node;
35.1281 - digraph.erase(node);
35.1282 - typename _Digraph::Arc arc;
35.1283 - digraph.erase(arc);
35.1284 - }
35.1285 + typename _Digraph::Node node;
35.1286 + digraph.erase(node);
35.1287 + typename _Digraph::Arc arc;
35.1288 + digraph.erase(arc);
35.1289 + }
35.1290
35.1291 - _Digraph& digraph;
35.1292 + _Digraph& digraph;
35.1293 };
35.1294 };
35.1295
35.1296 /// \brief An empty erasable base undirected graph class.
35.1297 - ///
35.1298 + ///
35.1299 /// This class provides beside the core undirected graph features
35.1300 /// core erase functions for the undirceted graph structure. The
35.1301 /// main difference between the base and this interface is that
35.1302 @@ -1410,7 +1410,7 @@
35.1303 ///
35.1304 /// Erase a node from the graph. This function should erase
35.1305 /// arcs connecting to the node.
35.1306 - void erase(const Node&) {}
35.1307 + void erase(const Node&) {}
35.1308
35.1309 /// \brief Erase an arc from the graph.
35.1310 ///
35.1311 @@ -1420,15 +1420,15 @@
35.1312
35.1313 template <typename _Graph>
35.1314 struct Constraints {
35.1315 - void constraints() {
35.1316 + void constraints() {
35.1317 checkConcept<Base, _Graph>();
35.1318 - typename _Graph::Node node;
35.1319 - graph.erase(node);
35.1320 - typename _Graph::Edge edge;
35.1321 - graph.erase(edge);
35.1322 - }
35.1323 + typename _Graph::Node node;
35.1324 + graph.erase(node);
35.1325 + typename _Graph::Edge edge;
35.1326 + graph.erase(edge);
35.1327 + }
35.1328
35.1329 - _Graph& graph;
35.1330 + _Graph& graph;
35.1331 };
35.1332 };
35.1333
35.1334 @@ -1448,16 +1448,16 @@
35.1335 ///
35.1336 /// Erase all nodes and arcs from the digraph.
35.1337 ///
35.1338 - void clear() {}
35.1339 + void clear() {}
35.1340
35.1341 template <typename _Digraph>
35.1342 struct Constraints {
35.1343 - void constraints() {
35.1344 + void constraints() {
35.1345 checkConcept<Base, _Digraph>();
35.1346 - digraph.clear();
35.1347 - }
35.1348 + digraph.clear();
35.1349 + }
35.1350
35.1351 - _Digraph digraph;
35.1352 + _Digraph digraph;
35.1353 };
35.1354 };
35.1355
35.1356 @@ -1475,11 +1475,11 @@
35.1357
35.1358 template <typename _Graph>
35.1359 struct Constraints {
35.1360 - void constraints() {
35.1361 + void constraints() {
35.1362 checkConcept<ClearableGraphComponent<Base>, _Graph>();
35.1363 - }
35.1364 + }
35.1365
35.1366 - _Graph graph;
35.1367 + _Graph graph;
35.1368 };
35.1369 };
35.1370
36.1 --- a/lemon/concepts/heap.h Sun Jul 13 16:46:56 2008 +0100
36.2 +++ b/lemon/concepts/heap.h Sun Jul 13 19:51:02 2008 +0100
36.3 @@ -1,6 +1,6 @@
36.4 -/* -*- C++ -*-
36.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
36.6 *
36.7 - * This file is a part of LEMON, a generic C++ optimization library
36.8 + * This file is a part of LEMON, a generic C++ optimization library.
36.9 *
36.10 * Copyright (C) 2003-2008
36.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
36.12 @@ -52,14 +52,14 @@
36.13 /// from the point of view of the heap, but may be useful for
36.14 /// the user.
36.15 ///
36.16 - /// The \c ItemIntMap must be initialized in such a way, that it
36.17 + /// The \c ItemIntMap must be initialized in such a way, that it
36.18 /// assigns \c PRE_HEAP (<tt>-1</tt>) to every item.
36.19 enum State {
36.20 - IN_HEAP = 0,
36.21 - PRE_HEAP = -1,
36.22 - POST_HEAP = -2
36.23 + IN_HEAP = 0,
36.24 + PRE_HEAP = -1,
36.25 + POST_HEAP = -2
36.26 };
36.27 -
36.28 +
36.29 /// \brief The constructor.
36.30 ///
36.31 /// The constructor.
36.32 @@ -85,8 +85,8 @@
36.33 void clear();
36.34
36.35 /// \brief Inserts an item into the heap with the given priority.
36.36 - ///
36.37 - /// Inserts the given item into the heap with the given priority.
36.38 + ///
36.39 + /// Inserts the given item into the heap with the given priority.
36.40 /// \param i The item to insert.
36.41 /// \param p The priority of the item.
36.42 void push(const Item &i, const Prio &p) {}
36.43 @@ -112,12 +112,12 @@
36.44 /// \brief Removes an item from the heap.
36.45 ///
36.46 /// Removes the given item from the heap if it is already stored.
36.47 - /// \param i The item to delete.
36.48 + /// \param i The item to delete.
36.49 void erase(const Item &i) {}
36.50
36.51 /// \brief The priority of an item.
36.52 ///
36.53 - /// Returns the priority of the given item.
36.54 + /// Returns the priority of the given item.
36.55 /// \pre \c i must be in the heap.
36.56 /// \param i The item.
36.57 Prio operator[](const Item &i) const {}
36.58 @@ -133,7 +133,7 @@
36.59 /// \param i The item.
36.60 /// \param p The priority.
36.61 void set(const Item &i, const Prio &p) {}
36.62 -
36.63 +
36.64 /// \brief Decreases the priority of an item to the given value.
36.65 ///
36.66 /// Decreases the priority of an item to the given value.
36.67 @@ -174,69 +174,69 @@
36.68 template <typename _Heap>
36.69 struct Constraints {
36.70 public:
36.71 - void constraints() {
36.72 - typedef typename _Heap::Item OwnItem;
36.73 - typedef typename _Heap::Prio OwnPrio;
36.74 - typedef typename _Heap::State OwnState;
36.75 + void constraints() {
36.76 + typedef typename _Heap::Item OwnItem;
36.77 + typedef typename _Heap::Prio OwnPrio;
36.78 + typedef typename _Heap::State OwnState;
36.79
36.80 - Item item;
36.81 - Prio prio;
36.82 - item=Item();
36.83 - prio=Prio();
36.84 - ignore_unused_variable_warning(item);
36.85 - ignore_unused_variable_warning(prio);
36.86 + Item item;
36.87 + Prio prio;
36.88 + item=Item();
36.89 + prio=Prio();
36.90 + ignore_unused_variable_warning(item);
36.91 + ignore_unused_variable_warning(prio);
36.92
36.93 - OwnItem own_item;
36.94 - OwnPrio own_prio;
36.95 - OwnState own_state;
36.96 - own_item=Item();
36.97 - own_prio=Prio();
36.98 - ignore_unused_variable_warning(own_item);
36.99 - ignore_unused_variable_warning(own_prio);
36.100 - ignore_unused_variable_warning(own_state);
36.101 + OwnItem own_item;
36.102 + OwnPrio own_prio;
36.103 + OwnState own_state;
36.104 + own_item=Item();
36.105 + own_prio=Prio();
36.106 + ignore_unused_variable_warning(own_item);
36.107 + ignore_unused_variable_warning(own_prio);
36.108 + ignore_unused_variable_warning(own_state);
36.109
36.110 - _Heap heap1(map);
36.111 - _Heap heap2 = heap1;
36.112 - ignore_unused_variable_warning(heap1);
36.113 - ignore_unused_variable_warning(heap2);
36.114 -
36.115 - int s = heap.size();
36.116 - ignore_unused_variable_warning(s);
36.117 - bool e = heap.empty();
36.118 - ignore_unused_variable_warning(e);
36.119 + _Heap heap1(map);
36.120 + _Heap heap2 = heap1;
36.121 + ignore_unused_variable_warning(heap1);
36.122 + ignore_unused_variable_warning(heap2);
36.123
36.124 - prio = heap.prio();
36.125 - item = heap.top();
36.126 - prio = heap[item];
36.127 - own_prio = heap.prio();
36.128 - own_item = heap.top();
36.129 - own_prio = heap[own_item];
36.130 + int s = heap.size();
36.131 + ignore_unused_variable_warning(s);
36.132 + bool e = heap.empty();
36.133 + ignore_unused_variable_warning(e);
36.134
36.135 - heap.push(item, prio);
36.136 - heap.push(own_item, own_prio);
36.137 - heap.pop();
36.138 + prio = heap.prio();
36.139 + item = heap.top();
36.140 + prio = heap[item];
36.141 + own_prio = heap.prio();
36.142 + own_item = heap.top();
36.143 + own_prio = heap[own_item];
36.144
36.145 - heap.set(item, prio);
36.146 - heap.decrease(item, prio);
36.147 - heap.increase(item, prio);
36.148 - heap.set(own_item, own_prio);
36.149 - heap.decrease(own_item, own_prio);
36.150 - heap.increase(own_item, own_prio);
36.151 + heap.push(item, prio);
36.152 + heap.push(own_item, own_prio);
36.153 + heap.pop();
36.154
36.155 - heap.erase(item);
36.156 - heap.erase(own_item);
36.157 - heap.clear();
36.158 + heap.set(item, prio);
36.159 + heap.decrease(item, prio);
36.160 + heap.increase(item, prio);
36.161 + heap.set(own_item, own_prio);
36.162 + heap.decrease(own_item, own_prio);
36.163 + heap.increase(own_item, own_prio);
36.164
36.165 - own_state = heap.state(own_item);
36.166 - heap.state(own_item, own_state);
36.167 + heap.erase(item);
36.168 + heap.erase(own_item);
36.169 + heap.clear();
36.170
36.171 - own_state = _Heap::PRE_HEAP;
36.172 - own_state = _Heap::IN_HEAP;
36.173 - own_state = _Heap::POST_HEAP;
36.174 - }
36.175 + own_state = heap.state(own_item);
36.176 + heap.state(own_item, own_state);
36.177
36.178 - _Heap& heap;
36.179 - ItemIntMap& map;
36.180 + own_state = _Heap::PRE_HEAP;
36.181 + own_state = _Heap::IN_HEAP;
36.182 + own_state = _Heap::POST_HEAP;
36.183 + }
36.184 +
36.185 + _Heap& heap;
36.186 + ItemIntMap& map;
36.187 };
36.188 };
36.189
37.1 --- a/lemon/concepts/maps.h Sun Jul 13 16:46:56 2008 +0100
37.2 +++ b/lemon/concepts/maps.h Sun Jul 13 19:51:02 2008 +0100
37.3 @@ -1,6 +1,6 @@
37.4 -/* -*- C++ -*-
37.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
37.6 *
37.7 - * This file is a part of LEMON, a generic C++ optimization library
37.8 + * This file is a part of LEMON, a generic C++ optimization library.
37.9 *
37.10 * Copyright (C) 2003-2008
37.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
37.12 @@ -47,26 +47,26 @@
37.13 typedef T Value;
37.14
37.15 /// Returns the value associated with the given key.
37.16 - Value operator[](const Key &) const {
37.17 + Value operator[](const Key &) const {
37.18 return *static_cast<Value *>(0);
37.19 }
37.20
37.21 template<typename _ReadMap>
37.22 struct Constraints {
37.23 - void constraints() {
37.24 - Value val = m[key];
37.25 - val = m[key];
37.26 - typename _ReadMap::Value own_val = m[own_key];
37.27 - own_val = m[own_key];
37.28 + void constraints() {
37.29 + Value val = m[key];
37.30 + val = m[key];
37.31 + typename _ReadMap::Value own_val = m[own_key];
37.32 + own_val = m[own_key];
37.33
37.34 - ignore_unused_variable_warning(key);
37.35 - ignore_unused_variable_warning(val);
37.36 - ignore_unused_variable_warning(own_key);
37.37 - ignore_unused_variable_warning(own_val);
37.38 - }
37.39 - const Key& key;
37.40 - const typename _ReadMap::Key& own_key;
37.41 - const _ReadMap& m;
37.42 + ignore_unused_variable_warning(key);
37.43 + ignore_unused_variable_warning(val);
37.44 + ignore_unused_variable_warning(own_key);
37.45 + ignore_unused_variable_warning(own_val);
37.46 + }
37.47 + const Key& key;
37.48 + const typename _ReadMap::Key& own_key;
37.49 + const _ReadMap& m;
37.50 };
37.51
37.52 };
37.53 @@ -93,20 +93,20 @@
37.54
37.55 template <typename _WriteMap>
37.56 struct Constraints {
37.57 - void constraints() {
37.58 - m.set(key, val);
37.59 - m.set(own_key, own_val);
37.60 + void constraints() {
37.61 + m.set(key, val);
37.62 + m.set(own_key, own_val);
37.63
37.64 - ignore_unused_variable_warning(key);
37.65 - ignore_unused_variable_warning(val);
37.66 - ignore_unused_variable_warning(own_key);
37.67 - ignore_unused_variable_warning(own_val);
37.68 - }
37.69 - const Key& key;
37.70 - const Value& val;
37.71 - const typename _WriteMap::Key& own_key;
37.72 - const typename _WriteMap::Value& own_val;
37.73 - _WriteMap& m;
37.74 + ignore_unused_variable_warning(key);
37.75 + ignore_unused_variable_warning(val);
37.76 + ignore_unused_variable_warning(own_key);
37.77 + ignore_unused_variable_warning(own_val);
37.78 + }
37.79 + const Key& key;
37.80 + const Value& val;
37.81 + const typename _WriteMap::Key& own_key;
37.82 + const typename _WriteMap::Value& own_val;
37.83 + _WriteMap& m;
37.84 };
37.85 };
37.86
37.87 @@ -116,7 +116,7 @@
37.88 ///
37.89 template<typename K, typename T>
37.90 class ReadWriteMap : public ReadMap<K,T>,
37.91 - public WriteMap<K,T>
37.92 + public WriteMap<K,T>
37.93 {
37.94 public:
37.95 /// The key type of the map.
37.96 @@ -125,7 +125,7 @@
37.97 typedef T Value;
37.98
37.99 /// Returns the value associated with the given key.
37.100 - Value operator[](const Key &) const {
37.101 + Value operator[](const Key &) const {
37.102 return *static_cast<Value *>(0);
37.103 }
37.104
37.105 @@ -134,10 +134,10 @@
37.106
37.107 template<typename _ReadWriteMap>
37.108 struct Constraints {
37.109 - void constraints() {
37.110 - checkConcept<ReadMap<K, T>, _ReadWriteMap >();
37.111 - checkConcept<WriteMap<K, T>, _ReadWriteMap >();
37.112 - }
37.113 + void constraints() {
37.114 + checkConcept<ReadMap<K, T>, _ReadWriteMap >();
37.115 + checkConcept<WriteMap<K, T>, _ReadWriteMap >();
37.116 + }
37.117 };
37.118 };
37.119
37.120 @@ -164,7 +164,7 @@
37.121 public:
37.122
37.123 /// Returns a reference to the value associated with the given key.
37.124 - Reference operator[](const Key &) {
37.125 + Reference operator[](const Key &) {
37.126 return *static_cast<Value *>(0);
37.127 }
37.128
37.129 @@ -178,28 +178,28 @@
37.130
37.131 template<typename _ReferenceMap>
37.132 struct Constraints {
37.133 - void constraints() {
37.134 - checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
37.135 - ref = m[key];
37.136 - m[key] = val;
37.137 - m[key] = ref;
37.138 - m[key] = cref;
37.139 - own_ref = m[own_key];
37.140 - m[own_key] = own_val;
37.141 - m[own_key] = own_ref;
37.142 - m[own_key] = own_cref;
37.143 - m[key] = m[own_key];
37.144 - m[own_key] = m[key];
37.145 - }
37.146 - const Key& key;
37.147 - Value& val;
37.148 - Reference ref;
37.149 - ConstReference cref;
37.150 - const typename _ReferenceMap::Key& own_key;
37.151 - typename _ReferenceMap::Value& own_val;
37.152 - typename _ReferenceMap::Reference own_ref;
37.153 - typename _ReferenceMap::ConstReference own_cref;
37.154 - _ReferenceMap& m;
37.155 + void constraints() {
37.156 + checkConcept<ReadWriteMap<K, T>, _ReferenceMap >();
37.157 + ref = m[key];
37.158 + m[key] = val;
37.159 + m[key] = ref;
37.160 + m[key] = cref;
37.161 + own_ref = m[own_key];
37.162 + m[own_key] = own_val;
37.163 + m[own_key] = own_ref;
37.164 + m[own_key] = own_cref;
37.165 + m[key] = m[own_key];
37.166 + m[own_key] = m[key];
37.167 + }
37.168 + const Key& key;
37.169 + Value& val;
37.170 + Reference ref;
37.171 + ConstReference cref;
37.172 + const typename _ReferenceMap::Key& own_key;
37.173 + typename _ReferenceMap::Value& own_val;
37.174 + typename _ReferenceMap::Reference own_ref;
37.175 + typename _ReferenceMap::ConstReference own_cref;
37.176 + _ReferenceMap& m;
37.177 };
37.178 };
37.179
38.1 --- a/lemon/concepts/path.h Sun Jul 13 16:46:56 2008 +0100
38.2 +++ b/lemon/concepts/path.h Sun Jul 13 19:51:02 2008 +0100
38.3 @@ -1,6 +1,6 @@
38.4 -/* -*- C++ -*-
38.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
38.6 *
38.7 - * This file is a part of LEMON, a generic C++ optimization library
38.8 + * This file is a part of LEMON, a generic C++ optimization library.
38.9 *
38.10 * Copyright (C) 2003-2008
38.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
38.12 @@ -39,7 +39,7 @@
38.13 /// a digraph.
38.14 ///
38.15 /// A skeleton structure for representing directed paths in a
38.16 - /// digraph.
38.17 + /// digraph.
38.18 /// \tparam _Digraph The digraph type in which the path is.
38.19 ///
38.20 /// In a sense, the path can be treated as a list of arcs. The
38.21 @@ -83,25 +83,25 @@
38.22 /// This class is used to iterate on the arcs of the paths.
38.23 class ArcIt {
38.24 public:
38.25 - /// Default constructor
38.26 - ArcIt() {}
38.27 - /// Invalid constructor
38.28 - ArcIt(Invalid) {}
38.29 - /// Constructor for first arc
38.30 - ArcIt(const Path &) {}
38.31 + /// Default constructor
38.32 + ArcIt() {}
38.33 + /// Invalid constructor
38.34 + ArcIt(Invalid) {}
38.35 + /// Constructor for first arc
38.36 + ArcIt(const Path &) {}
38.37
38.38 /// Conversion to Arc
38.39 - operator Arc() const { return INVALID; }
38.40 + operator Arc() const { return INVALID; }
38.41
38.42 - /// Next arc
38.43 - ArcIt& operator++() {return *this;}
38.44 + /// Next arc
38.45 + ArcIt& operator++() {return *this;}
38.46
38.47 - /// Comparison operator
38.48 - bool operator==(const ArcIt&) const {return true;}
38.49 - /// Comparison operator
38.50 - bool operator!=(const ArcIt&) const {return true;}
38.51 - /// Comparison operator
38.52 - bool operator<(const ArcIt&) const {return false;}
38.53 + /// Comparison operator
38.54 + bool operator==(const ArcIt&) const {return true;}
38.55 + /// Comparison operator
38.56 + bool operator!=(const ArcIt&) const {return true;}
38.57 + /// Comparison operator
38.58 + bool operator<(const ArcIt&) const {return false;}
38.59
38.60 };
38.61
38.62 @@ -137,7 +137,7 @@
38.63 };
38.64
38.65 namespace _path_bits {
38.66 -
38.67 +
38.68 template <typename _Digraph, typename _Path, typename RevPathTag = void>
38.69 struct PathDumperConstraints {
38.70 void constraints() {
38.71 @@ -162,7 +162,7 @@
38.72
38.73 template <typename _Digraph, typename _Path>
38.74 struct PathDumperConstraints<
38.75 - _Digraph, _Path,
38.76 + _Digraph, _Path,
38.77 typename enable_if<typename _Path::RevPathTag, void>::type
38.78 > {
38.79 void constraints() {
38.80 @@ -184,7 +184,7 @@
38.81 }
38.82 _Path& p;
38.83 };
38.84 -
38.85 +
38.86 }
38.87
38.88
38.89 @@ -209,7 +209,7 @@
38.90 ///
38.91 /// The paths can be constructed from any path type by a
38.92 /// template constructor or a template assignment operator.
38.93 - ///
38.94 + ///
38.95 template <typename _Digraph>
38.96 class PathDumper {
38.97 public:
38.98 @@ -238,25 +238,25 @@
38.99 /// This class is used to iterate on the arcs of the paths.
38.100 class ArcIt {
38.101 public:
38.102 - /// Default constructor
38.103 - ArcIt() {}
38.104 - /// Invalid constructor
38.105 - ArcIt(Invalid) {}
38.106 - /// Constructor for first arc
38.107 - ArcIt(const PathDumper&) {}
38.108 + /// Default constructor
38.109 + ArcIt() {}
38.110 + /// Invalid constructor
38.111 + ArcIt(Invalid) {}
38.112 + /// Constructor for first arc
38.113 + ArcIt(const PathDumper&) {}
38.114
38.115 /// Conversion to Arc
38.116 - operator Arc() const { return INVALID; }
38.117 + operator Arc() const { return INVALID; }
38.118
38.119 - /// Next arc
38.120 - ArcIt& operator++() {return *this;}
38.121 + /// Next arc
38.122 + ArcIt& operator++() {return *this;}
38.123
38.124 - /// Comparison operator
38.125 - bool operator==(const ArcIt&) const {return true;}
38.126 - /// Comparison operator
38.127 - bool operator!=(const ArcIt&) const {return true;}
38.128 - /// Comparison operator
38.129 - bool operator<(const ArcIt&) const {return false;}
38.130 + /// Comparison operator
38.131 + bool operator==(const ArcIt&) const {return true;}
38.132 + /// Comparison operator
38.133 + bool operator!=(const ArcIt&) const {return true;}
38.134 + /// Comparison operator
38.135 + bool operator<(const ArcIt&) const {return false;}
38.136
38.137 };
38.138
38.139 @@ -266,25 +266,25 @@
38.140 /// reverse direction.
38.141 class RevArcIt {
38.142 public:
38.143 - /// Default constructor
38.144 - RevArcIt() {}
38.145 - /// Invalid constructor
38.146 - RevArcIt(Invalid) {}
38.147 - /// Constructor for first arc
38.148 - RevArcIt(const PathDumper &) {}
38.149 + /// Default constructor
38.150 + RevArcIt() {}
38.151 + /// Invalid constructor
38.152 + RevArcIt(Invalid) {}
38.153 + /// Constructor for first arc
38.154 + RevArcIt(const PathDumper &) {}
38.155
38.156 /// Conversion to Arc
38.157 - operator Arc() const { return INVALID; }
38.158 + operator Arc() const { return INVALID; }
38.159
38.160 - /// Next arc
38.161 - RevArcIt& operator++() {return *this;}
38.162 + /// Next arc
38.163 + RevArcIt& operator++() {return *this;}
38.164
38.165 - /// Comparison operator
38.166 - bool operator==(const RevArcIt&) const {return true;}
38.167 - /// Comparison operator
38.168 - bool operator!=(const RevArcIt&) const {return true;}
38.169 - /// Comparison operator
38.170 - bool operator<(const RevArcIt&) const {return false;}
38.171 + /// Comparison operator
38.172 + bool operator==(const RevArcIt&) const {return true;}
38.173 + /// Comparison operator
38.174 + bool operator!=(const RevArcIt&) const {return true;}
38.175 + /// Comparison operator
38.176 + bool operator<(const RevArcIt&) const {return false;}
38.177
38.178 };
38.179
39.1 --- a/lemon/counter.h Sun Jul 13 16:46:56 2008 +0100
39.2 +++ b/lemon/counter.h Sun Jul 13 19:51:02 2008 +0100
39.3 @@ -1,6 +1,6 @@
39.4 -/* -*- C++ -*-
39.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
39.6 *
39.7 - * This file is a part of LEMON, a generic C++ optimization library
39.8 + * This file is a part of LEMON, a generic C++ optimization library.
39.9 *
39.10 * Copyright (C) 2003-2008
39.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
39.12 @@ -26,13 +26,13 @@
39.13 ///\file
39.14 ///\brief Tools for counting steps and events
39.15
39.16 -namespace lemon
39.17 +namespace lemon
39.18 {
39.19
39.20 template<class P> class _NoSubCounter;
39.21
39.22 template<class P>
39.23 - class _SubCounter
39.24 + class _SubCounter
39.25 {
39.26 P &_parent;
39.27 std::string _title;
39.28 @@ -49,7 +49,7 @@
39.29 : _parent(parent), _title(title), _os(os), count(0) {}
39.30 _SubCounter(P &parent,const char *title,std::ostream &os=std::cerr)
39.31 : _parent(parent), _title(title), _os(os), count(0) {}
39.32 - ~_SubCounter() {
39.33 + ~_SubCounter() {
39.34 _os << _title << count <<std::endl;
39.35 _parent+=count;
39.36 }
39.37 @@ -63,17 +63,17 @@
39.38 };
39.39
39.40 template<class P>
39.41 - class _NoSubCounter
39.42 + class _NoSubCounter
39.43 {
39.44 P &_parent;
39.45 public:
39.46 typedef _NoSubCounter<_NoSubCounter<P> > SubCounter;
39.47 typedef _NoSubCounter<_NoSubCounter<P> > NoSubCounter;
39.48 -
39.49 +
39.50 _NoSubCounter(P &parent) :_parent(parent) {}
39.51 - _NoSubCounter(P &parent,std::string,std::ostream &)
39.52 + _NoSubCounter(P &parent,std::string,std::ostream &)
39.53 :_parent(parent) {}
39.54 - _NoSubCounter(P &parent,std::string)
39.55 + _NoSubCounter(P &parent,std::string)
39.56 :_parent(parent) {}
39.57 _NoSubCounter(P &parent,const char *,std::ostream &)
39.58 :_parent(parent) {}
39.59 @@ -102,7 +102,7 @@
39.60 /// define subcounters for the different phases of the algorithm or
39.61 /// for different types of operations.
39.62 /// A report containing the given title and the value of the counter
39.63 - /// is automatically printed on destruction.
39.64 + /// is automatically printed on destruction.
39.65 ///
39.66 /// The following example shows the usage of counters and subcounters.
39.67 /// \code
39.68 @@ -133,7 +133,7 @@
39.69 /// \endcode
39.70 ///
39.71 /// \sa NoCounter
39.72 - class Counter
39.73 + class Counter
39.74 {
39.75 std::string _title;
39.76 std::ostream &_os;
39.77 @@ -141,13 +141,13 @@
39.78 public:
39.79
39.80 /// SubCounter class
39.81 -
39.82 +
39.83 /// This class can be used to setup subcounters for a \ref Counter
39.84 /// to have finer reports. A subcounter provides exactly the same
39.85 /// operations as the main \ref Counter, but it also increments and
39.86 /// decrements the value of its parent.
39.87 /// Subcounters can also have subcounters.
39.88 - ///
39.89 + ///
39.90 /// The parent counter must be given as the first parameter of the
39.91 /// constructor. Apart from that a title and an \c ostream object
39.92 /// can also be given just like for the main \ref Counter.
39.93 @@ -156,19 +156,19 @@
39.94 /// subcounter is automatically printed on destruction. If you
39.95 /// would like to turn off this report, use \ref NoSubCounter
39.96 /// instead.
39.97 - ///
39.98 + ///
39.99 /// \sa NoSubCounter
39.100 typedef _SubCounter<Counter> SubCounter;
39.101
39.102 - /// SubCounter class without printing report on destruction
39.103 -
39.104 + /// SubCounter class without printing report on destruction
39.105 +
39.106 /// This class can be used to setup subcounters for a \ref Counter.
39.107 /// It is the same as \ref SubCounter but it does not print report
39.108 /// on destruction. (It modifies the value of its parent, so 'No'
39.109 /// only means 'do not print'.)
39.110 ///
39.111 /// Replacing \ref SubCounter "SubCounter"s with \ref NoSubCounter
39.112 - /// "NoSubCounter"s makes it possible to turn off reporting
39.113 + /// "NoSubCounter"s makes it possible to turn off reporting
39.114 /// subcounter values without actually removing the definitions
39.115 /// and the increment or decrement operators.
39.116 ///
39.117 @@ -178,7 +178,7 @@
39.118 /// Constructor.
39.119 Counter() : _title(), _os(std::cerr), count(0) {}
39.120 /// Constructor.
39.121 - Counter(std::string title,std::ostream &os=std::cerr)
39.122 + Counter(std::string title,std::ostream &os=std::cerr)
39.123 : _title(title), _os(os), count(0) {}
39.124 /// Constructor.
39.125 Counter(const char *title,std::ostream &os=std::cerr)
39.126 @@ -204,7 +204,7 @@
39.127 /// Resets the counter to the given value.
39.128 /// \note This function does not reset the values of
39.129 /// \ref SubCounter "SubCounter"s but it resets \ref NoSubCounter
39.130 - /// "NoSubCounter"s along with the main counter.
39.131 + /// "NoSubCounter"s along with the main counter.
39.132 void reset(int c=0) {count=c;}
39.133 /// Returns the value of the counter.
39.134 operator int() {return count;}
40.1 --- a/lemon/dfs.h Sun Jul 13 16:46:56 2008 +0100
40.2 +++ b/lemon/dfs.h Sun Jul 13 19:51:02 2008 +0100
40.3 @@ -1,6 +1,6 @@
40.4 -/* -*- C++ -*-
40.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
40.6 *
40.7 - * This file is a part of LEMON, a generic C++ optimization library
40.8 + * This file is a part of LEMON, a generic C++ optimization library.
40.9 *
40.10 * Copyright (C) 2003-2008
40.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
40.12 @@ -34,7 +34,7 @@
40.13
40.14 namespace lemon {
40.15
40.16 -
40.17 +
40.18 ///Default traits class of Dfs class.
40.19
40.20 ///Default traits class of Dfs class.
40.21 @@ -42,35 +42,35 @@
40.22 template<class GR>
40.23 struct DfsDefaultTraits
40.24 {
40.25 - ///The digraph type the algorithm runs on.
40.26 + ///The digraph type the algorithm runs on.
40.27 typedef GR Digraph;
40.28 ///\brief The type of the map that stores the last
40.29 ///arcs of the %DFS paths.
40.30 - ///
40.31 + ///
40.32 ///The type of the map that stores the last
40.33 ///arcs of the %DFS paths.
40.34 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
40.35 ///
40.36 typedef typename Digraph::template NodeMap<typename GR::Arc> PredMap;
40.37 ///Instantiates a PredMap.
40.38 -
40.39 - ///This function instantiates a \ref PredMap.
40.40 +
40.41 + ///This function instantiates a \ref PredMap.
40.42 ///\param G is the digraph, to which we would like to define the PredMap.
40.43 ///\todo The digraph alone may be insufficient to initialize
40.44 - static PredMap *createPredMap(const GR &G)
40.45 + static PredMap *createPredMap(const GR &G)
40.46 {
40.47 return new PredMap(G);
40.48 }
40.49
40.50 ///The type of the map that indicates which nodes are processed.
40.51 -
40.52 +
40.53 ///The type of the map that indicates which nodes are processed.
40.54 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
40.55 ///\todo named parameter to set this type, function to read and write.
40.56 typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
40.57 ///Instantiates a ProcessedMap.
40.58 -
40.59 - ///This function instantiates a \ref ProcessedMap.
40.60 +
40.61 + ///This function instantiates a \ref ProcessedMap.
40.62 ///\param g is the digraph, to which
40.63 ///we would like to define the \ref ProcessedMap
40.64 #ifdef DOXYGEN
40.65 @@ -82,14 +82,14 @@
40.66 return new ProcessedMap();
40.67 }
40.68 ///The type of the map that indicates which nodes are reached.
40.69 -
40.70 +
40.71 ///The type of the map that indicates which nodes are reached.
40.72 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
40.73 ///\todo named parameter to set this type, function to read and write.
40.74 typedef typename Digraph::template NodeMap<bool> ReachedMap;
40.75 ///Instantiates a ReachedMap.
40.76 -
40.77 - ///This function instantiates a \ref ReachedMap.
40.78 +
40.79 + ///This function instantiates a \ref ReachedMap.
40.80 ///\param G is the digraph, to which
40.81 ///we would like to define the \ref ReachedMap.
40.82 static ReachedMap *createReachedMap(const GR &G)
40.83 @@ -97,23 +97,23 @@
40.84 return new ReachedMap(G);
40.85 }
40.86 ///The type of the map that stores the dists of the nodes.
40.87 -
40.88 +
40.89 ///The type of the map that stores the dists of the nodes.
40.90 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
40.91 ///
40.92 typedef typename Digraph::template NodeMap<int> DistMap;
40.93 ///Instantiates a DistMap.
40.94 -
40.95 - ///This function instantiates a \ref DistMap.
40.96 +
40.97 + ///This function instantiates a \ref DistMap.
40.98 ///\param G is the digraph, to which we would like to define the \ref DistMap
40.99 static DistMap *createDistMap(const GR &G)
40.100 {
40.101 return new DistMap(G);
40.102 }
40.103 };
40.104 -
40.105 +
40.106 ///%DFS algorithm class.
40.107 -
40.108 +
40.109 ///\ingroup search
40.110 ///This class provides an efficient implementation of the %DFS algorithm.
40.111 ///
40.112 @@ -127,10 +127,10 @@
40.113 ///a Dfs traits class.
40.114 #ifdef DOXYGEN
40.115 template <typename GR,
40.116 - typename TR>
40.117 + typename TR>
40.118 #else
40.119 template <typename GR=ListDigraph,
40.120 - typename TR=DfsDefaultTraits<GR> >
40.121 + typename TR=DfsDefaultTraits<GR> >
40.122 #endif
40.123 class Dfs {
40.124 public:
40.125 @@ -143,7 +143,7 @@
40.126 class UninitializedParameter : public lemon::UninitializedParameter {
40.127 public:
40.128 virtual const char* what() const throw() {
40.129 - return "lemon::Dfs::UninitializedParameter";
40.130 + return "lemon::Dfs::UninitializedParameter";
40.131 }
40.132 };
40.133
40.134 @@ -158,7 +158,7 @@
40.135 typedef typename Digraph::Arc Arc;
40.136 ///\e
40.137 typedef typename Digraph::OutArcIt OutArcIt;
40.138 -
40.139 +
40.140 ///\brief The type of the map that stores the last
40.141 ///arcs of the %DFS paths.
40.142 typedef typename TR::PredMap PredMap;
40.143 @@ -192,32 +192,32 @@
40.144 int _stack_head;
40.145
40.146 ///Creates the maps if necessary.
40.147 -
40.148 +
40.149 ///\todo Better memory allocation (instead of new).
40.150 - void create_maps()
40.151 + void create_maps()
40.152 {
40.153 if(!_pred) {
40.154 - local_pred = true;
40.155 - _pred = Traits::createPredMap(*G);
40.156 + local_pred = true;
40.157 + _pred = Traits::createPredMap(*G);
40.158 }
40.159 if(!_dist) {
40.160 - local_dist = true;
40.161 - _dist = Traits::createDistMap(*G);
40.162 + local_dist = true;
40.163 + _dist = Traits::createDistMap(*G);
40.164 }
40.165 if(!_reached) {
40.166 - local_reached = true;
40.167 - _reached = Traits::createReachedMap(*G);
40.168 + local_reached = true;
40.169 + _reached = Traits::createReachedMap(*G);
40.170 }
40.171 if(!_processed) {
40.172 - local_processed = true;
40.173 - _processed = Traits::createProcessedMap(*G);
40.174 + local_processed = true;
40.175 + _processed = Traits::createProcessedMap(*G);
40.176 }
40.177 }
40.178
40.179 protected:
40.180
40.181 Dfs() {}
40.182 -
40.183 +
40.184 public:
40.185
40.186 typedef Dfs Create;
40.187 @@ -229,9 +229,9 @@
40.188 template <class T>
40.189 struct DefPredMapTraits : public Traits {
40.190 typedef T PredMap;
40.191 - static PredMap *createPredMap(const Digraph &G)
40.192 + static PredMap *createPredMap(const Digraph &G)
40.193 {
40.194 - throw UninitializedParameter();
40.195 + throw UninitializedParameter();
40.196 }
40.197 };
40.198 ///\brief \ref named-templ-param "Named parameter" for setting
40.199 @@ -243,14 +243,14 @@
40.200 struct DefPredMap : public Dfs<Digraph, DefPredMapTraits<T> > {
40.201 typedef Dfs<Digraph, DefPredMapTraits<T> > Create;
40.202 };
40.203 -
40.204 -
40.205 +
40.206 +
40.207 template <class T>
40.208 struct DefDistMapTraits : public Traits {
40.209 typedef T DistMap;
40.210 - static DistMap *createDistMap(const Digraph &)
40.211 + static DistMap *createDistMap(const Digraph &)
40.212 {
40.213 - throw UninitializedParameter();
40.214 + throw UninitializedParameter();
40.215 }
40.216 };
40.217 ///\brief \ref named-templ-param "Named parameter" for setting
40.218 @@ -262,13 +262,13 @@
40.219 struct DefDistMap {
40.220 typedef Dfs<Digraph, DefDistMapTraits<T> > Create;
40.221 };
40.222 -
40.223 +
40.224 template <class T>
40.225 struct DefReachedMapTraits : public Traits {
40.226 typedef T ReachedMap;
40.227 - static ReachedMap *createReachedMap(const Digraph &)
40.228 + static ReachedMap *createReachedMap(const Digraph &)
40.229 {
40.230 - throw UninitializedParameter();
40.231 + throw UninitializedParameter();
40.232 }
40.233 };
40.234 ///\brief \ref named-templ-param "Named parameter" for setting
40.235 @@ -284,9 +284,9 @@
40.236 template <class T>
40.237 struct DefProcessedMapTraits : public Traits {
40.238 typedef T ProcessedMap;
40.239 - static ProcessedMap *createProcessedMap(const Digraph &)
40.240 + static ProcessedMap *createProcessedMap(const Digraph &)
40.241 {
40.242 - throw UninitializedParameter();
40.243 + throw UninitializedParameter();
40.244 }
40.245 };
40.246 ///\brief \ref named-templ-param "Named parameter" for setting
40.247 @@ -295,15 +295,15 @@
40.248 ///\ref named-templ-param "Named parameter" for setting ProcessedMap type
40.249 ///
40.250 template <class T>
40.251 - struct DefProcessedMap : public Dfs< Digraph, DefProcessedMapTraits<T> > {
40.252 + struct DefProcessedMap : public Dfs< Digraph, DefProcessedMapTraits<T> > {
40.253 typedef Dfs< Digraph, DefProcessedMapTraits<T> > Create;
40.254 };
40.255 -
40.256 +
40.257 struct DefDigraphProcessedMapTraits : public Traits {
40.258 typedef typename Digraph::template NodeMap<bool> ProcessedMap;
40.259 - static ProcessedMap *createProcessedMap(const Digraph &G)
40.260 + static ProcessedMap *createProcessedMap(const Digraph &G)
40.261 {
40.262 - return new ProcessedMap(G);
40.263 + return new ProcessedMap(G);
40.264 }
40.265 };
40.266 ///\brief \ref named-templ-param "Named parameter"
40.267 @@ -314,16 +314,16 @@
40.268 ///If you don't set it explicitely, it will be automatically allocated.
40.269 template <class T>
40.270 class DefProcessedMapToBeDefaultMap :
40.271 - public Dfs< Digraph, DefDigraphProcessedMapTraits> {
40.272 + public Dfs< Digraph, DefDigraphProcessedMapTraits> {
40.273 typedef Dfs< Digraph, DefDigraphProcessedMapTraits> Create;
40.274 };
40.275 -
40.276 +
40.277 ///@}
40.278
40.279 - public:
40.280 -
40.281 + public:
40.282 +
40.283 ///Constructor.
40.284 -
40.285 +
40.286 ///\param _G the digraph the algorithm will run on.
40.287 ///
40.288 Dfs(const Digraph& _G) :
40.289 @@ -333,9 +333,9 @@
40.290 _reached(NULL), local_reached(false),
40.291 _processed(NULL), local_processed(false)
40.292 { }
40.293 -
40.294 +
40.295 ///Destructor.
40.296 - ~Dfs()
40.297 + ~Dfs()
40.298 {
40.299 if(local_pred) delete _pred;
40.300 if(local_dist) delete _dist;
40.301 @@ -350,11 +350,11 @@
40.302 ///it will allocate one. The destuctor deallocates this
40.303 ///automatically allocated map, of course.
40.304 ///\return <tt> (*this) </tt>
40.305 - Dfs &predMap(PredMap &m)
40.306 + Dfs &predMap(PredMap &m)
40.307 {
40.308 if(local_pred) {
40.309 - delete _pred;
40.310 - local_pred=false;
40.311 + delete _pred;
40.312 + local_pred=false;
40.313 }
40.314 _pred = &m;
40.315 return *this;
40.316 @@ -367,11 +367,11 @@
40.317 ///it will allocate one. The destuctor deallocates this
40.318 ///automatically allocated map, of course.
40.319 ///\return <tt> (*this) </tt>
40.320 - Dfs &distMap(DistMap &m)
40.321 + Dfs &distMap(DistMap &m)
40.322 {
40.323 if(local_dist) {
40.324 - delete _dist;
40.325 - local_dist=false;
40.326 + delete _dist;
40.327 + local_dist=false;
40.328 }
40.329 _dist = &m;
40.330 return *this;
40.331 @@ -384,11 +384,11 @@
40.332 ///it will allocate one. The destuctor deallocates this
40.333 ///automatically allocated map, of course.
40.334 ///\return <tt> (*this) </tt>
40.335 - Dfs &reachedMap(ReachedMap &m)
40.336 + Dfs &reachedMap(ReachedMap &m)
40.337 {
40.338 if(local_reached) {
40.339 - delete _reached;
40.340 - local_reached=false;
40.341 + delete _reached;
40.342 + local_reached=false;
40.343 }
40.344 _reached = &m;
40.345 return *this;
40.346 @@ -401,11 +401,11 @@
40.347 ///it will allocate one. The destuctor deallocates this
40.348 ///automatically allocated map, of course.
40.349 ///\return <tt> (*this) </tt>
40.350 - Dfs &processedMap(ProcessedMap &m)
40.351 + Dfs &processedMap(ProcessedMap &m)
40.352 {
40.353 if(local_processed) {
40.354 - delete _processed;
40.355 - local_processed=false;
40.356 + delete _processed;
40.357 + local_processed=false;
40.358 }
40.359 _processed = &m;
40.360 return *this;
40.361 @@ -434,13 +434,13 @@
40.362 _stack.resize(countNodes(*G));
40.363 _stack_head=-1;
40.364 for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
40.365 - _pred->set(u,INVALID);
40.366 - // _predNode->set(u,INVALID);
40.367 - _reached->set(u,false);
40.368 - _processed->set(u,false);
40.369 + _pred->set(u,INVALID);
40.370 + // _predNode->set(u,INVALID);
40.371 + _reached->set(u,false);
40.372 + _processed->set(u,false);
40.373 }
40.374 }
40.375 -
40.376 +
40.377 ///Adds a new source node.
40.378
40.379 ///Adds a new source node to the set of nodes to be processed.
40.380 @@ -450,21 +450,21 @@
40.381 void addSource(Node s)
40.382 {
40.383 if(!(*_reached)[s])
40.384 - {
40.385 - _reached->set(s,true);
40.386 - _pred->set(s,INVALID);
40.387 - OutArcIt e(*G,s);
40.388 - if(e!=INVALID) {
40.389 - _stack[++_stack_head]=e;
40.390 - _dist->set(s,_stack_head);
40.391 - }
40.392 - else {
40.393 - _processed->set(s,true);
40.394 - _dist->set(s,0);
40.395 - }
40.396 - }
40.397 + {
40.398 + _reached->set(s,true);
40.399 + _pred->set(s,INVALID);
40.400 + OutArcIt e(*G,s);
40.401 + if(e!=INVALID) {
40.402 + _stack[++_stack_head]=e;
40.403 + _dist->set(s,_stack_head);
40.404 + }
40.405 + else {
40.406 + _processed->set(s,true);
40.407 + _dist->set(s,0);
40.408 + }
40.409 + }
40.410 }
40.411 -
40.412 +
40.413 ///Processes the next arc.
40.414
40.415 ///Processes the next arc.
40.416 @@ -473,27 +473,27 @@
40.417 ///
40.418 ///\pre The stack must not be empty!
40.419 Arc processNextArc()
40.420 - {
40.421 + {
40.422 Node m;
40.423 Arc e=_stack[_stack_head];
40.424 if(!(*_reached)[m=G->target(e)]) {
40.425 - _pred->set(m,e);
40.426 - _reached->set(m,true);
40.427 - ++_stack_head;
40.428 - _stack[_stack_head] = OutArcIt(*G, m);
40.429 - _dist->set(m,_stack_head);
40.430 + _pred->set(m,e);
40.431 + _reached->set(m,true);
40.432 + ++_stack_head;
40.433 + _stack[_stack_head] = OutArcIt(*G, m);
40.434 + _dist->set(m,_stack_head);
40.435 }
40.436 else {
40.437 - m=G->source(e);
40.438 - ++_stack[_stack_head];
40.439 + m=G->source(e);
40.440 + ++_stack[_stack_head];
40.441 }
40.442 while(_stack_head>=0 && _stack[_stack_head]==INVALID) {
40.443 - _processed->set(m,true);
40.444 - --_stack_head;
40.445 - if(_stack_head>=0) {
40.446 - m=G->source(_stack[_stack_head]);
40.447 - ++_stack[_stack_head];
40.448 - }
40.449 + _processed->set(m,true);
40.450 + --_stack_head;
40.451 + if(_stack_head>=0) {
40.452 + m=G->source(_stack[_stack_head]);
40.453 + ++_stack[_stack_head];
40.454 + }
40.455 }
40.456 return e;
40.457 }
40.458 @@ -504,7 +504,7 @@
40.459 ///\return The next arc to be processed or INVALID if the stack is
40.460 /// empty.
40.461 OutArcIt nextArc()
40.462 - {
40.463 + {
40.464 return _stack_head>=0?_stack[_stack_head]:INVALID;
40.465 }
40.466
40.467 @@ -515,10 +515,10 @@
40.468 ///to be processed in the queue
40.469 bool emptyQueue() { return _stack_head<0; }
40.470 ///Returns the number of the nodes to be processed.
40.471 -
40.472 +
40.473 ///Returns the number of the nodes to be processed in the queue.
40.474 int queueSize() { return _stack_head+1; }
40.475 -
40.476 +
40.477 ///Executes the algorithm.
40.478
40.479 ///Executes the algorithm.
40.480 @@ -537,7 +537,7 @@
40.481 {
40.482 while ( !emptyQueue() ) processNextArc();
40.483 }
40.484 -
40.485 +
40.486 ///Executes the algorithm until \c dest is reached.
40.487
40.488 ///Executes the algorithm until \c dest is reached.
40.489 @@ -554,10 +554,10 @@
40.490 ///
40.491 void start(Node dest)
40.492 {
40.493 - while ( !emptyQueue() && G->target(_stack[_stack_head])!=dest )
40.494 - processNextArc();
40.495 + while ( !emptyQueue() && G->target(_stack[_stack_head])!=dest )
40.496 + processNextArc();
40.497 }
40.498 -
40.499 +
40.500 ///Executes the algorithm until a condition is met.
40.501
40.502 ///Executes the algorithm until a condition is met.
40.503 @@ -582,7 +582,7 @@
40.504 }
40.505
40.506 ///Runs %DFS algorithm to visit all nodes in the digraph.
40.507 -
40.508 +
40.509 ///This method runs the %DFS algorithm in order to
40.510 ///compute the
40.511 ///%DFS path to each node. The algorithm computes
40.512 @@ -610,7 +610,7 @@
40.513 }
40.514
40.515 ///Runs %DFS algorithm from node \c s.
40.516 -
40.517 +
40.518 ///This method runs the %DFS algorithm from a root node \c s
40.519 ///in order to
40.520 ///compute the
40.521 @@ -629,9 +629,9 @@
40.522 addSource(s);
40.523 start();
40.524 }
40.525 -
40.526 +
40.527 ///Finds the %DFS path between \c s and \c t.
40.528 -
40.529 +
40.530 ///Finds the %DFS path between \c s and \c t.
40.531 ///
40.532 ///\return The length of the %DFS s---t path if there exists one,
40.533 @@ -649,7 +649,7 @@
40.534 start(t);
40.535 return reached(t)?_stack_head+1:0;
40.536 }
40.537 -
40.538 +
40.539 ///@}
40.540
40.541 ///\name Query Functions
40.542 @@ -657,16 +657,16 @@
40.543 ///functions.\n
40.544 ///Before the use of these functions,
40.545 ///either run() or start() must be called.
40.546 -
40.547 +
40.548 ///@{
40.549
40.550 typedef PredMapPath<Digraph, PredMap> Path;
40.551
40.552 ///Gives back the shortest path.
40.553 -
40.554 +
40.555 ///Gives back the shortest path.
40.556 ///\pre The \c t should be reachable from the source.
40.557 - Path path(Node t)
40.558 + Path path(Node t)
40.559 {
40.560 return Path(*G, *_pred, t);
40.561 }
40.562 @@ -675,7 +675,7 @@
40.563
40.564 ///Returns the distance of a node from the root(s).
40.565 ///\pre \ref run() must be called before using this function.
40.566 - ///\warning If node \c v is unreachable from the root(s) then the return
40.567 + ///\warning If node \c v is unreachable from the root(s) then the return
40.568 ///value of this funcion is undefined.
40.569 int dist(Node v) const { return (*_dist)[v]; }
40.570
40.571 @@ -705,15 +705,15 @@
40.572 ///\pre Either \ref run() or \ref start() must be called before
40.573 ///using this function.
40.574 Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
40.575 - G->source((*_pred)[v]); }
40.576 -
40.577 + G->source((*_pred)[v]); }
40.578 +
40.579 ///Returns a reference to the NodeMap of distances.
40.580
40.581 ///Returns a reference to the NodeMap of distances.
40.582 ///\pre Either \ref run() or \ref init() must
40.583 ///be called before using this function.
40.584 const DistMap &distMap() const { return *_dist;}
40.585 -
40.586 +
40.587 ///Returns a reference to the %DFS arc-tree map.
40.588
40.589 ///Returns a reference to the NodeMap of the arcs of the
40.590 @@ -721,7 +721,7 @@
40.591 ///\pre Either \ref run() or \ref init()
40.592 ///must be called before using this function.
40.593 const PredMap &predMap() const { return *_pred;}
40.594 -
40.595 +
40.596 ///Checks if a node is reachable from the root.
40.597
40.598 ///Returns \c true if \c v is reachable from the root(s).
40.599 @@ -730,7 +730,7 @@
40.600 ///must be called before using this function.
40.601 ///
40.602 bool reached(Node v) { return (*_reached)[v]; }
40.603 -
40.604 +
40.605 ///@}
40.606 };
40.607
40.608 @@ -741,39 +741,39 @@
40.609 template<class GR>
40.610 struct DfsWizardDefaultTraits
40.611 {
40.612 - ///The digraph type the algorithm runs on.
40.613 + ///The digraph type the algorithm runs on.
40.614 typedef GR Digraph;
40.615 ///\brief The type of the map that stores the last
40.616 ///arcs of the %DFS paths.
40.617 - ///
40.618 + ///
40.619 ///The type of the map that stores the last
40.620 ///arcs of the %DFS paths.
40.621 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
40.622 ///
40.623 typedef NullMap<typename Digraph::Node,typename GR::Arc> PredMap;
40.624 ///Instantiates a PredMap.
40.625 -
40.626 - ///This function instantiates a \ref PredMap.
40.627 +
40.628 + ///This function instantiates a \ref PredMap.
40.629 ///\param g is the digraph, to which we would like to define the PredMap.
40.630 ///\todo The digraph alone may be insufficient to initialize
40.631 #ifdef DOXYGEN
40.632 - static PredMap *createPredMap(const GR &g)
40.633 + static PredMap *createPredMap(const GR &g)
40.634 #else
40.635 - static PredMap *createPredMap(const GR &)
40.636 + static PredMap *createPredMap(const GR &)
40.637 #endif
40.638 {
40.639 return new PredMap();
40.640 }
40.641
40.642 ///The type of the map that indicates which nodes are processed.
40.643 -
40.644 +
40.645 ///The type of the map that indicates which nodes are processed.
40.646 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
40.647 ///\todo named parameter to set this type, function to read and write.
40.648 typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
40.649 ///Instantiates a ProcessedMap.
40.650 -
40.651 - ///This function instantiates a \ref ProcessedMap.
40.652 +
40.653 + ///This function instantiates a \ref ProcessedMap.
40.654 ///\param g is the digraph, to which
40.655 ///we would like to define the \ref ProcessedMap
40.656 #ifdef DOXYGEN
40.657 @@ -785,14 +785,14 @@
40.658 return new ProcessedMap();
40.659 }
40.660 ///The type of the map that indicates which nodes are reached.
40.661 -
40.662 +
40.663 ///The type of the map that indicates which nodes are reached.
40.664 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
40.665 ///\todo named parameter to set this type, function to read and write.
40.666 typedef typename Digraph::template NodeMap<bool> ReachedMap;
40.667 ///Instantiates a ReachedMap.
40.668 -
40.669 - ///This function instantiates a \ref ReachedMap.
40.670 +
40.671 + ///This function instantiates a \ref ReachedMap.
40.672 ///\param G is the digraph, to which
40.673 ///we would like to define the \ref ReachedMap.
40.674 static ReachedMap *createReachedMap(const GR &G)
40.675 @@ -800,14 +800,14 @@
40.676 return new ReachedMap(G);
40.677 }
40.678 ///The type of the map that stores the dists of the nodes.
40.679 -
40.680 +
40.681 ///The type of the map that stores the dists of the nodes.
40.682 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
40.683 ///
40.684 typedef NullMap<typename Digraph::Node,int> DistMap;
40.685 ///Instantiates a DistMap.
40.686 -
40.687 - ///This function instantiates a \ref DistMap.
40.688 +
40.689 + ///This function instantiates a \ref DistMap.
40.690 ///\param g is the digraph, to which we would like to define the \ref DistMap
40.691 #ifdef DOXYGEN
40.692 static DistMap *createDistMap(const GR &g)
40.693 @@ -818,7 +818,7 @@
40.694 return new DistMap();
40.695 }
40.696 };
40.697 -
40.698 +
40.699 /// Default traits used by \ref DfsWizard
40.700
40.701 /// To make it easier to use Dfs algorithm
40.702 @@ -848,28 +848,28 @@
40.703 void *_dist;
40.704 ///Pointer to the source node.
40.705 Node _source;
40.706 -
40.707 +
40.708 public:
40.709 /// Constructor.
40.710 -
40.711 +
40.712 /// This constructor does not require parameters, therefore it initiates
40.713 /// all of the attributes to default values (0, INVALID).
40.714 DfsWizardBase() : _g(0), _reached(0), _processed(0), _pred(0),
40.715 - _dist(0), _source(INVALID) {}
40.716 + _dist(0), _source(INVALID) {}
40.717
40.718 /// Constructor.
40.719 -
40.720 +
40.721 /// This constructor requires some parameters,
40.722 /// listed in the parameters list.
40.723 /// Others are initiated to 0.
40.724 /// \param g is the initial value of \ref _g
40.725 /// \param s is the initial value of \ref _source
40.726 DfsWizardBase(const GR &g, Node s=INVALID) :
40.727 - _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
40.728 + _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
40.729 _reached(0), _processed(0), _pred(0), _dist(0), _source(s) {}
40.730
40.731 };
40.732 -
40.733 +
40.734 /// A class to make the usage of the Dfs algorithm easier
40.735
40.736 /// This class is created to make it easier to use the Dfs algorithm.
40.737 @@ -904,7 +904,7 @@
40.738 typedef typename Digraph::Arc Arc;
40.739 //\e
40.740 typedef typename Digraph::OutArcIt OutArcIt;
40.741 -
40.742 +
40.743 ///\brief The type of the map that stores
40.744 ///the reached nodes
40.745 typedef typename TR::ReachedMap ReachedMap;
40.746 @@ -934,20 +934,20 @@
40.747 ~DfsWizard() {}
40.748
40.749 ///Runs Dfs algorithm from a given node.
40.750 -
40.751 +
40.752 ///Runs Dfs algorithm from a given node.
40.753 ///The node can be given by the \ref source function.
40.754 void run()
40.755 {
40.756 if(Base::_source==INVALID) throw UninitializedParameter();
40.757 Dfs<Digraph,TR> alg(*reinterpret_cast<const Digraph*>(Base::_g));
40.758 - if(Base::_reached)
40.759 + if(Base::_reached)
40.760 alg.reachedMap(*reinterpret_cast<ReachedMap*>(Base::_reached));
40.761 - if(Base::_processed)
40.762 + if(Base::_processed)
40.763 alg.processedMap(*reinterpret_cast<ProcessedMap*>(Base::_processed));
40.764 - if(Base::_pred)
40.765 + if(Base::_pred)
40.766 alg.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
40.767 - if(Base::_dist)
40.768 + if(Base::_dist)
40.769 alg.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
40.770 alg.run(Base::_source);
40.771 }
40.772 @@ -968,7 +968,7 @@
40.773 static PredMap *createPredMap(const Digraph &) { return 0; };
40.774 DefPredMapBase(const TR &b) : TR(b) {}
40.775 };
40.776 -
40.777 +
40.778 ///\brief \ref named-templ-param "Named parameter"
40.779 ///function for setting PredMap type
40.780 ///
40.781 @@ -976,20 +976,20 @@
40.782 ///function for setting PredMap type
40.783 ///
40.784 template<class T>
40.785 - DfsWizard<DefPredMapBase<T> > predMap(const T &t)
40.786 + DfsWizard<DefPredMapBase<T> > predMap(const T &t)
40.787 {
40.788 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
40.789 return DfsWizard<DefPredMapBase<T> >(*this);
40.790 }
40.791 -
40.792 -
40.793 +
40.794 +
40.795 template<class T>
40.796 struct DefReachedMapBase : public Base {
40.797 typedef T ReachedMap;
40.798 static ReachedMap *createReachedMap(const Digraph &) { return 0; };
40.799 DefReachedMapBase(const TR &b) : TR(b) {}
40.800 };
40.801 -
40.802 +
40.803 ///\brief \ref named-templ-param "Named parameter"
40.804 ///function for setting ReachedMap
40.805 ///
40.806 @@ -997,12 +997,12 @@
40.807 ///function for setting ReachedMap
40.808 ///
40.809 template<class T>
40.810 - DfsWizard<DefReachedMapBase<T> > reachedMap(const T &t)
40.811 + DfsWizard<DefReachedMapBase<T> > reachedMap(const T &t)
40.812 {
40.813 Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t));
40.814 return DfsWizard<DefReachedMapBase<T> >(*this);
40.815 }
40.816 -
40.817 +
40.818
40.819 template<class T>
40.820 struct DefProcessedMapBase : public Base {
40.821 @@ -1010,7 +1010,7 @@
40.822 static ProcessedMap *createProcessedMap(const Digraph &) { return 0; };
40.823 DefProcessedMapBase(const TR &b) : TR(b) {}
40.824 };
40.825 -
40.826 +
40.827 ///\brief \ref named-templ-param "Named parameter"
40.828 ///function for setting ProcessedMap
40.829 ///
40.830 @@ -1018,19 +1018,19 @@
40.831 ///function for setting ProcessedMap
40.832 ///
40.833 template<class T>
40.834 - DfsWizard<DefProcessedMapBase<T> > processedMap(const T &t)
40.835 + DfsWizard<DefProcessedMapBase<T> > processedMap(const T &t)
40.836 {
40.837 Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t));
40.838 return DfsWizard<DefProcessedMapBase<T> >(*this);
40.839 }
40.840 -
40.841 +
40.842 template<class T>
40.843 struct DefDistMapBase : public Base {
40.844 typedef T DistMap;
40.845 static DistMap *createDistMap(const Digraph &) { return 0; };
40.846 DefDistMapBase(const TR &b) : TR(b) {}
40.847 };
40.848 -
40.849 +
40.850 ///\brief \ref named-templ-param "Named parameter"
40.851 ///function for setting DistMap type
40.852 ///
40.853 @@ -1038,24 +1038,24 @@
40.854 ///function for setting DistMap type
40.855 ///
40.856 template<class T>
40.857 - DfsWizard<DefDistMapBase<T> > distMap(const T &t)
40.858 + DfsWizard<DefDistMapBase<T> > distMap(const T &t)
40.859 {
40.860 Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
40.861 return DfsWizard<DefDistMapBase<T> >(*this);
40.862 }
40.863 -
40.864 +
40.865 /// Sets the source node, from which the Dfs algorithm runs.
40.866
40.867 /// Sets the source node, from which the Dfs algorithm runs.
40.868 /// \param s is the source node.
40.869 - DfsWizard<TR> &source(Node s)
40.870 + DfsWizard<TR> &source(Node s)
40.871 {
40.872 Base::_source=s;
40.873 return *this;
40.874 }
40.875 -
40.876 +
40.877 };
40.878 -
40.879 +
40.880 ///Function type interface for Dfs algorithm.
40.881
40.882 ///\ingroup search
40.883 @@ -1082,43 +1082,43 @@
40.884
40.885 #ifdef DOXYGEN
40.886 /// \brief Visitor class for dfs.
40.887 - ///
40.888 - /// It gives a simple interface for a functional interface for dfs
40.889 - /// traversal. The traversal on a linear data structure.
40.890 + ///
40.891 + /// It gives a simple interface for a functional interface for dfs
40.892 + /// traversal. The traversal on a linear data structure.
40.893 template <typename _Digraph>
40.894 struct DfsVisitor {
40.895 typedef _Digraph Digraph;
40.896 typedef typename Digraph::Arc Arc;
40.897 typedef typename Digraph::Node Node;
40.898 /// \brief Called when the arc reach a node.
40.899 - ///
40.900 + ///
40.901 /// It is called when the dfs find an arc which target is not
40.902 /// reached yet.
40.903 void discover(const Arc& arc) {}
40.904 /// \brief Called when the node reached first time.
40.905 - ///
40.906 + ///
40.907 /// It is Called when the node reached first time.
40.908 void reach(const Node& node) {}
40.909 /// \brief Called when we step back on an arc.
40.910 - ///
40.911 + ///
40.912 /// It is called when the dfs should step back on the arc.
40.913 void backtrack(const Arc& arc) {}
40.914 /// \brief Called when we step back from the node.
40.915 - ///
40.916 + ///
40.917 /// It is called when we step back from the node.
40.918 void leave(const Node& node) {}
40.919 - /// \brief Called when the arc examined but target of the arc
40.920 + /// \brief Called when the arc examined but target of the arc
40.921 /// already discovered.
40.922 - ///
40.923 - /// It called when the arc examined but the target of the arc
40.924 + ///
40.925 + /// It called when the arc examined but the target of the arc
40.926 /// already discovered.
40.927 void examine(const Arc& arc) {}
40.928 /// \brief Called for the source node of the dfs.
40.929 - ///
40.930 + ///
40.931 /// It is called for the source node of the dfs.
40.932 void start(const Node& node) {}
40.933 /// \brief Called when we leave the source node of the dfs.
40.934 - ///
40.935 + ///
40.936 /// It is called when we leave the source node of the dfs.
40.937 void stop(const Node& node) {}
40.938
40.939 @@ -1140,15 +1140,15 @@
40.940 template <typename _Visitor>
40.941 struct Constraints {
40.942 void constraints() {
40.943 - Arc arc;
40.944 - Node node;
40.945 - visitor.discover(arc);
40.946 - visitor.reach(node);
40.947 - visitor.backtrack(arc);
40.948 - visitor.leave(node);
40.949 - visitor.examine(arc);
40.950 - visitor.start(node);
40.951 - visitor.stop(arc);
40.952 + Arc arc;
40.953 + Node node;
40.954 + visitor.discover(arc);
40.955 + visitor.reach(node);
40.956 + visitor.backtrack(arc);
40.957 + visitor.leave(node);
40.958 + visitor.examine(arc);
40.959 + visitor.start(node);
40.960 + visitor.stop(arc);
40.961 }
40.962 _Visitor& visitor;
40.963 };
40.964 @@ -1162,11 +1162,11 @@
40.965 template<class _Digraph>
40.966 struct DfsVisitDefaultTraits {
40.967
40.968 - /// \brief The digraph type the algorithm runs on.
40.969 + /// \brief The digraph type the algorithm runs on.
40.970 typedef _Digraph Digraph;
40.971
40.972 /// \brief The type of the map that indicates which nodes are reached.
40.973 - ///
40.974 + ///
40.975 /// The type of the map that indicates which nodes are reached.
40.976 /// It must meet the \ref concepts::WriteMap "WriteMap" concept.
40.977 /// \todo named parameter to set this type, function to read and write.
40.978 @@ -1174,7 +1174,7 @@
40.979
40.980 /// \brief Instantiates a ReachedMap.
40.981 ///
40.982 - /// This function instantiates a \ref ReachedMap.
40.983 + /// This function instantiates a \ref ReachedMap.
40.984 /// \param digraph is the digraph, to which
40.985 /// we would like to define the \ref ReachedMap.
40.986 static ReachedMap *createReachedMap(const Digraph &digraph) {
40.987 @@ -1182,25 +1182,25 @@
40.988 }
40.989
40.990 };
40.991 -
40.992 +
40.993 /// %DFS Visit algorithm class.
40.994 -
40.995 +
40.996 /// \ingroup search
40.997 /// This class provides an efficient implementation of the %DFS algorithm
40.998 /// with visitor interface.
40.999 ///
40.1000 /// The %DfsVisit class provides an alternative interface to the Dfs
40.1001 /// class. It works with callback mechanism, the DfsVisit object calls
40.1002 - /// on every dfs event the \c Visitor class member functions.
40.1003 + /// on every dfs event the \c Visitor class member functions.
40.1004 ///
40.1005 /// \tparam _Digraph The digraph type the algorithm runs on. The default value is
40.1006 /// \ref ListDigraph. The value of _Digraph is not used directly by Dfs, it
40.1007 /// is only passed to \ref DfsDefaultTraits.
40.1008 - /// \tparam _Visitor The Visitor object for the algorithm. The
40.1009 + /// \tparam _Visitor The Visitor object for the algorithm. The
40.1010 /// \ref DfsVisitor "DfsVisitor<_Digraph>" is an empty Visitor which
40.1011 /// does not observe the Dfs events. If you want to observe the dfs
40.1012 /// events you should implement your own Visitor class.
40.1013 - /// \tparam _Traits Traits class to set various data types used by the
40.1014 + /// \tparam _Traits Traits class to set various data types used by the
40.1015 /// algorithm. The default traits class is
40.1016 /// \ref DfsVisitDefaultTraits "DfsVisitDefaultTraits<_Digraph>".
40.1017 /// See \ref DfsVisitDefaultTraits for the documentation of
40.1018 @@ -1211,21 +1211,21 @@
40.1019 template <typename _Digraph, typename _Visitor, typename _Traits>
40.1020 #else
40.1021 template <typename _Digraph = ListDigraph,
40.1022 - typename _Visitor = DfsVisitor<_Digraph>,
40.1023 - typename _Traits = DfsDefaultTraits<_Digraph> >
40.1024 + typename _Visitor = DfsVisitor<_Digraph>,
40.1025 + typename _Traits = DfsDefaultTraits<_Digraph> >
40.1026 #endif
40.1027 class DfsVisit {
40.1028 public:
40.1029 -
40.1030 +
40.1031 /// \brief \ref Exception for uninitialized parameters.
40.1032 ///
40.1033 /// This error represents problems in the initialization
40.1034 /// of the parameters of the algorithms.
40.1035 class UninitializedParameter : public lemon::UninitializedParameter {
40.1036 public:
40.1037 - virtual const char* what() const throw()
40.1038 + virtual const char* what() const throw()
40.1039 {
40.1040 - return "lemon::DfsVisit::UninitializedParameter";
40.1041 + return "lemon::DfsVisit::UninitializedParameter";
40.1042 }
40.1043 };
40.1044
40.1045 @@ -1262,15 +1262,15 @@
40.1046 /// Creates the maps if necessary.
40.1047 void create_maps() {
40.1048 if(!_reached) {
40.1049 - local_reached = true;
40.1050 - _reached = Traits::createReachedMap(*_digraph);
40.1051 + local_reached = true;
40.1052 + _reached = Traits::createReachedMap(*_digraph);
40.1053 }
40.1054 }
40.1055
40.1056 protected:
40.1057
40.1058 DfsVisit() {}
40.1059 -
40.1060 +
40.1061 public:
40.1062
40.1063 typedef DfsVisit Create;
40.1064 @@ -1282,22 +1282,22 @@
40.1065 struct DefReachedMapTraits : public Traits {
40.1066 typedef T ReachedMap;
40.1067 static ReachedMap *createReachedMap(const Digraph &digraph) {
40.1068 - throw UninitializedParameter();
40.1069 + throw UninitializedParameter();
40.1070 }
40.1071 };
40.1072 - /// \brief \ref named-templ-param "Named parameter" for setting
40.1073 + /// \brief \ref named-templ-param "Named parameter" for setting
40.1074 /// ReachedMap type
40.1075 ///
40.1076 /// \ref named-templ-param "Named parameter" for setting ReachedMap type
40.1077 template <class T>
40.1078 struct DefReachedMap : public DfsVisit< Digraph, Visitor,
40.1079 - DefReachedMapTraits<T> > {
40.1080 + DefReachedMapTraits<T> > {
40.1081 typedef DfsVisit< Digraph, Visitor, DefReachedMapTraits<T> > Create;
40.1082 };
40.1083 ///@}
40.1084
40.1085 - public:
40.1086 -
40.1087 + public:
40.1088 +
40.1089 /// \brief Constructor.
40.1090 ///
40.1091 /// Constructor.
40.1092 @@ -1305,10 +1305,10 @@
40.1093 /// \param digraph the digraph the algorithm will run on.
40.1094 /// \param visitor The visitor of the algorithm.
40.1095 ///
40.1096 - DfsVisit(const Digraph& digraph, Visitor& visitor)
40.1097 + DfsVisit(const Digraph& digraph, Visitor& visitor)
40.1098 : _digraph(&digraph), _visitor(&visitor),
40.1099 - _reached(0), local_reached(false) {}
40.1100 -
40.1101 + _reached(0), local_reached(false) {}
40.1102 +
40.1103 /// \brief Destructor.
40.1104 ///
40.1105 /// Destructor.
40.1106 @@ -1325,8 +1325,8 @@
40.1107 /// \return <tt> (*this) </tt>
40.1108 DfsVisit &reachedMap(ReachedMap &m) {
40.1109 if(local_reached) {
40.1110 - delete _reached;
40.1111 - local_reached=false;
40.1112 + delete _reached;
40.1113 + local_reached=false;
40.1114 }
40.1115 _reached = &m;
40.1116 return *this;
40.1117 @@ -1353,28 +1353,28 @@
40.1118 _stack.resize(countNodes(*_digraph));
40.1119 _stack_head = -1;
40.1120 for (NodeIt u(*_digraph) ; u != INVALID ; ++u) {
40.1121 - _reached->set(u, false);
40.1122 + _reached->set(u, false);
40.1123 }
40.1124 }
40.1125 -
40.1126 +
40.1127 /// \brief Adds a new source node.
40.1128 ///
40.1129 /// Adds a new source node to the set of nodes to be processed.
40.1130 void addSource(Node s) {
40.1131 if(!(*_reached)[s]) {
40.1132 - _reached->set(s,true);
40.1133 - _visitor->start(s);
40.1134 - _visitor->reach(s);
40.1135 - Arc e;
40.1136 - _digraph->firstOut(e, s);
40.1137 - if (e != INVALID) {
40.1138 - _stack[++_stack_head] = e;
40.1139 - } else {
40.1140 - _visitor->leave(s);
40.1141 - }
40.1142 - }
40.1143 + _reached->set(s,true);
40.1144 + _visitor->start(s);
40.1145 + _visitor->reach(s);
40.1146 + Arc e;
40.1147 + _digraph->firstOut(e, s);
40.1148 + if (e != INVALID) {
40.1149 + _stack[++_stack_head] = e;
40.1150 + } else {
40.1151 + _visitor->leave(s);
40.1152 + }
40.1153 + }
40.1154 }
40.1155 -
40.1156 +
40.1157 /// \brief Processes the next arc.
40.1158 ///
40.1159 /// Processes the next arc.
40.1160 @@ -1382,29 +1382,29 @@
40.1161 /// \return The processed arc.
40.1162 ///
40.1163 /// \pre The stack must not be empty!
40.1164 - Arc processNextArc() {
40.1165 + Arc processNextArc() {
40.1166 Arc e = _stack[_stack_head];
40.1167 Node m = _digraph->target(e);
40.1168 if(!(*_reached)[m]) {
40.1169 - _visitor->discover(e);
40.1170 - _visitor->reach(m);
40.1171 - _reached->set(m, true);
40.1172 - _digraph->firstOut(_stack[++_stack_head], m);
40.1173 + _visitor->discover(e);
40.1174 + _visitor->reach(m);
40.1175 + _reached->set(m, true);
40.1176 + _digraph->firstOut(_stack[++_stack_head], m);
40.1177 } else {
40.1178 - _visitor->examine(e);
40.1179 - m = _digraph->source(e);
40.1180 - _digraph->nextOut(_stack[_stack_head]);
40.1181 + _visitor->examine(e);
40.1182 + m = _digraph->source(e);
40.1183 + _digraph->nextOut(_stack[_stack_head]);
40.1184 }
40.1185 while (_stack_head>=0 && _stack[_stack_head] == INVALID) {
40.1186 - _visitor->leave(m);
40.1187 - --_stack_head;
40.1188 - if (_stack_head >= 0) {
40.1189 - _visitor->backtrack(_stack[_stack_head]);
40.1190 - m = _digraph->source(_stack[_stack_head]);
40.1191 - _digraph->nextOut(_stack[_stack_head]);
40.1192 - } else {
40.1193 - _visitor->stop(m);
40.1194 - }
40.1195 + _visitor->leave(m);
40.1196 + --_stack_head;
40.1197 + if (_stack_head >= 0) {
40.1198 + _visitor->backtrack(_stack[_stack_head]);
40.1199 + m = _digraph->source(_stack[_stack_head]);
40.1200 + _digraph->nextOut(_stack[_stack_head]);
40.1201 + } else {
40.1202 + _visitor->stop(m);
40.1203 + }
40.1204 }
40.1205 return e;
40.1206 }
40.1207 @@ -1415,7 +1415,7 @@
40.1208 ///
40.1209 /// \return The next arc to be processed or INVALID if the stack is
40.1210 /// empty.
40.1211 - Arc nextArc() {
40.1212 + Arc nextArc() {
40.1213 return _stack_head >= 0 ? _stack[_stack_head] : INVALID;
40.1214 }
40.1215
40.1216 @@ -1430,7 +1430,7 @@
40.1217 ///
40.1218 /// Returns the number of the nodes to be processed in the queue.
40.1219 int queueSize() { return _stack_head + 1; }
40.1220 -
40.1221 +
40.1222 /// \brief Executes the algorithm.
40.1223 ///
40.1224 /// Executes the algorithm.
40.1225 @@ -1440,7 +1440,7 @@
40.1226 void start() {
40.1227 while ( !emptyQueue() ) processNextArc();
40.1228 }
40.1229 -
40.1230 +
40.1231 /// \brief Executes the algorithm until \c dest is reached.
40.1232 ///
40.1233 /// Executes the algorithm until \c dest is reached.
40.1234 @@ -1448,10 +1448,10 @@
40.1235 /// \pre init() must be called and at least one node should be added
40.1236 /// with addSource() before using this function.
40.1237 void start(Node dest) {
40.1238 - while ( !emptyQueue() && _digraph->target(_stack[_stack_head]) != dest )
40.1239 - processNextArc();
40.1240 + while ( !emptyQueue() && _digraph->target(_stack[_stack_head]) != dest )
40.1241 + processNextArc();
40.1242 }
40.1243 -
40.1244 +
40.1245 /// \brief Executes the algorithm until a condition is met.
40.1246 ///
40.1247 /// Executes the algorithm until a condition is met.
40.1248 @@ -1490,7 +1490,7 @@
40.1249 }
40.1250
40.1251 /// \brief Runs %DFSVisit algorithm to visit all nodes in the digraph.
40.1252 -
40.1253 +
40.1254 /// This method runs the %DFS algorithm in order to
40.1255 /// compute the %DFS path to each node. The algorithm computes
40.1256 /// - The %DFS tree.
41.1 --- a/lemon/dijkstra.h Sun Jul 13 16:46:56 2008 +0100
41.2 +++ b/lemon/dijkstra.h Sun Jul 13 19:51:02 2008 +0100
41.3 @@ -1,6 +1,6 @@
41.4 -/* -*- C++ -*-
41.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
41.6 *
41.7 - * This file is a part of LEMON, a generic C++ optimization library
41.8 + * This file is a part of LEMON, a generic C++ optimization library.
41.9 *
41.10 * Copyright (C) 2003-2008
41.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
41.12 @@ -34,7 +34,7 @@
41.13 namespace lemon {
41.14
41.15 /// \brief Default OperationTraits for the Dijkstra algorithm class.
41.16 - ///
41.17 + ///
41.18 /// It defines all computational operations and constants which are
41.19 /// used in the Dijkstra algorithm.
41.20 template <typename Value>
41.21 @@ -54,7 +54,7 @@
41.22 };
41.23
41.24 /// \brief Widest path OperationTraits for the Dijkstra algorithm class.
41.25 - ///
41.26 + ///
41.27 /// It defines all computational operations and constants which are
41.28 /// used in the Dijkstra algorithm for widest path computation.
41.29 template <typename Value>
41.30 @@ -72,7 +72,7 @@
41.31 return left < right;
41.32 }
41.33 };
41.34 -
41.35 +
41.36 ///Default traits class of Dijkstra class.
41.37
41.38 ///Default traits class of Dijkstra class.
41.39 @@ -81,7 +81,7 @@
41.40 template<class GR, class LM>
41.41 struct DijkstraDefaultTraits
41.42 {
41.43 - ///The digraph type the algorithm runs on.
41.44 + ///The digraph type the algorithm runs on.
41.45 typedef GR Digraph;
41.46 ///The type of the map that stores the arc lengths.
41.47
41.48 @@ -103,14 +103,14 @@
41.49 typedef typename Digraph::template NodeMap<int> HeapCrossRef;
41.50 ///Instantiates a HeapCrossRef.
41.51
41.52 - ///This function instantiates a \c HeapCrossRef.
41.53 - /// \param G is the digraph, to which we would like to define the
41.54 + ///This function instantiates a \c HeapCrossRef.
41.55 + /// \param G is the digraph, to which we would like to define the
41.56 /// HeapCrossRef.
41.57 - static HeapCrossRef *createHeapCrossRef(const GR &G)
41.58 + static HeapCrossRef *createHeapCrossRef(const GR &G)
41.59 {
41.60 return new HeapCrossRef(G);
41.61 }
41.62 -
41.63 +
41.64 ///The heap type used by Dijkstra algorithm.
41.65
41.66 ///The heap type used by Dijkstra algorithm.
41.67 @@ -119,31 +119,31 @@
41.68 ///\sa Dijkstra
41.69 typedef BinHeap<typename LM::Value, HeapCrossRef, std::less<Value> > Heap;
41.70
41.71 - static Heap *createHeap(HeapCrossRef& R)
41.72 + static Heap *createHeap(HeapCrossRef& R)
41.73 {
41.74 return new Heap(R);
41.75 }
41.76
41.77 ///\brief The type of the map that stores the last
41.78 ///arcs of the shortest paths.
41.79 - ///
41.80 + ///
41.81 ///The type of the map that stores the last
41.82 ///arcs of the shortest paths.
41.83 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
41.84 ///
41.85 typedef typename Digraph::template NodeMap<typename GR::Arc> PredMap;
41.86 ///Instantiates a PredMap.
41.87 -
41.88 - ///This function instantiates a \c PredMap.
41.89 +
41.90 + ///This function instantiates a \c PredMap.
41.91 ///\param G is the digraph, to which we would like to define the PredMap.
41.92 ///\todo The digraph alone may be insufficient for the initialization
41.93 - static PredMap *createPredMap(const GR &G)
41.94 + static PredMap *createPredMap(const GR &G)
41.95 {
41.96 return new PredMap(G);
41.97 }
41.98
41.99 ///The type of the map that stores whether a nodes is processed.
41.100 -
41.101 +
41.102 ///The type of the map that stores whether a nodes is processed.
41.103 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
41.104 ///By default it is a NullMap.
41.105 @@ -152,8 +152,8 @@
41.106 ///\todo named parameter to set this type, function to read and write.
41.107 typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
41.108 ///Instantiates a ProcessedMap.
41.109 -
41.110 - ///This function instantiates a \c ProcessedMap.
41.111 +
41.112 + ///This function instantiates a \c ProcessedMap.
41.113 ///\param g is the digraph, to which
41.114 ///we would like to define the \c ProcessedMap
41.115 #ifdef DOXYGEN
41.116 @@ -165,23 +165,23 @@
41.117 return new ProcessedMap();
41.118 }
41.119 ///The type of the map that stores the dists of the nodes.
41.120 -
41.121 +
41.122 ///The type of the map that stores the dists of the nodes.
41.123 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
41.124 ///
41.125 typedef typename Digraph::template NodeMap<typename LM::Value> DistMap;
41.126 ///Instantiates a DistMap.
41.127 -
41.128 - ///This function instantiates a \ref DistMap.
41.129 +
41.130 + ///This function instantiates a \ref DistMap.
41.131 ///\param G is the digraph, to which we would like to define the \ref DistMap
41.132 static DistMap *createDistMap(const GR &G)
41.133 {
41.134 return new DistMap(G);
41.135 }
41.136 };
41.137 -
41.138 +
41.139 ///%Dijkstra algorithm class.
41.140 -
41.141 +
41.142 /// \ingroup shortest_path
41.143 ///This class provides an efficient implementation of %Dijkstra algorithm.
41.144 ///The arc lengths are passed to the algorithm using a
41.145 @@ -202,7 +202,7 @@
41.146 ///it is necessary. The default map type is \ref
41.147 ///concepts::Digraph::ArcMap "Digraph::ArcMap<int>". The value
41.148 ///of LM is not used directly by Dijkstra, it is only passed to \ref
41.149 - ///DijkstraDefaultTraits.
41.150 + ///DijkstraDefaultTraits.
41.151 ///\tparam TR Traits class to set
41.152 ///various data types used by the algorithm. The default traits
41.153 ///class is \ref DijkstraDefaultTraits
41.154 @@ -214,8 +214,8 @@
41.155 template <typename GR, typename LM, typename TR>
41.156 #else
41.157 template <typename GR=ListDigraph,
41.158 - typename LM=typename GR::template ArcMap<int>,
41.159 - typename TR=DijkstraDefaultTraits<GR,LM> >
41.160 + typename LM=typename GR::template ArcMap<int>,
41.161 + typename TR=DijkstraDefaultTraits<GR,LM> >
41.162 #endif
41.163 class Dijkstra {
41.164 public:
41.165 @@ -228,7 +228,7 @@
41.166 class UninitializedParameter : public lemon::UninitializedParameter {
41.167 public:
41.168 virtual const char* what() const throw() {
41.169 - return "lemon::Dijkstra::UninitializedParameter";
41.170 + return "lemon::Dijkstra::UninitializedParameter";
41.171 }
41.172 };
41.173
41.174 @@ -243,7 +243,7 @@
41.175 typedef typename Digraph::Arc Arc;
41.176 ///\e
41.177 typedef typename Digraph::OutArcIt OutArcIt;
41.178 -
41.179 +
41.180 ///The type of the length of the arcs.
41.181 typedef typename TR::LengthMap::Value Value;
41.182 ///The type of the map that stores the arc lengths.
41.183 @@ -288,36 +288,36 @@
41.184 bool local_heap;
41.185
41.186 ///Creates the maps if necessary.
41.187 -
41.188 +
41.189 ///\todo Better memory allocation (instead of new).
41.190 - void create_maps()
41.191 + void create_maps()
41.192 {
41.193 if(!_pred) {
41.194 - local_pred = true;
41.195 - _pred = Traits::createPredMap(*G);
41.196 + local_pred = true;
41.197 + _pred = Traits::createPredMap(*G);
41.198 }
41.199 if(!_dist) {
41.200 - local_dist = true;
41.201 - _dist = Traits::createDistMap(*G);
41.202 + local_dist = true;
41.203 + _dist = Traits::createDistMap(*G);
41.204 }
41.205 if(!_processed) {
41.206 - local_processed = true;
41.207 - _processed = Traits::createProcessedMap(*G);
41.208 + local_processed = true;
41.209 + _processed = Traits::createProcessedMap(*G);
41.210 }
41.211 if (!_heap_cross_ref) {
41.212 - local_heap_cross_ref = true;
41.213 - _heap_cross_ref = Traits::createHeapCrossRef(*G);
41.214 + local_heap_cross_ref = true;
41.215 + _heap_cross_ref = Traits::createHeapCrossRef(*G);
41.216 }
41.217 if (!_heap) {
41.218 - local_heap = true;
41.219 - _heap = Traits::createHeap(*_heap_cross_ref);
41.220 + local_heap = true;
41.221 + _heap = Traits::createHeap(*_heap_cross_ref);
41.222 }
41.223 }
41.224 -
41.225 +
41.226 public :
41.227
41.228 typedef Dijkstra Create;
41.229 -
41.230 +
41.231 ///\name Named template parameters
41.232
41.233 ///@{
41.234 @@ -327,7 +327,7 @@
41.235 typedef T PredMap;
41.236 static PredMap *createPredMap(const Digraph &)
41.237 {
41.238 - throw UninitializedParameter();
41.239 + throw UninitializedParameter();
41.240 }
41.241 };
41.242 ///\ref named-templ-param "Named parameter" for setting PredMap type
41.243 @@ -335,17 +335,17 @@
41.244 ///\ref named-templ-param "Named parameter" for setting PredMap type
41.245 ///
41.246 template <class T>
41.247 - struct DefPredMap
41.248 - : public Dijkstra< Digraph, LengthMap, DefPredMapTraits<T> > {
41.249 - typedef Dijkstra< Digraph, LengthMap, DefPredMapTraits<T> > Create;
41.250 + struct DefPredMap
41.251 + : public Dijkstra< Digraph, LengthMap, DefPredMapTraits<T> > {
41.252 + typedef Dijkstra< Digraph, LengthMap, DefPredMapTraits<T> > Create;
41.253 };
41.254 -
41.255 +
41.256 template <class T>
41.257 struct DefDistMapTraits : public Traits {
41.258 typedef T DistMap;
41.259 static DistMap *createDistMap(const Digraph &)
41.260 {
41.261 - throw UninitializedParameter();
41.262 + throw UninitializedParameter();
41.263 }
41.264 };
41.265 ///\ref named-templ-param "Named parameter" for setting DistMap type
41.266 @@ -353,17 +353,17 @@
41.267 ///\ref named-templ-param "Named parameter" for setting DistMap type
41.268 ///
41.269 template <class T>
41.270 - struct DefDistMap
41.271 - : public Dijkstra< Digraph, LengthMap, DefDistMapTraits<T> > {
41.272 + struct DefDistMap
41.273 + : public Dijkstra< Digraph, LengthMap, DefDistMapTraits<T> > {
41.274 typedef Dijkstra< Digraph, LengthMap, DefDistMapTraits<T> > Create;
41.275 };
41.276 -
41.277 +
41.278 template <class T>
41.279 struct DefProcessedMapTraits : public Traits {
41.280 typedef T ProcessedMap;
41.281 - static ProcessedMap *createProcessedMap(const Digraph &G)
41.282 + static ProcessedMap *createProcessedMap(const Digraph &G)
41.283 {
41.284 - throw UninitializedParameter();
41.285 + throw UninitializedParameter();
41.286 }
41.287 };
41.288 ///\ref named-templ-param "Named parameter" for setting ProcessedMap type
41.289 @@ -371,16 +371,16 @@
41.290 ///\ref named-templ-param "Named parameter" for setting ProcessedMap type
41.291 ///
41.292 template <class T>
41.293 - struct DefProcessedMap
41.294 - : public Dijkstra< Digraph, LengthMap, DefProcessedMapTraits<T> > {
41.295 - typedef Dijkstra< Digraph, LengthMap, DefProcessedMapTraits<T> > Create;
41.296 + struct DefProcessedMap
41.297 + : public Dijkstra< Digraph, LengthMap, DefProcessedMapTraits<T> > {
41.298 + typedef Dijkstra< Digraph, LengthMap, DefProcessedMapTraits<T> > Create;
41.299 };
41.300 -
41.301 +
41.302 struct DefDigraphProcessedMapTraits : public Traits {
41.303 typedef typename Digraph::template NodeMap<bool> ProcessedMap;
41.304 - static ProcessedMap *createProcessedMap(const Digraph &G)
41.305 + static ProcessedMap *createProcessedMap(const Digraph &G)
41.306 {
41.307 - return new ProcessedMap(G);
41.308 + return new ProcessedMap(G);
41.309 }
41.310 };
41.311 ///\brief \ref named-templ-param "Named parameter"
41.312 @@ -390,7 +390,7 @@
41.313 ///for setting the ProcessedMap type to be Digraph::NodeMap<bool>.
41.314 ///If you don't set it explicitely, it will be automatically allocated.
41.315 template <class T>
41.316 - struct DefProcessedMapToBeDefaultMap
41.317 + struct DefProcessedMapToBeDefaultMap
41.318 : public Dijkstra< Digraph, LengthMap, DefDigraphProcessedMapTraits> {
41.319 typedef Dijkstra< Digraph, LengthMap, DefDigraphProcessedMapTraits> Create;
41.320 };
41.321 @@ -400,23 +400,23 @@
41.322 typedef CR HeapCrossRef;
41.323 typedef H Heap;
41.324 static HeapCrossRef *createHeapCrossRef(const Digraph &) {
41.325 - throw UninitializedParameter();
41.326 + throw UninitializedParameter();
41.327 }
41.328 - static Heap *createHeap(HeapCrossRef &)
41.329 + static Heap *createHeap(HeapCrossRef &)
41.330 {
41.331 - throw UninitializedParameter();
41.332 + throw UninitializedParameter();
41.333 }
41.334 };
41.335 ///\brief \ref named-templ-param "Named parameter" for setting
41.336 ///heap and cross reference type
41.337 ///
41.338 - ///\ref named-templ-param "Named parameter" for setting heap and cross
41.339 + ///\ref named-templ-param "Named parameter" for setting heap and cross
41.340 ///reference type
41.341 ///
41.342 template <class H, class CR = typename Digraph::template NodeMap<int> >
41.343 struct DefHeap
41.344 - : public Dijkstra< Digraph, LengthMap, DefHeapTraits<H, CR> > {
41.345 - typedef Dijkstra< Digraph, LengthMap, DefHeapTraits<H, CR> > Create;
41.346 + : public Dijkstra< Digraph, LengthMap, DefHeapTraits<H, CR> > {
41.347 + typedef Dijkstra< Digraph, LengthMap, DefHeapTraits<H, CR> > Create;
41.348 };
41.349
41.350 template <class H, class CR>
41.351 @@ -424,24 +424,24 @@
41.352 typedef CR HeapCrossRef;
41.353 typedef H Heap;
41.354 static HeapCrossRef *createHeapCrossRef(const Digraph &G) {
41.355 - return new HeapCrossRef(G);
41.356 + return new HeapCrossRef(G);
41.357 }
41.358 - static Heap *createHeap(HeapCrossRef &R)
41.359 + static Heap *createHeap(HeapCrossRef &R)
41.360 {
41.361 - return new Heap(R);
41.362 + return new Heap(R);
41.363 }
41.364 };
41.365 ///\brief \ref named-templ-param "Named parameter" for setting
41.366 ///heap and cross reference type with automatic allocation
41.367 ///
41.368 - ///\ref named-templ-param "Named parameter" for setting heap and cross
41.369 - ///reference type. It can allocate the heap and the cross reference
41.370 - ///object if the cross reference's constructor waits for the digraph as
41.371 + ///\ref named-templ-param "Named parameter" for setting heap and cross
41.372 + ///reference type. It can allocate the heap and the cross reference
41.373 + ///object if the cross reference's constructor waits for the digraph as
41.374 ///parameter and the heap's constructor waits for the cross reference.
41.375 template <class H, class CR = typename Digraph::template NodeMap<int> >
41.376 struct DefStandardHeap
41.377 - : public Dijkstra< Digraph, LengthMap, DefStandardHeapTraits<H, CR> > {
41.378 - typedef Dijkstra< Digraph, LengthMap, DefStandardHeapTraits<H, CR> >
41.379 + : public Dijkstra< Digraph, LengthMap, DefStandardHeapTraits<H, CR> > {
41.380 + typedef Dijkstra< Digraph, LengthMap, DefStandardHeapTraits<H, CR> >
41.381 Create;
41.382 };
41.383
41.384 @@ -449,8 +449,8 @@
41.385 struct DefOperationTraitsTraits : public Traits {
41.386 typedef T OperationTraits;
41.387 };
41.388 -
41.389 - /// \brief \ref named-templ-param "Named parameter" for setting
41.390 +
41.391 + /// \brief \ref named-templ-param "Named parameter" for setting
41.392 /// OperationTraits type
41.393 ///
41.394 /// \ref named-templ-param "Named parameter" for setting OperationTraits
41.395 @@ -461,7 +461,7 @@
41.396 typedef Dijkstra<Digraph, LengthMap, DefOperationTraitsTraits<T> >
41.397 Create;
41.398 };
41.399 -
41.400 +
41.401 ///@}
41.402
41.403
41.404 @@ -469,10 +469,10 @@
41.405
41.406 Dijkstra() {}
41.407
41.408 - public:
41.409 -
41.410 + public:
41.411 +
41.412 ///Constructor.
41.413 -
41.414 +
41.415 ///\param _G the digraph the algorithm will run on.
41.416 ///\param _length the length map used by the algorithm.
41.417 Dijkstra(const Digraph& _G, const LengthMap& _length) :
41.418 @@ -483,9 +483,9 @@
41.419 _heap_cross_ref(NULL), local_heap_cross_ref(false),
41.420 _heap(NULL), local_heap(false)
41.421 { }
41.422 -
41.423 +
41.424 ///Destructor.
41.425 - ~Dijkstra()
41.426 + ~Dijkstra()
41.427 {
41.428 if(local_pred) delete _pred;
41.429 if(local_dist) delete _dist;
41.430 @@ -498,7 +498,7 @@
41.431
41.432 ///Sets the length map.
41.433 ///\return <tt> (*this) </tt>
41.434 - Dijkstra &lengthMap(const LengthMap &m)
41.435 + Dijkstra &lengthMap(const LengthMap &m)
41.436 {
41.437 length = &m;
41.438 return *this;
41.439 @@ -511,11 +511,11 @@
41.440 ///it will allocate one. The destuctor deallocates this
41.441 ///automatically allocated map, of course.
41.442 ///\return <tt> (*this) </tt>
41.443 - Dijkstra &predMap(PredMap &m)
41.444 + Dijkstra &predMap(PredMap &m)
41.445 {
41.446 if(local_pred) {
41.447 - delete _pred;
41.448 - local_pred=false;
41.449 + delete _pred;
41.450 + local_pred=false;
41.451 }
41.452 _pred = &m;
41.453 return *this;
41.454 @@ -528,11 +528,11 @@
41.455 ///it will allocate one. The destuctor deallocates this
41.456 ///automatically allocated map, of course.
41.457 ///\return <tt> (*this) </tt>
41.458 - Dijkstra &distMap(DistMap &m)
41.459 + Dijkstra &distMap(DistMap &m)
41.460 {
41.461 if(local_dist) {
41.462 - delete _dist;
41.463 - local_dist=false;
41.464 + delete _dist;
41.465 + local_dist=false;
41.466 }
41.467 _dist = &m;
41.468 return *this;
41.469 @@ -548,13 +548,13 @@
41.470 Dijkstra &heap(Heap& hp, HeapCrossRef &cr)
41.471 {
41.472 if(local_heap_cross_ref) {
41.473 - delete _heap_cross_ref;
41.474 - local_heap_cross_ref=false;
41.475 + delete _heap_cross_ref;
41.476 + local_heap_cross_ref=false;
41.477 }
41.478 _heap_cross_ref = &cr;
41.479 if(local_heap) {
41.480 - delete _heap;
41.481 - local_heap=false;
41.482 + delete _heap;
41.483 + local_heap=false;
41.484 }
41.485 _heap = &hp;
41.486 return *this;
41.487 @@ -592,12 +592,12 @@
41.488 create_maps();
41.489 _heap->clear();
41.490 for ( NodeIt u(*G) ; u!=INVALID ; ++u ) {
41.491 - _pred->set(u,INVALID);
41.492 - _processed->set(u,false);
41.493 - _heap_cross_ref->set(u,Heap::PRE_HEAP);
41.494 + _pred->set(u,INVALID);
41.495 + _processed->set(u,false);
41.496 + _heap_cross_ref->set(u,Heap::PRE_HEAP);
41.497 }
41.498 }
41.499 -
41.500 +
41.501 ///Adds a new source node.
41.502
41.503 ///Adds a new source node to the priority heap.
41.504 @@ -610,13 +610,13 @@
41.505 void addSource(Node s,Value dst=OperationTraits::zero())
41.506 {
41.507 if(_heap->state(s) != Heap::IN_HEAP) {
41.508 - _heap->push(s,dst);
41.509 + _heap->push(s,dst);
41.510 } else if(OperationTraits::less((*_heap)[s], dst)) {
41.511 - _heap->set(s,dst);
41.512 - _pred->set(s,INVALID);
41.513 + _heap->set(s,dst);
41.514 + _pred->set(s,INVALID);
41.515 }
41.516 }
41.517 -
41.518 +
41.519 ///Processes the next node in the priority heap
41.520
41.521 ///Processes the next node in the priority heap.
41.522 @@ -626,45 +626,45 @@
41.523 ///\warning The priority heap must not be empty!
41.524 Node processNextNode()
41.525 {
41.526 - Node v=_heap->top();
41.527 + Node v=_heap->top();
41.528 Value oldvalue=_heap->prio();
41.529 _heap->pop();
41.530 finalizeNodeData(v,oldvalue);
41.531 -
41.532 +
41.533 for(OutArcIt e(*G,v); e!=INVALID; ++e) {
41.534 - Node w=G->target(e);
41.535 - switch(_heap->state(w)) {
41.536 - case Heap::PRE_HEAP:
41.537 - _heap->push(w,OperationTraits::plus(oldvalue, (*length)[e]));
41.538 - _pred->set(w,e);
41.539 - break;
41.540 - case Heap::IN_HEAP:
41.541 - {
41.542 - Value newvalue = OperationTraits::plus(oldvalue, (*length)[e]);
41.543 - if ( OperationTraits::less(newvalue, (*_heap)[w]) ) {
41.544 - _heap->decrease(w, newvalue);
41.545 - _pred->set(w,e);
41.546 - }
41.547 - }
41.548 - break;
41.549 - case Heap::POST_HEAP:
41.550 - break;
41.551 - }
41.552 + Node w=G->target(e);
41.553 + switch(_heap->state(w)) {
41.554 + case Heap::PRE_HEAP:
41.555 + _heap->push(w,OperationTraits::plus(oldvalue, (*length)[e]));
41.556 + _pred->set(w,e);
41.557 + break;
41.558 + case Heap::IN_HEAP:
41.559 + {
41.560 + Value newvalue = OperationTraits::plus(oldvalue, (*length)[e]);
41.561 + if ( OperationTraits::less(newvalue, (*_heap)[w]) ) {
41.562 + _heap->decrease(w, newvalue);
41.563 + _pred->set(w,e);
41.564 + }
41.565 + }
41.566 + break;
41.567 + case Heap::POST_HEAP:
41.568 + break;
41.569 + }
41.570 }
41.571 return v;
41.572 }
41.573
41.574 ///Next node to be processed.
41.575 -
41.576 +
41.577 ///Next node to be processed.
41.578 ///
41.579 ///\return The next node to be processed or INVALID if the priority heap
41.580 /// is empty.
41.581 Node nextNode()
41.582 - {
41.583 + {
41.584 return !_heap->empty()?_heap->top():INVALID;
41.585 }
41.586 -
41.587 +
41.588 ///\brief Returns \c false if there are nodes
41.589 ///to be processed in the priority heap
41.590 ///
41.591 @@ -676,7 +676,7 @@
41.592 ///Returns the number of the nodes to be processed in the priority heap
41.593 ///
41.594 int queueSize() { return _heap->size(); }
41.595 -
41.596 +
41.597 ///Executes the algorithm.
41.598
41.599 ///Executes the algorithm.
41.600 @@ -695,7 +695,7 @@
41.601 {
41.602 while ( !_heap->empty() ) processNextNode();
41.603 }
41.604 -
41.605 +
41.606 ///Executes the algorithm until \c dest is reached.
41.607
41.608 ///Executes the algorithm until \c dest is reached.
41.609 @@ -715,7 +715,7 @@
41.610 while ( !_heap->empty() && _heap->top()!=dest ) processNextNode();
41.611 if ( !_heap->empty() ) finalizeNodeData(_heap->top(),_heap->prio());
41.612 }
41.613 -
41.614 +
41.615 ///Executes the algorithm until a condition is met.
41.616
41.617 ///Executes the algorithm until a condition is met.
41.618 @@ -736,9 +736,9 @@
41.619 finalizeNodeData(_heap->top(),_heap->prio());
41.620 return _heap->top();
41.621 }
41.622 -
41.623 +
41.624 ///Runs %Dijkstra algorithm from node \c s.
41.625 -
41.626 +
41.627 ///This method runs the %Dijkstra algorithm from a root node \c s
41.628 ///in order to
41.629 ///compute the
41.630 @@ -757,9 +757,9 @@
41.631 addSource(s);
41.632 start();
41.633 }
41.634 -
41.635 +
41.636 ///Finds the shortest path between \c s and \c t.
41.637 -
41.638 +
41.639 ///Finds the shortest path between \c s and \c t.
41.640 ///
41.641 ///\return The length of the shortest s---t path if there exists one,
41.642 @@ -777,7 +777,7 @@
41.643 start(t);
41.644 return (*_pred)[t]==INVALID?OperationTraits::zero():(*_dist)[t];
41.645 }
41.646 -
41.647 +
41.648 ///@}
41.649
41.650 ///\name Query Functions
41.651 @@ -785,14 +785,14 @@
41.652 ///functions.\n
41.653 ///Before the use of these functions,
41.654 ///either run() or start() must be called.
41.655 -
41.656 +
41.657 ///@{
41.658
41.659 ///Gives back the shortest path.
41.660 -
41.661 +
41.662 ///Gives back the shortest path.
41.663 ///\pre The \c t should be reachable from the source.
41.664 - Path path(Node t)
41.665 + Path path(Node t)
41.666 {
41.667 return Path(*G, *_pred, t);
41.668 }
41.669 @@ -832,21 +832,21 @@
41.670 ///tree used in \ref predArc(). \pre \ref run() must be called before
41.671 ///using this function.
41.672 Node predNode(Node v) const { return (*_pred)[v]==INVALID ? INVALID:
41.673 - G->source((*_pred)[v]); }
41.674 -
41.675 + G->source((*_pred)[v]); }
41.676 +
41.677 ///Returns a reference to the NodeMap of distances.
41.678
41.679 ///Returns a reference to the NodeMap of distances. \pre \ref run() must
41.680 ///be called before using this function.
41.681 const DistMap &distMap() const { return *_dist;}
41.682 -
41.683 +
41.684 ///Returns a reference to the shortest path tree map.
41.685
41.686 ///Returns a reference to the NodeMap of the arcs of the
41.687 ///shortest path tree.
41.688 ///\pre \ref run() must be called before using this function.
41.689 const PredMap &predMap() const { return *_pred;}
41.690 -
41.691 +
41.692 ///Checks if a node is reachable from the root.
41.693
41.694 ///Returns \c true if \c v is reachable from the root.
41.695 @@ -862,14 +862,14 @@
41.696 ///\pre \ref run() must be called before using this function.
41.697 ///
41.698 bool processed(Node v) { return (*_heap_cross_ref)[v] == Heap::POST_HEAP; }
41.699 -
41.700 +
41.701 ///@}
41.702 };
41.703
41.704
41.705
41.706
41.707 -
41.708 +
41.709 ///Default traits class of Dijkstra function.
41.710
41.711 ///Default traits class of Dijkstra function.
41.712 @@ -878,7 +878,7 @@
41.713 template<class GR, class LM>
41.714 struct DijkstraWizardDefaultTraits
41.715 {
41.716 - ///The digraph type the algorithm runs on.
41.717 + ///The digraph type the algorithm runs on.
41.718 typedef GR Digraph;
41.719 ///The type of the map that stores the arc lengths.
41.720
41.721 @@ -901,15 +901,15 @@
41.722 typedef typename Digraph::template NodeMap<int> HeapCrossRef;
41.723 ///Instantiates a HeapCrossRef.
41.724
41.725 - ///This function instantiates a \ref HeapCrossRef.
41.726 - /// \param G is the digraph, to which we would like to define the
41.727 + ///This function instantiates a \ref HeapCrossRef.
41.728 + /// \param G is the digraph, to which we would like to define the
41.729 /// HeapCrossRef.
41.730 /// \todo The digraph alone may be insufficient for the initialization
41.731 - static HeapCrossRef *createHeapCrossRef(const GR &G)
41.732 + static HeapCrossRef *createHeapCrossRef(const GR &G)
41.733 {
41.734 return new HeapCrossRef(G);
41.735 }
41.736 -
41.737 +
41.738 ///The heap type used by Dijkstra algorithm.
41.739
41.740 ///The heap type used by Dijkstra algorithm.
41.741 @@ -917,36 +917,36 @@
41.742 ///\sa BinHeap
41.743 ///\sa Dijkstra
41.744 typedef BinHeap<typename LM::Value, typename GR::template NodeMap<int>,
41.745 - std::less<Value> > Heap;
41.746 + std::less<Value> > Heap;
41.747
41.748 - static Heap *createHeap(HeapCrossRef& R)
41.749 + static Heap *createHeap(HeapCrossRef& R)
41.750 {
41.751 return new Heap(R);
41.752 }
41.753
41.754 ///\brief The type of the map that stores the last
41.755 ///arcs of the shortest paths.
41.756 - ///
41.757 + ///
41.758 ///The type of the map that stores the last
41.759 ///arcs of the shortest paths.
41.760 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
41.761 ///
41.762 typedef NullMap <typename GR::Node,typename GR::Arc> PredMap;
41.763 ///Instantiates a PredMap.
41.764 -
41.765 - ///This function instantiates a \ref PredMap.
41.766 +
41.767 + ///This function instantiates a \ref PredMap.
41.768 ///\param g is the digraph, to which we would like to define the PredMap.
41.769 ///\todo The digraph alone may be insufficient for the initialization
41.770 #ifdef DOXYGEN
41.771 - static PredMap *createPredMap(const GR &g)
41.772 + static PredMap *createPredMap(const GR &g)
41.773 #else
41.774 - static PredMap *createPredMap(const GR &)
41.775 + static PredMap *createPredMap(const GR &)
41.776 #endif
41.777 {
41.778 return new PredMap();
41.779 }
41.780 ///The type of the map that stores whether a nodes is processed.
41.781 -
41.782 +
41.783 ///The type of the map that stores whether a nodes is processed.
41.784 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
41.785 ///By default it is a NullMap.
41.786 @@ -955,8 +955,8 @@
41.787 ///\todo named parameter to set this type, function to read and write.
41.788 typedef NullMap<typename Digraph::Node,bool> ProcessedMap;
41.789 ///Instantiates a ProcessedMap.
41.790 -
41.791 - ///This function instantiates a \ref ProcessedMap.
41.792 +
41.793 + ///This function instantiates a \ref ProcessedMap.
41.794 ///\param g is the digraph, to which
41.795 ///we would like to define the \ref ProcessedMap
41.796 #ifdef DOXYGEN
41.797 @@ -968,14 +968,14 @@
41.798 return new ProcessedMap();
41.799 }
41.800 ///The type of the map that stores the dists of the nodes.
41.801 -
41.802 +
41.803 ///The type of the map that stores the dists of the nodes.
41.804 ///It must meet the \ref concepts::WriteMap "WriteMap" concept.
41.805 ///
41.806 typedef NullMap<typename Digraph::Node,typename LM::Value> DistMap;
41.807 ///Instantiates a DistMap.
41.808 -
41.809 - ///This function instantiates a \ref DistMap.
41.810 +
41.811 + ///This function instantiates a \ref DistMap.
41.812 ///\param g is the digraph, to which we would like to define the \ref DistMap
41.813 #ifdef DOXYGEN
41.814 static DistMap *createDistMap(const GR &g)
41.815 @@ -986,7 +986,7 @@
41.816 return new DistMap();
41.817 }
41.818 };
41.819 -
41.820 +
41.821 /// Default traits used by \ref DijkstraWizard
41.822
41.823 /// To make it easier to use Dijkstra algorithm
41.824 @@ -1018,14 +1018,14 @@
41.825
41.826 public:
41.827 /// Constructor.
41.828 -
41.829 +
41.830 /// This constructor does not require parameters, therefore it initiates
41.831 /// all of the attributes to default values (0, INVALID).
41.832 DijkstraWizardBase() : _g(0), _length(0), _pred(0),
41.833 - _dist(0), _source(INVALID) {}
41.834 + _dist(0), _source(INVALID) {}
41.835
41.836 /// Constructor.
41.837 -
41.838 +
41.839 /// This constructor requires some parameters,
41.840 /// listed in the parameters list.
41.841 /// Others are initiated to 0.
41.842 @@ -1033,12 +1033,12 @@
41.843 /// \param l is the initial value of \ref _length
41.844 /// \param s is the initial value of \ref _source
41.845 DijkstraWizardBase(const GR &g,const LM &l, Node s=INVALID) :
41.846 - _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
41.847 - _length(reinterpret_cast<void*>(const_cast<LM*>(&l))),
41.848 + _g(reinterpret_cast<void*>(const_cast<GR*>(&g))),
41.849 + _length(reinterpret_cast<void*>(const_cast<LM*>(&l))),
41.850 _pred(0), _dist(0), _source(s) {}
41.851
41.852 };
41.853 -
41.854 +
41.855 /// A class to make the usage of Dijkstra algorithm easier
41.856
41.857 /// This class is created to make it easier to use Dijkstra algorithm.
41.858 @@ -1056,7 +1056,7 @@
41.859 /// return the needed class.
41.860 ///
41.861 /// It does not have own \ref run method. When its \ref run method is called
41.862 - /// it initiates a plain \ref Dijkstra class, and calls the \ref
41.863 + /// it initiates a plain \ref Dijkstra class, and calls the \ref
41.864 /// Dijkstra::run method of it.
41.865 template<class TR>
41.866 class DijkstraWizard : public TR
41.867 @@ -1073,7 +1073,7 @@
41.868 typedef typename Digraph::Arc Arc;
41.869 //\e
41.870 typedef typename Digraph::OutArcIt OutArcIt;
41.871 -
41.872 +
41.873 ///The type of the map that stores the arc lengths.
41.874 typedef typename TR::LengthMap LengthMap;
41.875 ///The type of the length of the arcs.
41.876 @@ -1102,14 +1102,14 @@
41.877 ~DijkstraWizard() {}
41.878
41.879 ///Runs Dijkstra algorithm from a given node.
41.880 -
41.881 +
41.882 ///Runs Dijkstra algorithm from a given node.
41.883 ///The node can be given by the \ref source function.
41.884 void run()
41.885 {
41.886 if(Base::_source==INVALID) throw UninitializedParameter();
41.887 - Dijkstra<Digraph,LengthMap,TR>
41.888 - dij(*reinterpret_cast<const Digraph*>(Base::_g),
41.889 + Dijkstra<Digraph,LengthMap,TR>
41.890 + dij(*reinterpret_cast<const Digraph*>(Base::_g),
41.891 *reinterpret_cast<const LengthMap*>(Base::_length));
41.892 if(Base::_pred) dij.predMap(*reinterpret_cast<PredMap*>(Base::_pred));
41.893 if(Base::_dist) dij.distMap(*reinterpret_cast<DistMap*>(Base::_dist));
41.894 @@ -1132,7 +1132,7 @@
41.895 static PredMap *createPredMap(const Digraph &) { return 0; };
41.896 DefPredMapBase(const TR &b) : TR(b) {}
41.897 };
41.898 -
41.899 +
41.900 ///\brief \ref named-templ-param "Named parameter"
41.901 ///function for setting PredMap type
41.902 ///
41.903 @@ -1140,19 +1140,19 @@
41.904 ///function for setting PredMap type
41.905 ///
41.906 template<class T>
41.907 - DijkstraWizard<DefPredMapBase<T> > predMap(const T &t)
41.908 + DijkstraWizard<DefPredMapBase<T> > predMap(const T &t)
41.909 {
41.910 Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t));
41.911 return DijkstraWizard<DefPredMapBase<T> >(*this);
41.912 }
41.913 -
41.914 +
41.915 template<class T>
41.916 struct DefDistMapBase : public Base {
41.917 typedef T DistMap;
41.918 static DistMap *createDistMap(const Digraph &) { return 0; };
41.919 DefDistMapBase(const TR &b) : TR(b) {}
41.920 };
41.921 -
41.922 +
41.923 ///\brief \ref named-templ-param "Named parameter"
41.924 ///function for setting DistMap type
41.925 ///
41.926 @@ -1160,24 +1160,24 @@
41.927 ///function for setting DistMap type
41.928 ///
41.929 template<class T>
41.930 - DijkstraWizard<DefDistMapBase<T> > distMap(const T &t)
41.931 + DijkstraWizard<DefDistMapBase<T> > distMap(const T &t)
41.932 {
41.933 Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t));
41.934 return DijkstraWizard<DefDistMapBase<T> >(*this);
41.935 }
41.936 -
41.937 +
41.938 /// Sets the source node, from which the Dijkstra algorithm runs.
41.939
41.940 /// Sets the source node, from which the Dijkstra algorithm runs.
41.941 /// \param s is the source node.
41.942 - DijkstraWizard<TR> &source(Node s)
41.943 + DijkstraWizard<TR> &source(Node s)
41.944 {
41.945 Base::_source=s;
41.946 return *this;
41.947 }
41.948 -
41.949 +
41.950 };
41.951 -
41.952 +
41.953 ///Function type interface for Dijkstra algorithm.
41.954
41.955 /// \ingroup shortest_path
42.1 --- a/lemon/dim2.h Sun Jul 13 16:46:56 2008 +0100
42.2 +++ b/lemon/dim2.h Sun Jul 13 19:51:02 2008 +0100
42.3 @@ -1,6 +1,6 @@
42.4 -/* -*- C++ -*-
42.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
42.6 *
42.7 - * This file is a part of LEMON, a generic C++ optimization library
42.8 + * This file is a part of LEMON, a generic C++ optimization library.
42.9 *
42.10 * Copyright (C) 2003-2008
42.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
42.12 @@ -24,7 +24,7 @@
42.13
42.14 ///\ingroup misc
42.15 ///\file
42.16 -///\brief A simple two dimensional vector and a bounding box implementation
42.17 +///\brief A simple two dimensional vector and a bounding box implementation
42.18 ///
42.19 /// The class \ref lemon::dim2::Point "dim2::Point" implements
42.20 /// a two dimensional vector with the usual operations.
42.21 @@ -59,8 +59,8 @@
42.22 ///First coordinate
42.23 T x;
42.24 ///Second coordinate
42.25 - T y;
42.26 -
42.27 + T y;
42.28 +
42.29 ///Default constructor
42.30 Point() {}
42.31
42.32 @@ -70,7 +70,7 @@
42.33 ///Returns the dimension of the vector (i.e. returns 2).
42.34
42.35 ///The dimension of the vector.
42.36 - ///This function always returns 2.
42.37 + ///This function always returns 2.
42.38 int size() const { return 2; }
42.39
42.40 ///Subscripting operator
42.41 @@ -92,14 +92,14 @@
42.42 T normSquare() const {
42.43 return x*x+y*y;
42.44 }
42.45 -
42.46 +
42.47 ///Increment the left hand side by \c u
42.48 Point<T>& operator +=(const Point<T>& u) {
42.49 x += u.x;
42.50 y += u.y;
42.51 return *this;
42.52 }
42.53 -
42.54 +
42.55 ///Decrement the left hand side by \c u
42.56 Point<T>& operator -=(const Point<T>& u) {
42.57 x -= u.x;
42.58 @@ -120,12 +120,12 @@
42.59 y /= u;
42.60 return *this;
42.61 }
42.62 -
42.63 +
42.64 ///Return the scalar product of two vectors
42.65 T operator *(const Point<T>& u) const {
42.66 return x*u.x+y*u.y;
42.67 }
42.68 -
42.69 +
42.70 ///Return the sum of two vectors
42.71 Point<T> operator+(const Point<T> &u) const {
42.72 Point<T> b=*this;
42.73 @@ -169,7 +169,7 @@
42.74
42.75 };
42.76
42.77 - ///Return a Point
42.78 + ///Return a Point
42.79
42.80 ///Return a Point.
42.81 ///\relates Point
42.82 @@ -259,7 +259,7 @@
42.83 return Point<T>(z.y,-z.x);
42.84 }
42.85
42.86 -
42.87 +
42.88
42.89 /// A class to calculate or store the bounding box of plainvectors.
42.90
42.91 @@ -270,15 +270,15 @@
42.92 Point<T> bottom_left, top_right;
42.93 bool _empty;
42.94 public:
42.95 -
42.96 +
42.97 ///Default constructor: creates an empty bounding box
42.98 BoundingBox() { _empty = true; }
42.99
42.100 ///Construct an instance from one point
42.101 BoundingBox(Point<T> a) { bottom_left=top_right=a; _empty = false; }
42.102 -
42.103 +
42.104 ///Construct an instance from two points
42.105 -
42.106 +
42.107 ///Construct an instance from two points.
42.108 ///\param a The bottom left corner.
42.109 ///\param b The top right corner.
42.110 @@ -286,11 +286,11 @@
42.111 ///than those of the top right one.
42.112 BoundingBox(Point<T> a,Point<T> b)
42.113 {
42.114 - bottom_left=a;
42.115 - top_right=b;
42.116 - _empty = false;
42.117 + bottom_left=a;
42.118 + top_right=b;
42.119 + _empty = false;
42.120 }
42.121 -
42.122 +
42.123 ///Construct an instance from four numbers
42.124
42.125 ///Construct an instance from four numbers.
42.126 @@ -299,25 +299,25 @@
42.127 ///\param r The right side of the box.
42.128 ///\param t The top of the box.
42.129 ///\warning The left side must be no more than the right side and
42.130 - ///bottom must be no more than the top.
42.131 + ///bottom must be no more than the top.
42.132 BoundingBox(T l,T b,T r,T t)
42.133 {
42.134 - bottom_left=Point<T>(l,b);
42.135 - top_right=Point<T>(r,t);
42.136 - _empty = false;
42.137 + bottom_left=Point<T>(l,b);
42.138 + top_right=Point<T>(r,t);
42.139 + _empty = false;
42.140 }
42.141 -
42.142 +
42.143 ///Return \c true if the bounding box is empty.
42.144 -
42.145 +
42.146 ///Return \c true if the bounding box is empty (i.e. return \c false
42.147 ///if at least one point was added to the box or the coordinates of
42.148 ///the box were set).
42.149 ///
42.150 - ///The coordinates of an empty bounding box are not defined.
42.151 + ///The coordinates of an empty bounding box are not defined.
42.152 bool empty() const {
42.153 return _empty;
42.154 }
42.155 -
42.156 +
42.157 ///Make the BoundingBox empty
42.158 void clear() {
42.159 _empty=1;
42.160 @@ -336,7 +336,7 @@
42.161 ///Set the bottom left corner of the box.
42.162 ///It should only be used for non-empty box.
42.163 void bottomLeft(Point<T> p) {
42.164 - bottom_left = p;
42.165 + bottom_left = p;
42.166 }
42.167
42.168 ///Give back the top right corner of the box
42.169 @@ -352,7 +352,7 @@
42.170 ///Set the top right corner of the box.
42.171 ///It should only be used for non-empty box.
42.172 void topRight(Point<T> p) {
42.173 - top_right = p;
42.174 + top_right = p;
42.175 }
42.176
42.177 ///Give back the bottom right corner of the box
42.178 @@ -368,10 +368,10 @@
42.179 ///Set the bottom right corner of the box.
42.180 ///It should only be used for non-empty box.
42.181 void bottomRight(Point<T> p) {
42.182 - top_right.x = p.x;
42.183 - bottom_left.y = p.y;
42.184 + top_right.x = p.x;
42.185 + bottom_left.y = p.y;
42.186 }
42.187 -
42.188 +
42.189 ///Give back the top left corner of the box
42.190
42.191 ///Give back the top left corner of the box.
42.192 @@ -385,8 +385,8 @@
42.193 ///Set the top left corner of the box.
42.194 ///It should only be used for non-empty box.
42.195 void topLeft(Point<T> p) {
42.196 - top_right.y = p.y;
42.197 - bottom_left.x = p.x;
42.198 + top_right.y = p.y;
42.199 + bottom_left.x = p.x;
42.200 }
42.201
42.202 ///Give back the bottom of the box
42.203 @@ -402,7 +402,7 @@
42.204 ///Set the bottom of the box.
42.205 ///It should only be used for non-empty box.
42.206 void bottom(T t) {
42.207 - bottom_left.y = t;
42.208 + bottom_left.y = t;
42.209 }
42.210
42.211 ///Give back the top of the box
42.212 @@ -418,7 +418,7 @@
42.213 ///Set the top of the box.
42.214 ///It should only be used for non-empty box.
42.215 void top(T t) {
42.216 - top_right.y = t;
42.217 + top_right.y = t;
42.218 }
42.219
42.220 ///Give back the left side of the box
42.221 @@ -428,13 +428,13 @@
42.222 T left() const {
42.223 return bottom_left.x;
42.224 }
42.225 -
42.226 +
42.227 ///Set the left side of the box
42.228
42.229 ///Set the left side of the box.
42.230 ///It should only be used for non-empty box.
42.231 void left(T t) {
42.232 - bottom_left.x = t;
42.233 + bottom_left.x = t;
42.234 }
42.235
42.236 /// Give back the right side of the box
42.237 @@ -450,7 +450,7 @@
42.238 ///Set the right side of the box.
42.239 ///It should only be used for non-empty box.
42.240 void right(T t) {
42.241 - top_right.x = t;
42.242 + top_right.x = t;
42.243 }
42.244
42.245 ///Give back the height of the box
42.246 @@ -478,7 +478,7 @@
42.247 (u.y-bottom_left.y)*(top_right.y-u.y) >= 0 );
42.248 }
42.249 }
42.250 -
42.251 +
42.252 ///Increments a bounding box with a point
42.253
42.254 ///Increments a bounding box with a point.
42.255 @@ -496,19 +496,19 @@
42.256 }
42.257 return *this;
42.258 }
42.259 -
42.260 +
42.261 ///Increments a bounding box to contain another bounding box
42.262 -
42.263 +
42.264 ///Increments a bounding box to contain another bounding box.
42.265 ///
42.266 BoundingBox& add(const BoundingBox &u){
42.267 if ( !u.empty() ){
42.268 this->add(u.bottomLeft());
42.269 - this->add(u.topRight());
42.270 + this->add(u.topRight());
42.271 }
42.272 return *this;
42.273 }
42.274 -
42.275 +
42.276 ///Intersection of two bounding boxes
42.277
42.278 ///Intersection of two bounding boxes.
42.279 @@ -516,15 +516,15 @@
42.280 BoundingBox operator&(const BoundingBox& u) const {
42.281 BoundingBox b;
42.282 if (this->_empty || u._empty) {
42.283 - b._empty = true;
42.284 - } else {
42.285 - b.bottom_left.x = std::max(this->bottom_left.x,u.bottom_left.x);
42.286 - b.bottom_left.y = std::max(this->bottom_left.y,u.bottom_left.y);
42.287 - b.top_right.x = std::min(this->top_right.x,u.top_right.x);
42.288 - b.top_right.y = std::min(this->top_right.y,u.top_right.y);
42.289 - b._empty = b.bottom_left.x > b.top_right.x ||
42.290 - b.bottom_left.y > b.top_right.y;
42.291 - }
42.292 + b._empty = true;
42.293 + } else {
42.294 + b.bottom_left.x = std::max(this->bottom_left.x,u.bottom_left.x);
42.295 + b.bottom_left.y = std::max(this->bottom_left.y,u.bottom_left.y);
42.296 + b.top_right.x = std::min(this->top_right.x,u.top_right.x);
42.297 + b.top_right.y = std::min(this->top_right.y,u.top_right.y);
42.298 + b._empty = b.bottom_left.x > b.top_right.x ||
42.299 + b.bottom_left.y > b.top_right.y;
42.300 + }
42.301 return b;
42.302 }
42.303
42.304 @@ -537,7 +537,7 @@
42.305 ///Map of x-coordinates of a \ref Point "Point"-map.
42.306 ///
42.307 template<class M>
42.308 - class XMap
42.309 + class XMap
42.310 {
42.311 M& _map;
42.312 public:
42.313 @@ -549,21 +549,21 @@
42.314 Value operator[](Key k) const {return _map[k].x;}
42.315 void set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));}
42.316 };
42.317 -
42.318 +
42.319 ///Returns an \ref XMap class
42.320
42.321 ///This function just returns an \ref XMap class.
42.322 ///
42.323 ///\ingroup maps
42.324 ///\relates XMap
42.325 - template<class M>
42.326 - inline XMap<M> xMap(M &m)
42.327 + template<class M>
42.328 + inline XMap<M> xMap(M &m)
42.329 {
42.330 return XMap<M>(m);
42.331 }
42.332
42.333 - template<class M>
42.334 - inline XMap<M> xMap(const M &m)
42.335 + template<class M>
42.336 + inline XMap<M> xMap(const M &m)
42.337 {
42.338 return XMap<M>(m);
42.339 }
42.340 @@ -574,7 +574,7 @@
42.341 ///Constant (read only) version of \ref XMap
42.342 ///
42.343 template<class M>
42.344 - class ConstXMap
42.345 + class ConstXMap
42.346 {
42.347 const M& _map;
42.348 public:
42.349 @@ -585,26 +585,26 @@
42.350 ConstXMap(const M &map) : _map(map) {}
42.351 Value operator[](Key k) const {return _map[k].x;}
42.352 };
42.353 -
42.354 +
42.355 ///Returns a \ref ConstXMap class
42.356
42.357 ///This function just returns a \ref ConstXMap class.
42.358 ///
42.359 ///\ingroup maps
42.360 ///\relates ConstXMap
42.361 - template<class M>
42.362 - inline ConstXMap<M> xMap(const M &m)
42.363 + template<class M>
42.364 + inline ConstXMap<M> xMap(const M &m)
42.365 {
42.366 return ConstXMap<M>(m);
42.367 }
42.368
42.369 ///Map of y-coordinates of a \ref Point "Point"-map
42.370 -
42.371 +
42.372 ///\ingroup maps
42.373 ///Map of y-coordinates of a \ref Point "Point"-map.
42.374 ///
42.375 template<class M>
42.376 - class YMap
42.377 + class YMap
42.378 {
42.379 M& _map;
42.380 public:
42.381 @@ -623,14 +623,14 @@
42.382 ///
42.383 ///\ingroup maps
42.384 ///\relates YMap
42.385 - template<class M>
42.386 - inline YMap<M> yMap(M &m)
42.387 + template<class M>
42.388 + inline YMap<M> yMap(M &m)
42.389 {
42.390 return YMap<M>(m);
42.391 }
42.392
42.393 - template<class M>
42.394 - inline YMap<M> yMap(const M &m)
42.395 + template<class M>
42.396 + inline YMap<M> yMap(const M &m)
42.397 {
42.398 return YMap<M>(m);
42.399 }
42.400 @@ -641,7 +641,7 @@
42.401 ///Constant (read only) version of \ref YMap
42.402 ///
42.403 template<class M>
42.404 - class ConstYMap
42.405 + class ConstYMap
42.406 {
42.407 const M& _map;
42.408 public:
42.409 @@ -652,15 +652,15 @@
42.410 ConstYMap(const M &map) : _map(map) {}
42.411 Value operator[](Key k) const {return _map[k].y;}
42.412 };
42.413 -
42.414 +
42.415 ///Returns a \ref ConstYMap class
42.416
42.417 ///This function just returns a \ref ConstYMap class.
42.418 ///
42.419 ///\ingroup maps
42.420 ///\relates ConstYMap
42.421 - template<class M>
42.422 - inline ConstYMap<M> yMap(const M &m)
42.423 + template<class M>
42.424 + inline ConstYMap<M> yMap(const M &m)
42.425 {
42.426 return ConstYMap<M>(m);
42.427 }
42.428 @@ -673,7 +673,7 @@
42.429 ///of a \ref Point "Point"-map.
42.430 ///\ingroup maps
42.431 template<class M>
42.432 - class NormSquareMap
42.433 + class NormSquareMap
42.434 {
42.435 const M& _map;
42.436 public:
42.437 @@ -684,15 +684,15 @@
42.438 NormSquareMap(const M &map) : _map(map) {}
42.439 Value operator[](Key k) const {return _map[k].normSquare();}
42.440 };
42.441 -
42.442 +
42.443 ///Returns a \ref NormSquareMap class
42.444
42.445 ///This function just returns a \ref NormSquareMap class.
42.446 ///
42.447 ///\ingroup maps
42.448 ///\relates NormSquareMap
42.449 - template<class M>
42.450 - inline NormSquareMap<M> normSquareMap(const M &m)
42.451 + template<class M>
42.452 + inline NormSquareMap<M> normSquareMap(const M &m)
42.453 {
42.454 return NormSquareMap<M>(m);
42.455 }
42.456 @@ -700,7 +700,7 @@
42.457 /// @}
42.458
42.459 } //namespce dim2
42.460 -
42.461 +
42.462 } //namespace lemon
42.463
42.464 #endif //LEMON_DIM2_H
43.1 --- a/lemon/error.h Sun Jul 13 16:46:56 2008 +0100
43.2 +++ b/lemon/error.h Sun Jul 13 19:51:02 2008 +0100
43.3 @@ -1,6 +1,6 @@
43.4 -/* -*- C++ -*-
43.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
43.6 *
43.7 - * This file is a part of LEMON, a generic C++ optimization library
43.8 + * This file is a part of LEMON, a generic C++ optimization library.
43.9 *
43.10 * Copyright (C) 2003-2008
43.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
43.12 @@ -45,39 +45,39 @@
43.13
43.14 ExceptionMember() throw() {
43.15 try {
43.16 - ptr.reset(new Type());
43.17 + ptr.reset(new Type());
43.18 } catch (...) {}
43.19 }
43.20
43.21 ExceptionMember(const Type& type) throw() {
43.22 try {
43.23 - ptr.reset(new Type());
43.24 - if (ptr.get() == 0) return;
43.25 - *ptr = type;
43.26 + ptr.reset(new Type());
43.27 + if (ptr.get() == 0) return;
43.28 + *ptr = type;
43.29 } catch (...) {}
43.30 }
43.31
43.32 ExceptionMember(const ExceptionMember& copy) throw() {
43.33 try {
43.34 - if (!copy.valid()) return;
43.35 - ptr.reset(new Type());
43.36 - if (ptr.get() == 0) return;
43.37 - *ptr = copy.get();
43.38 + if (!copy.valid()) return;
43.39 + ptr.reset(new Type());
43.40 + if (ptr.get() == 0) return;
43.41 + *ptr = copy.get();
43.42 } catch (...) {}
43.43 }
43.44
43.45 ExceptionMember& operator=(const ExceptionMember& copy) throw() {
43.46 if (ptr.get() == 0) return;
43.47 try {
43.48 - if (!copy.valid()) return;
43.49 - *ptr = copy.get();
43.50 + if (!copy.valid()) return;
43.51 + *ptr = copy.get();
43.52 } catch (...) {}
43.53 }
43.54
43.55 void set(const Type& type) throw() {
43.56 if (ptr.get() == 0) return;
43.57 try {
43.58 - *ptr = type;
43.59 + *ptr = type;
43.60 } catch (...) {}
43.61 }
43.62
43.63 @@ -109,10 +109,10 @@
43.64 ///\e
43.65 bool init() throw() {
43.66 try {
43.67 - buf.reset(new std::ostringstream);
43.68 + buf.reset(new std::ostringstream);
43.69 }
43.70 catch(...) {
43.71 - buf.reset();
43.72 + buf.reset();
43.73 }
43.74 return buf.get();
43.75 }
43.76 @@ -142,10 +142,10 @@
43.77 if( ! buf.get() ) return *this;
43.78
43.79 try {
43.80 - *buf << t;
43.81 + *buf << t;
43.82 }
43.83 catch(...) {
43.84 - buf.reset();
43.85 + buf.reset();
43.86 }
43.87 return *this;
43.88 }
43.89 @@ -156,7 +156,7 @@
43.90
43.91 const char* mes = 0;
43.92 try {
43.93 - mes = buf->str().c_str();
43.94 + mes = buf->str().c_str();
43.95 }
43.96 catch(...) {}
43.97 return mes;
43.98 @@ -254,7 +254,7 @@
43.99
43.100 ///\e
43.101 DataFormatError(const std::string &file_name, int line_num,
43.102 - const char *the_message)
43.103 + const char *the_message)
43.104 : _message(the_message), _line(line_num) { file(file_name); }
43.105
43.106 ///\e
43.107 @@ -269,9 +269,9 @@
43.108 ///\e
43.109 const char* message() const {
43.110 if (_message.valid() && !_message.get().empty()) {
43.111 - return _message.get().c_str();
43.112 + return _message.get().c_str();
43.113 } else {
43.114 - return 0;
43.115 + return 0;
43.116 }
43.117 }
43.118
43.119 @@ -280,26 +280,26 @@
43.120 /// Returns \e null if the filename was not specified.
43.121 const char* file() const {
43.122 if (_file.valid() && !_file.get().empty()) {
43.123 - return _file.get().c_str();
43.124 + return _file.get().c_str();
43.125 } else {
43.126 - return 0;
43.127 + return 0;
43.128 }
43.129 }
43.130
43.131 ///\e
43.132 virtual const char* what() const throw() {
43.133 try {
43.134 - std::ostringstream ostr;
43.135 - ostr << "lemon:DataFormatError" << ": ";
43.136 - if (message()) ostr << message();
43.137 - if( file() || line() != 0 ) {
43.138 - ostr << " (";
43.139 - if( file() ) ostr << "in file '" << file() << "'";
43.140 - if( file() && line() != 0 ) ostr << " ";
43.141 - if( line() != 0 ) ostr << "at line " << line();
43.142 - ostr << ")";
43.143 - }
43.144 - _message_holder.set(ostr.str());
43.145 + std::ostringstream ostr;
43.146 + ostr << "lemon:DataFormatError" << ": ";
43.147 + if (message()) ostr << message();
43.148 + if( file() || line() != 0 ) {
43.149 + ostr << " (";
43.150 + if( file() ) ostr << "in file '" << file() << "'";
43.151 + if( file() && line() != 0 ) ostr << " ";
43.152 + if( line() != 0 ) ostr << "at line " << line();
43.153 + ostr << ")";
43.154 + }
43.155 + _message_holder.set(ostr.str());
43.156 }
43.157 catch (...) {}
43.158 if( _message_holder.valid()) return _message_holder.get().c_str();
43.159 @@ -333,19 +333,19 @@
43.160 /// Returns \e null if the filename was not specified.
43.161 const char* file() const {
43.162 if (_file.valid() && !_file.get().empty()) {
43.163 - return _file.get().c_str();
43.164 + return _file.get().c_str();
43.165 } else {
43.166 - return 0;
43.167 + return 0;
43.168 }
43.169 }
43.170
43.171 ///\e
43.172 virtual const char* what() const throw() {
43.173 try {
43.174 - std::ostringstream ostr;
43.175 - ostr << "lemon::FileOpenError" << ": ";
43.176 - ostr << "Cannot open file - " << file();
43.177 - _message_holder.set(ostr.str());
43.178 + std::ostringstream ostr;
43.179 + ostr << "lemon::FileOpenError" << ": ";
43.180 + ostr << "Cannot open file - " << file();
43.181 + _message_holder.set(ostr.str());
43.182 }
43.183 catch (...) {}
43.184 if( _message_holder.valid()) return _message_holder.get().c_str();
43.185 @@ -381,9 +381,9 @@
43.186 ///\e
43.187 const char* message() const {
43.188 if (_message.valid()) {
43.189 - return _message.get().c_str();
43.190 + return _message.get().c_str();
43.191 } else {
43.192 - return 0;
43.193 + return 0;
43.194 }
43.195 }
43.196
43.197 @@ -392,19 +392,19 @@
43.198 /// Returns \c 0 if the filename was not specified.
43.199 const char* file() const {
43.200 if (_file.valid()) {
43.201 - return _file.get().c_str();
43.202 + return _file.get().c_str();
43.203 } else {
43.204 - return 0;
43.205 + return 0;
43.206 }
43.207 }
43.208
43.209 ///\e
43.210 virtual const char* what() const throw() {
43.211 try {
43.212 - std::ostringstream ostr;
43.213 - if (message()) ostr << message();
43.214 - if (file()) ostr << "(when reading file '" << file() << "')";
43.215 - _message_holder.set(ostr.str());
43.216 + std::ostringstream ostr;
43.217 + if (message()) ostr << message();
43.218 + if (file()) ostr << "(when reading file '" << file() << "')";
43.219 + _message_holder.set(ostr.str());
43.220 }
43.221 catch (...) {}
43.222 if( _message_holder.valid() ) return _message_holder.get().c_str();
44.1 --- a/lemon/graph_to_eps.h Sun Jul 13 16:46:56 2008 +0100
44.2 +++ b/lemon/graph_to_eps.h Sun Jul 13 19:51:02 2008 +0100
44.3 @@ -1,6 +1,6 @@
44.4 -/* -*- C++ -*-
44.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
44.6 *
44.7 - * This file is a part of LEMON, a generic C++ optimization library
44.8 + * This file is a part of LEMON, a generic C++ optimization library.
44.9 *
44.10 * Copyright (C) 2003-2008
44.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
44.12 @@ -60,7 +60,7 @@
44.13 Value operator[](Key n) { return Value(map[n].x,map[n].y*yscale);}
44.14 };
44.15 }
44.16 -
44.17 +
44.18 ///Default traits class of \ref GraphToEps
44.19
44.20 ///Default traits class of \ref GraphToEps.
44.21 @@ -76,12 +76,12 @@
44.22 typedef typename Graph::ArcIt ArcIt;
44.23 typedef typename Graph::InArcIt InArcIt;
44.24 typedef typename Graph::OutArcIt OutArcIt;
44.25 -
44.26 +
44.27
44.28 const Graph &g;
44.29
44.30 std::ostream& os;
44.31 -
44.32 +
44.33 typedef ConstMap<typename Graph::Node,dim2::Point<double> > CoordsMapType;
44.34 CoordsMapType _coords;
44.35 ConstMap<typename Graph::Node,double > _nodeSizes;
44.36 @@ -93,28 +93,28 @@
44.37 ConstMap<typename Graph::Arc,double > _arcWidths;
44.38
44.39 double _arcWidthScale;
44.40 -
44.41 +
44.42 double _nodeScale;
44.43 double _xBorder, _yBorder;
44.44 double _scale;
44.45 double _nodeBorderQuotient;
44.46 -
44.47 +
44.48 bool _drawArrows;
44.49 double _arrowLength, _arrowWidth;
44.50 -
44.51 +
44.52 bool _showNodes, _showArcs;
44.53
44.54 bool _enableParallel;
44.55 double _parArcDist;
44.56
44.57 bool _showNodeText;
44.58 - ConstMap<typename Graph::Node,bool > _nodeTexts;
44.59 + ConstMap<typename Graph::Node,bool > _nodeTexts;
44.60 double _nodeTextSize;
44.61
44.62 bool _showNodePsText;
44.63 - ConstMap<typename Graph::Node,bool > _nodePsTexts;
44.64 + ConstMap<typename Graph::Node,bool > _nodePsTexts;
44.65 char *_nodePsTextsPreamble;
44.66 -
44.67 +
44.68 bool _undirected;
44.69
44.70 bool _pleaseRemoveOsStream;
44.71 @@ -124,7 +124,7 @@
44.72 std::string _title;
44.73 std::string _copyright;
44.74
44.75 - enum NodeTextColorType
44.76 + enum NodeTextColorType
44.77 { DIST_COL=0, DIST_BW=1, CUST_COL=2, SAME_COL=3 } _nodeTextColorType;
44.78 ConstMap<typename Graph::Node,Color > _nodeTextColors;
44.79
44.80 @@ -146,7 +146,7 @@
44.81 ///\param _pros If it is \c true, then the \c ostream referenced by \c _os
44.82 ///will be explicitly deallocated by the destructor.
44.83 DefaultGraphToEpsTraits(const G &_g,std::ostream& _os=std::cout,
44.84 - bool _pros=false) :
44.85 + bool _pros=false) :
44.86 g(_g), os(_os),
44.87 _coords(dim2::Point<double>(1,1)), _nodeSizes(1), _nodeShapes(0),
44.88 _nodeColors(WHITE), _arcColors(BLACK),
44.89 @@ -175,7 +175,7 @@
44.90 ///Auxiliary class to implement the named parameters of \ref graphToEps().
44.91 ///
44.92 ///For detailed examples see the \ref graph_to_eps_demo.cc demo file.
44.93 -template<class T> class GraphToEps : public T
44.94 +template<class T> class GraphToEps : public T
44.95 {
44.96 // Can't believe it is required by the C++ standard
44.97 using T::g;
44.98 @@ -194,11 +194,11 @@
44.99 using T::_yBorder;
44.100 using T::_scale;
44.101 using T::_nodeBorderQuotient;
44.102 -
44.103 +
44.104 using T::_drawArrows;
44.105 using T::_arrowLength;
44.106 using T::_arrowWidth;
44.107 -
44.108 +
44.109 using T::_showNodes;
44.110 using T::_showArcs;
44.111
44.112 @@ -206,13 +206,13 @@
44.113 using T::_parArcDist;
44.114
44.115 using T::_showNodeText;
44.116 - using T::_nodeTexts;
44.117 + using T::_nodeTexts;
44.118 using T::_nodeTextSize;
44.119
44.120 using T::_showNodePsText;
44.121 - using T::_nodePsTexts;
44.122 + using T::_nodePsTexts;
44.123 using T::_nodePsTextsPreamble;
44.124 -
44.125 +
44.126 using T::_undirected;
44.127
44.128 using T::_pleaseRemoveOsStream;
44.129 @@ -261,16 +261,16 @@
44.130
44.131 ///Node shapes.
44.132 ///
44.133 - enum NodeShapes {
44.134 + enum NodeShapes {
44.135 /// = 0
44.136 ///\image html nodeshape_0.png
44.137 ///\image latex nodeshape_0.eps "CIRCLE shape (0)" width=2cm
44.138 - CIRCLE=0,
44.139 + CIRCLE=0,
44.140 /// = 1
44.141 ///\image html nodeshape_1.png
44.142 ///\image latex nodeshape_1.eps "SQUARE shape (1)" width=2cm
44.143 ///
44.144 - SQUARE=1,
44.145 + SQUARE=1,
44.146 /// = 2
44.147 ///\image html nodeshape_2.png
44.148 ///\image latex nodeshape_2.eps "DIAMOND shape (2)" width=2cm
44.149 @@ -293,41 +293,41 @@
44.150 const Graph &g;
44.151 public:
44.152 arcLess(const Graph &_g) : g(_g) {}
44.153 - bool operator()(Arc a,Arc b) const
44.154 + bool operator()(Arc a,Arc b) const
44.155 {
44.156 Node ai=std::min(g.source(a),g.target(a));
44.157 Node aa=std::max(g.source(a),g.target(a));
44.158 Node bi=std::min(g.source(b),g.target(b));
44.159 Node ba=std::max(g.source(b),g.target(b));
44.160 return ai<bi ||
44.161 - (ai==bi && (aa < ba ||
44.162 - (aa==ba && ai==g.source(a) && bi==g.target(b))));
44.163 + (ai==bi && (aa < ba ||
44.164 + (aa==ba && ai==g.source(a) && bi==g.target(b))));
44.165 }
44.166 };
44.167 bool isParallel(Arc e,Arc f) const
44.168 {
44.169 return (g.source(e)==g.source(f)&&
44.170 - g.target(e)==g.target(f)) ||
44.171 + g.target(e)==g.target(f)) ||
44.172 (g.source(e)==g.target(f)&&
44.173 g.target(e)==g.source(f));
44.174 }
44.175 template<class TT>
44.176 - static std::string psOut(const dim2::Point<TT> &p)
44.177 + static std::string psOut(const dim2::Point<TT> &p)
44.178 {
44.179 - std::ostringstream os;
44.180 + std::ostringstream os;
44.181 os << p.x << ' ' << p.y;
44.182 return os.str();
44.183 }
44.184 - static std::string psOut(const Color &c)
44.185 + static std::string psOut(const Color &c)
44.186 {
44.187 - std::ostringstream os;
44.188 + std::ostringstream os;
44.189 os << c.red() << ' ' << c.green() << ' ' << c.blue();
44.190 return os.str();
44.191 }
44.192 -
44.193 +
44.194 public:
44.195 GraphToEps(const T &t) : T(t), dontPrint(false) {};
44.196 -
44.197 +
44.198 template<class X> struct CoordsTraits : public T {
44.199 typedef X CoordsMapType;
44.200 const X &_coords;
44.201 @@ -337,7 +337,7 @@
44.202
44.203 ///Sets the map of the node coordinates.
44.204 ///\param x must be a node map with \ref dim2::Point "dim2::Point<double>" or
44.205 - ///\ref dim2::Point "dim2::Point<int>" values.
44.206 + ///\ref dim2::Point "dim2::Point<int>" values.
44.207 template<class X> GraphToEps<CoordsTraits<X> > coords(const X &x) {
44.208 dontPrint=true;
44.209 return GraphToEps<CoordsTraits<X> >(CoordsTraits<X>(*this,x));
44.210 @@ -349,7 +349,7 @@
44.211 ///Sets the map of the node sizes
44.212
44.213 ///Sets the map of the node sizes.
44.214 - ///\param x must be a node map with \c double (or convertible) values.
44.215 + ///\param x must be a node map with \c double (or convertible) values.
44.216 template<class X> GraphToEps<NodeSizesTraits<X> > nodeSizes(const X &x)
44.217 {
44.218 dontPrint=true;
44.219 @@ -364,7 +364,7 @@
44.220 ///Sets the map of the node shapes.
44.221 ///The available shape values
44.222 ///can be found in \ref NodeShapes "enum NodeShapes".
44.223 - ///\param x must be a node map with \c int (or convertible) values.
44.224 + ///\param x must be a node map with \c int (or convertible) values.
44.225 ///\sa NodeShapes
44.226 template<class X> GraphToEps<NodeShapesTraits<X> > nodeShapes(const X &x)
44.227 {
44.228 @@ -379,7 +379,7 @@
44.229
44.230 ///Sets the text printed on the nodes.
44.231 ///\param x must be a node map with type that can be pushed to a standard
44.232 - ///\c ostream.
44.233 + ///\c ostream.
44.234 template<class X> GraphToEps<NodeTextsTraits<X> > nodeTexts(const X &x)
44.235 {
44.236 dontPrint=true;
44.237 @@ -417,7 +417,7 @@
44.238 ///Sets the map of the arc widths
44.239
44.240 ///Sets the map of the arc widths.
44.241 - ///\param x must be an arc map with \c double (or convertible) values.
44.242 + ///\param x must be an arc map with \c double (or convertible) values.
44.243 template<class X> GraphToEps<ArcWidthsTraits<X> > arcWidths(const X &x)
44.244 {
44.245 dontPrint=true;
44.246 @@ -447,7 +447,7 @@
44.247 ///Sets the map of the node text colors
44.248
44.249 ///Sets the map of the node text colors.
44.250 - ///\param x must be a node map with \ref Color values.
44.251 + ///\param x must be a node map with \ref Color values.
44.252 ///
44.253 ///\sa Palette
44.254 template<class X> GraphToEps<NodeTextColorsTraits<X> >
44.255 @@ -465,7 +465,7 @@
44.256 ///Sets the map of the arc colors
44.257
44.258 ///Sets the map of the arc colors.
44.259 - ///\param x must be an arc map with \ref Color values.
44.260 + ///\param x must be an arc map with \ref Color values.
44.261 ///
44.262 ///\sa Palette
44.263 template<class X> GraphToEps<ArcColorsTraits<X> >
44.264 @@ -477,7 +477,7 @@
44.265 ///Sets a global scale factor for node sizes
44.266
44.267 ///Sets a global scale factor for node sizes.
44.268 - ///
44.269 + ///
44.270 /// If nodeSizes() is not given, this function simply sets the node
44.271 /// sizes to \c d. If nodeSizes() is given, but
44.272 /// autoNodeScale() is not, then the node size given by
44.273 @@ -568,21 +568,21 @@
44.274 GraphToEps<T> &arrowLength(double d=1.0) {_arrowLength*=d;return *this;}
44.275 ///Sets the width of the arrowheads
44.276 GraphToEps<T> &arrowWidth(double d=.3) {_arrowWidth*=d;return *this;}
44.277 -
44.278 +
44.279 ///Scales the drawing to fit to A4 page
44.280 GraphToEps<T> &scaleToA4() {_scaleToA4=true;return *this;}
44.281 -
44.282 +
44.283 ///Enables parallel arcs
44.284 GraphToEps<T> &enableParallel(bool b=true) {_enableParallel=b;return *this;}
44.285 -
44.286 +
44.287 ///Sets the distance between parallel arcs
44.288 GraphToEps<T> &parArcDist(double d) {_parArcDist*=d;return *this;}
44.289 -
44.290 +
44.291 ///Hides the arcs
44.292 GraphToEps<T> &hideArcs(bool b=true) {_showArcs=!b;return *this;}
44.293 ///Hides the nodes
44.294 GraphToEps<T> &hideNodes(bool b=true) {_showNodes=!b;return *this;}
44.295 -
44.296 +
44.297 ///Sets the size of the node texts
44.298 GraphToEps<T> &nodeTextSize(double d) {_nodeTextSize=d;return *this;}
44.299
44.300 @@ -600,7 +600,7 @@
44.301 {_nodeTextColorType=DIST_BW;return *this;}
44.302
44.303 ///Gives a preamble block for node Postscript block.
44.304 -
44.305 +
44.306 ///Gives a preamble block for node Postscript block.
44.307 ///
44.308 ///\sa nodePsTexts()
44.309 @@ -625,7 +625,7 @@
44.310 ///
44.311 ///\sa undirected()
44.312 GraphToEps<T> &directed(bool b=true) {_undirected=!b;return *this;}
44.313 -
44.314 +
44.315 ///Sets the title.
44.316
44.317 ///Sets the title of the generated image,
44.318 @@ -640,7 +640,7 @@
44.319 GraphToEps<T> ©right(const std::string &t) {_copyright=t;return *this;}
44.320
44.321 protected:
44.322 - bool isInsideNode(dim2::Point<double> p, double r,int t)
44.323 + bool isInsideNode(dim2::Point<double> p, double r,int t)
44.324 {
44.325 switch(t) {
44.326 case CIRCLE:
44.327 @@ -657,7 +657,7 @@
44.328
44.329 public:
44.330 ~GraphToEps() { }
44.331 -
44.332 +
44.333 ///Draws the graph.
44.334
44.335 ///Like other functions using
44.336 @@ -668,7 +668,7 @@
44.337 //\todo better 'epsilon' would be nice here.
44.338 const double EPSILON=1e-9;
44.339 if(dontPrint) return;
44.340 -
44.341 +
44.342 _graph_to_eps_bits::_NegY<typename T::CoordsMapType>
44.343 mycoords(_coords,_negY);
44.344
44.345 @@ -677,8 +677,8 @@
44.346 if(_copyright.size()>0) os << "%%Copyright: " << _copyright << '\n';
44.347 os << "%%Creator: LEMON, graphToEps()\n";
44.348
44.349 - {
44.350 -#ifndef WIN32
44.351 + {
44.352 +#ifndef WIN32
44.353 timeval tv;
44.354 gettimeofday(&tv, 0);
44.355
44.356 @@ -688,37 +688,37 @@
44.357 #else
44.358 SYSTEMTIME time;
44.359 char buf1[11], buf2[9], buf3[5];
44.360 -
44.361 +
44.362 GetSystemTime(&time);
44.363 - if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
44.364 - "ddd MMM dd", buf1, 11) &&
44.365 - GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
44.366 - "HH':'mm':'ss", buf2, 9) &&
44.367 - GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
44.368 - "yyyy", buf3, 5)) {
44.369 - os << "%%CreationDate: " << buf1 << ' '
44.370 - << buf2 << ' ' << buf3 << std::endl;
44.371 - }
44.372 + if (GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
44.373 + "ddd MMM dd", buf1, 11) &&
44.374 + GetTimeFormat(LOCALE_USER_DEFAULT, 0, &time,
44.375 + "HH':'mm':'ss", buf2, 9) &&
44.376 + GetDateFormat(LOCALE_USER_DEFAULT, 0, &time,
44.377 + "yyyy", buf3, 5)) {
44.378 + os << "%%CreationDate: " << buf1 << ' '
44.379 + << buf2 << ' ' << buf3 << std::endl;
44.380 + }
44.381 #endif
44.382 }
44.383
44.384 if (_autoArcWidthScale) {
44.385 double max_w=0;
44.386 for(ArcIt e(g);e!=INVALID;++e)
44.387 - max_w=std::max(double(_arcWidths[e]),max_w);
44.388 + max_w=std::max(double(_arcWidths[e]),max_w);
44.389 //\todo better 'epsilon' would be nice here.
44.390 if(max_w>EPSILON) {
44.391 - _arcWidthScale/=max_w;
44.392 + _arcWidthScale/=max_w;
44.393 }
44.394 }
44.395
44.396 if (_autoNodeScale) {
44.397 double max_s=0;
44.398 for(NodeIt n(g);n!=INVALID;++n)
44.399 - max_s=std::max(double(_nodeSizes[n]),max_s);
44.400 + max_s=std::max(double(_nodeSizes[n]),max_s);
44.401 //\todo better 'epsilon' would be nice here.
44.402 if(max_s>EPSILON) {
44.403 - _nodeScale/=max_s;
44.404 + _nodeScale/=max_s;
44.405 }
44.406 }
44.407
44.408 @@ -727,14 +727,14 @@
44.409 dim2::BoundingBox<double> bb;
44.410 for(NodeIt n(g);n!=INVALID;++n) bb.add(mycoords[n]);
44.411 if (bb.empty()) {
44.412 - bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
44.413 + bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
44.414 }
44.415 diag_len = std::sqrt((bb.bottomLeft()-bb.topRight()).normSquare());
44.416 if(diag_len<EPSILON) diag_len = 1;
44.417 if(!_absoluteNodeSizes) _nodeScale*=diag_len;
44.418 if(!_absoluteArcWidths) _arcWidthScale*=diag_len;
44.419 }
44.420 -
44.421 +
44.422 dim2::BoundingBox<double> bb;
44.423 for(NodeIt n(g);n!=INVALID;++n) {
44.424 double ns=_nodeSizes[n]*_nodeScale;
44.425 @@ -743,41 +743,41 @@
44.426 case CIRCLE:
44.427 case SQUARE:
44.428 case DIAMOND:
44.429 - bb.add(p+mycoords[n]);
44.430 - bb.add(-p+mycoords[n]);
44.431 - break;
44.432 + bb.add(p+mycoords[n]);
44.433 + bb.add(-p+mycoords[n]);
44.434 + break;
44.435 case MALE:
44.436 - bb.add(-p+mycoords[n]);
44.437 - bb.add(dim2::Point<double>(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]);
44.438 - break;
44.439 + bb.add(-p+mycoords[n]);
44.440 + bb.add(dim2::Point<double>(1.5*ns,1.5*std::sqrt(3.0)*ns)+mycoords[n]);
44.441 + break;
44.442 case FEMALE:
44.443 - bb.add(p+mycoords[n]);
44.444 - bb.add(dim2::Point<double>(-ns,-3.01*ns)+mycoords[n]);
44.445 - break;
44.446 + bb.add(p+mycoords[n]);
44.447 + bb.add(dim2::Point<double>(-ns,-3.01*ns)+mycoords[n]);
44.448 + break;
44.449 }
44.450 }
44.451 if (bb.empty()) {
44.452 bb = dim2::BoundingBox<double>(dim2::Point<double>(0,0));
44.453 }
44.454 -
44.455 +
44.456 if(_scaleToA4)
44.457 os <<"%%BoundingBox: 0 0 596 842\n%%DocumentPaperSizes: a4\n";
44.458 else {
44.459 if(_preScale) {
44.460 - //Rescale so that BoundingBox won't be neither to big nor too small.
44.461 - while(bb.height()*_scale>1000||bb.width()*_scale>1000) _scale/=10;
44.462 - while(bb.height()*_scale<100||bb.width()*_scale<100) _scale*=10;
44.463 + //Rescale so that BoundingBox won't be neither to big nor too small.
44.464 + while(bb.height()*_scale>1000||bb.width()*_scale>1000) _scale/=10;
44.465 + while(bb.height()*_scale<100||bb.width()*_scale<100) _scale*=10;
44.466 }
44.467 -
44.468 +
44.469 os << "%%BoundingBox: "
44.470 - << int(floor(bb.left() * _scale - _xBorder)) << ' '
44.471 - << int(floor(bb.bottom() * _scale - _yBorder)) << ' '
44.472 - << int(ceil(bb.right() * _scale + _xBorder)) << ' '
44.473 - << int(ceil(bb.top() * _scale + _yBorder)) << '\n';
44.474 + << int(floor(bb.left() * _scale - _xBorder)) << ' '
44.475 + << int(floor(bb.bottom() * _scale - _yBorder)) << ' '
44.476 + << int(ceil(bb.right() * _scale + _xBorder)) << ' '
44.477 + << int(ceil(bb.top() * _scale + _yBorder)) << '\n';
44.478 }
44.479 -
44.480 +
44.481 os << "%%EndComments\n";
44.482 -
44.483 +
44.484 //x1 y1 x2 y2 x3 y3 cr cg cb w
44.485 os << "/lb { setlinewidth setrgbcolor newpath moveto\n"
44.486 << " 4 2 roll 1 index 1 index curveto stroke } bind def\n";
44.487 @@ -831,7 +831,7 @@
44.488 << " 5 index 5 index 5 index c fill\n"
44.489 << " setrgbcolor " << 1+_nodeBorderQuotient << " div c fill\n"
44.490 << " } bind def\n";
44.491 -
44.492 +
44.493
44.494 os << "/arrl " << _arrowLength << " def\n";
44.495 os << "/arrw " << _arrowWidth << " def\n";
44.496 @@ -840,7 +840,7 @@
44.497 //len w dx_norm dy_norm x1 y1 cr cg cb
44.498 os << "/arr { setrgbcolor /y1 exch def /x1 exch def /dy exch def /dx exch def\n"
44.499 << " /w exch def /len exch def\n"
44.500 - // << " 0.1 setlinewidth x1 y1 moveto dx len mul dy len mul rlineto stroke"
44.501 + // << " 0.1 setlinewidth x1 y1 moveto dx len mul dy len mul rlineto stroke"
44.502 << " newpath x1 dy w 2 div mul add y1 dx w 2 div mul sub moveto\n"
44.503 << " len w sub arrl sub dx dy lrl\n"
44.504 << " arrw dy dx neg lrl\n"
44.505 @@ -857,175 +857,175 @@
44.506 os << "\ngsave\n";
44.507 if(_scaleToA4)
44.508 if(bb.height()>bb.width()) {
44.509 - double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.height(),
44.510 - (A4WIDTH-2*A4BORDER)/bb.width());
44.511 - os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' '
44.512 - << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER
44.513 - << " translate\n"
44.514 - << sc << " dup scale\n"
44.515 - << -bb.left() << ' ' << -bb.bottom() << " translate\n";
44.516 + double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.height(),
44.517 + (A4WIDTH-2*A4BORDER)/bb.width());
44.518 + os << ((A4WIDTH -2*A4BORDER)-sc*bb.width())/2 + A4BORDER << ' '
44.519 + << ((A4HEIGHT-2*A4BORDER)-sc*bb.height())/2 + A4BORDER
44.520 + << " translate\n"
44.521 + << sc << " dup scale\n"
44.522 + << -bb.left() << ' ' << -bb.bottom() << " translate\n";
44.523 }
44.524 else {
44.525 - //\todo Verify centering
44.526 - double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(),
44.527 - (A4WIDTH-2*A4BORDER)/bb.height());
44.528 - os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' '
44.529 - << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER
44.530 - << " translate\n"
44.531 - << sc << " dup scale\n90 rotate\n"
44.532 - << -bb.left() << ' ' << -bb.top() << " translate\n";
44.533 - }
44.534 + //\todo Verify centering
44.535 + double sc= std::min((A4HEIGHT-2*A4BORDER)/bb.width(),
44.536 + (A4WIDTH-2*A4BORDER)/bb.height());
44.537 + os << ((A4WIDTH -2*A4BORDER)-sc*bb.height())/2 + A4BORDER << ' '
44.538 + << ((A4HEIGHT-2*A4BORDER)-sc*bb.width())/2 + A4BORDER
44.539 + << " translate\n"
44.540 + << sc << " dup scale\n90 rotate\n"
44.541 + << -bb.left() << ' ' << -bb.top() << " translate\n";
44.542 + }
44.543 else if(_scale!=1.0) os << _scale << " dup scale\n";
44.544 -
44.545 +
44.546 if(_showArcs) {
44.547 - os << "%Arcs:\ngsave\n";
44.548 + os << "%Arcs:\ngsave\n";
44.549 if(_enableParallel) {
44.550 - std::vector<Arc> el;
44.551 - for(ArcIt e(g);e!=INVALID;++e)
44.552 - if((!_undirected||g.source(e)<g.target(e))&&_arcWidths[e]>0
44.553 - &&g.source(e)!=g.target(e))
44.554 - el.push_back(e);
44.555 - std::sort(el.begin(),el.end(),arcLess(g));
44.556 -
44.557 - typename std::vector<Arc>::iterator j;
44.558 - for(typename std::vector<Arc>::iterator i=el.begin();i!=el.end();i=j) {
44.559 - for(j=i+1;j!=el.end()&&isParallel(*i,*j);++j) ;
44.560 + std::vector<Arc> el;
44.561 + for(ArcIt e(g);e!=INVALID;++e)
44.562 + if((!_undirected||g.source(e)<g.target(e))&&_arcWidths[e]>0
44.563 + &&g.source(e)!=g.target(e))
44.564 + el.push_back(e);
44.565 + std::sort(el.begin(),el.end(),arcLess(g));
44.566
44.567 - double sw=0;
44.568 - for(typename std::vector<Arc>::iterator e=i;e!=j;++e)
44.569 - sw+=_arcWidths[*e]*_arcWidthScale+_parArcDist;
44.570 - sw-=_parArcDist;
44.571 - sw/=-2.0;
44.572 - dim2::Point<double>
44.573 - dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
44.574 - double l=std::sqrt(dvec.normSquare());
44.575 - //\todo better 'epsilon' would be nice here.
44.576 - dim2::Point<double> d(dvec/std::max(l,EPSILON));
44.577 - dim2::Point<double> m;
44.578 -// m=dim2::Point<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0;
44.579 + typename std::vector<Arc>::iterator j;
44.580 + for(typename std::vector<Arc>::iterator i=el.begin();i!=el.end();i=j) {
44.581 + for(j=i+1;j!=el.end()&&isParallel(*i,*j);++j) ;
44.582
44.583 -// m=dim2::Point<double>(mycoords[g.source(*i)])+
44.584 -// dvec*(double(_nodeSizes[g.source(*i)])/
44.585 -// (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)]));
44.586 + double sw=0;
44.587 + for(typename std::vector<Arc>::iterator e=i;e!=j;++e)
44.588 + sw+=_arcWidths[*e]*_arcWidthScale+_parArcDist;
44.589 + sw-=_parArcDist;
44.590 + sw/=-2.0;
44.591 + dim2::Point<double>
44.592 + dvec(mycoords[g.target(*i)]-mycoords[g.source(*i)]);
44.593 + double l=std::sqrt(dvec.normSquare());
44.594 + //\todo better 'epsilon' would be nice here.
44.595 + dim2::Point<double> d(dvec/std::max(l,EPSILON));
44.596 + dim2::Point<double> m;
44.597 +// m=dim2::Point<double>(mycoords[g.target(*i)]+mycoords[g.source(*i)])/2.0;
44.598
44.599 - m=dim2::Point<double>(mycoords[g.source(*i)])+
44.600 - d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0;
44.601 +// m=dim2::Point<double>(mycoords[g.source(*i)])+
44.602 +// dvec*(double(_nodeSizes[g.source(*i)])/
44.603 +// (_nodeSizes[g.source(*i)]+_nodeSizes[g.target(*i)]));
44.604
44.605 - for(typename std::vector<Arc>::iterator e=i;e!=j;++e) {
44.606 - sw+=_arcWidths[*e]*_arcWidthScale/2.0;
44.607 - dim2::Point<double> mm=m+rot90(d)*sw/.75;
44.608 - if(_drawArrows) {
44.609 - int node_shape;
44.610 - dim2::Point<double> s=mycoords[g.source(*e)];
44.611 - dim2::Point<double> t=mycoords[g.target(*e)];
44.612 - double rn=_nodeSizes[g.target(*e)]*_nodeScale;
44.613 - node_shape=_nodeShapes[g.target(*e)];
44.614 - dim2::Bezier3 bez(s,mm,mm,t);
44.615 - double t1=0,t2=1;
44.616 - for(int ii=0;ii<INTERPOL_PREC;++ii)
44.617 - if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t2=(t1+t2)/2;
44.618 - else t1=(t1+t2)/2;
44.619 - dim2::Point<double> apoint=bez((t1+t2)/2);
44.620 - rn = _arrowLength+_arcWidths[*e]*_arcWidthScale;
44.621 - rn*=rn;
44.622 - t2=(t1+t2)/2;t1=0;
44.623 - for(int ii=0;ii<INTERPOL_PREC;++ii)
44.624 - if((bez((t1+t2)/2)-apoint).normSquare()>rn) t1=(t1+t2)/2;
44.625 - else t2=(t1+t2)/2;
44.626 - dim2::Point<double> linend=bez((t1+t2)/2);
44.627 - bez=bez.before((t1+t2)/2);
44.628 -// rn=_nodeSizes[g.source(*e)]*_nodeScale;
44.629 -// node_shape=_nodeShapes[g.source(*e)];
44.630 -// t1=0;t2=1;
44.631 -// for(int i=0;i<INTERPOL_PREC;++i)
44.632 -// if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t1=(t1+t2)/2;
44.633 -// else t2=(t1+t2)/2;
44.634 -// bez=bez.after((t1+t2)/2);
44.635 - os << _arcWidths[*e]*_arcWidthScale << " setlinewidth "
44.636 - << _arcColors[*e].red() << ' '
44.637 - << _arcColors[*e].green() << ' '
44.638 - << _arcColors[*e].blue() << " setrgbcolor newpath\n"
44.639 - << bez.p1.x << ' ' << bez.p1.y << " moveto\n"
44.640 - << bez.p2.x << ' ' << bez.p2.y << ' '
44.641 - << bez.p3.x << ' ' << bez.p3.y << ' '
44.642 - << bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n";
44.643 - dim2::Point<double> dd(rot90(linend-apoint));
44.644 - dd*=(.5*_arcWidths[*e]*_arcWidthScale+_arrowWidth)/
44.645 - std::sqrt(dd.normSquare());
44.646 - os << "newpath " << psOut(apoint) << " moveto "
44.647 - << psOut(linend+dd) << " lineto "
44.648 - << psOut(linend-dd) << " lineto closepath fill\n";
44.649 - }
44.650 - else {
44.651 - os << mycoords[g.source(*e)].x << ' '
44.652 - << mycoords[g.source(*e)].y << ' '
44.653 - << mm.x << ' ' << mm.y << ' '
44.654 - << mycoords[g.target(*e)].x << ' '
44.655 - << mycoords[g.target(*e)].y << ' '
44.656 - << _arcColors[*e].red() << ' '
44.657 - << _arcColors[*e].green() << ' '
44.658 - << _arcColors[*e].blue() << ' '
44.659 - << _arcWidths[*e]*_arcWidthScale << " lb\n";
44.660 - }
44.661 - sw+=_arcWidths[*e]*_arcWidthScale/2.0+_parArcDist;
44.662 - }
44.663 - }
44.664 + m=dim2::Point<double>(mycoords[g.source(*i)])+
44.665 + d*(l+_nodeSizes[g.source(*i)]-_nodeSizes[g.target(*i)])/2.0;
44.666 +
44.667 + for(typename std::vector<Arc>::iterator e=i;e!=j;++e) {
44.668 + sw+=_arcWidths[*e]*_arcWidthScale/2.0;
44.669 + dim2::Point<double> mm=m+rot90(d)*sw/.75;
44.670 + if(_drawArrows) {
44.671 + int node_shape;
44.672 + dim2::Point<double> s=mycoords[g.source(*e)];
44.673 + dim2::Point<double> t=mycoords[g.target(*e)];
44.674 + double rn=_nodeSizes[g.target(*e)]*_nodeScale;
44.675 + node_shape=_nodeShapes[g.target(*e)];
44.676 + dim2::Bezier3 bez(s,mm,mm,t);
44.677 + double t1=0,t2=1;
44.678 + for(int ii=0;ii<INTERPOL_PREC;++ii)
44.679 + if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t2=(t1+t2)/2;
44.680 + else t1=(t1+t2)/2;
44.681 + dim2::Point<double> apoint=bez((t1+t2)/2);
44.682 + rn = _arrowLength+_arcWidths[*e]*_arcWidthScale;
44.683 + rn*=rn;
44.684 + t2=(t1+t2)/2;t1=0;
44.685 + for(int ii=0;ii<INTERPOL_PREC;++ii)
44.686 + if((bez((t1+t2)/2)-apoint).normSquare()>rn) t1=(t1+t2)/2;
44.687 + else t2=(t1+t2)/2;
44.688 + dim2::Point<double> linend=bez((t1+t2)/2);
44.689 + bez=bez.before((t1+t2)/2);
44.690 +// rn=_nodeSizes[g.source(*e)]*_nodeScale;
44.691 +// node_shape=_nodeShapes[g.source(*e)];
44.692 +// t1=0;t2=1;
44.693 +// for(int i=0;i<INTERPOL_PREC;++i)
44.694 +// if(isInsideNode(bez((t1+t2)/2)-t,rn,node_shape)) t1=(t1+t2)/2;
44.695 +// else t2=(t1+t2)/2;
44.696 +// bez=bez.after((t1+t2)/2);
44.697 + os << _arcWidths[*e]*_arcWidthScale << " setlinewidth "
44.698 + << _arcColors[*e].red() << ' '
44.699 + << _arcColors[*e].green() << ' '
44.700 + << _arcColors[*e].blue() << " setrgbcolor newpath\n"
44.701 + << bez.p1.x << ' ' << bez.p1.y << " moveto\n"
44.702 + << bez.p2.x << ' ' << bez.p2.y << ' '
44.703 + << bez.p3.x << ' ' << bez.p3.y << ' '
44.704 + << bez.p4.x << ' ' << bez.p4.y << " curveto stroke\n";
44.705 + dim2::Point<double> dd(rot90(linend-apoint));
44.706 + dd*=(.5*_arcWidths[*e]*_arcWidthScale+_arrowWidth)/
44.707 + std::sqrt(dd.normSquare());
44.708 + os << "newpath " << psOut(apoint) << " moveto "
44.709 + << psOut(linend+dd) << " lineto "
44.710 + << psOut(linend-dd) << " lineto closepath fill\n";
44.711 + }
44.712 + else {
44.713 + os << mycoords[g.source(*e)].x << ' '
44.714 + << mycoords[g.source(*e)].y << ' '
44.715 + << mm.x << ' ' << mm.y << ' '
44.716 + << mycoords[g.target(*e)].x << ' '
44.717 + << mycoords[g.target(*e)].y << ' '
44.718 + << _arcColors[*e].red() << ' '
44.719 + << _arcColors[*e].green() << ' '
44.720 + << _arcColors[*e].blue() << ' '
44.721 + << _arcWidths[*e]*_arcWidthScale << " lb\n";
44.722 + }
44.723 + sw+=_arcWidths[*e]*_arcWidthScale/2.0+_parArcDist;
44.724 + }
44.725 + }
44.726 }
44.727 else for(ArcIt e(g);e!=INVALID;++e)
44.728 - if((!_undirected||g.source(e)<g.target(e))&&_arcWidths[e]>0
44.729 - &&g.source(e)!=g.target(e)) {
44.730 - if(_drawArrows) {
44.731 - dim2::Point<double> d(mycoords[g.target(e)]-mycoords[g.source(e)]);
44.732 - double rn=_nodeSizes[g.target(e)]*_nodeScale;
44.733 - int node_shape=_nodeShapes[g.target(e)];
44.734 - double t1=0,t2=1;
44.735 - for(int i=0;i<INTERPOL_PREC;++i)
44.736 - if(isInsideNode((-(t1+t2)/2)*d,rn,node_shape)) t1=(t1+t2)/2;
44.737 - else t2=(t1+t2)/2;
44.738 - double l=std::sqrt(d.normSquare());
44.739 - d/=l;
44.740 -
44.741 - os << l*(1-(t1+t2)/2) << ' '
44.742 - << _arcWidths[e]*_arcWidthScale << ' '
44.743 - << d.x << ' ' << d.y << ' '
44.744 - << mycoords[g.source(e)].x << ' '
44.745 - << mycoords[g.source(e)].y << ' '
44.746 - << _arcColors[e].red() << ' '
44.747 - << _arcColors[e].green() << ' '
44.748 - << _arcColors[e].blue() << " arr\n";
44.749 - }
44.750 - else os << mycoords[g.source(e)].x << ' '
44.751 - << mycoords[g.source(e)].y << ' '
44.752 - << mycoords[g.target(e)].x << ' '
44.753 - << mycoords[g.target(e)].y << ' '
44.754 - << _arcColors[e].red() << ' '
44.755 - << _arcColors[e].green() << ' '
44.756 - << _arcColors[e].blue() << ' '
44.757 - << _arcWidths[e]*_arcWidthScale << " l\n";
44.758 - }
44.759 + if((!_undirected||g.source(e)<g.target(e))&&_arcWidths[e]>0
44.760 + &&g.source(e)!=g.target(e)) {
44.761 + if(_drawArrows) {
44.762 + dim2::Point<double> d(mycoords[g.target(e)]-mycoords[g.source(e)]);
44.763 + double rn=_nodeSizes[g.target(e)]*_nodeScale;
44.764 + int node_shape=_nodeShapes[g.target(e)];
44.765 + double t1=0,t2=1;
44.766 + for(int i=0;i<INTERPOL_PREC;++i)
44.767 + if(isInsideNode((-(t1+t2)/2)*d,rn,node_shape)) t1=(t1+t2)/2;
44.768 + else t2=(t1+t2)/2;
44.769 + double l=std::sqrt(d.normSquare());
44.770 + d/=l;
44.771 +
44.772 + os << l*(1-(t1+t2)/2) << ' '
44.773 + << _arcWidths[e]*_arcWidthScale << ' '
44.774 + << d.x << ' ' << d.y << ' '
44.775 + << mycoords[g.source(e)].x << ' '
44.776 + << mycoords[g.source(e)].y << ' '
44.777 + << _arcColors[e].red() << ' '
44.778 + << _arcColors[e].green() << ' '
44.779 + << _arcColors[e].blue() << " arr\n";
44.780 + }
44.781 + else os << mycoords[g.source(e)].x << ' '
44.782 + << mycoords[g.source(e)].y << ' '
44.783 + << mycoords[g.target(e)].x << ' '
44.784 + << mycoords[g.target(e)].y << ' '
44.785 + << _arcColors[e].red() << ' '
44.786 + << _arcColors[e].green() << ' '
44.787 + << _arcColors[e].blue() << ' '
44.788 + << _arcWidths[e]*_arcWidthScale << " l\n";
44.789 + }
44.790 os << "grestore\n";
44.791 }
44.792 if(_showNodes) {
44.793 os << "%Nodes:\ngsave\n";
44.794 for(NodeIt n(g);n!=INVALID;++n) {
44.795 - os << mycoords[n].x << ' ' << mycoords[n].y << ' '
44.796 - << _nodeSizes[n]*_nodeScale << ' '
44.797 - << _nodeColors[n].red() << ' '
44.798 - << _nodeColors[n].green() << ' '
44.799 - << _nodeColors[n].blue() << ' ';
44.800 - switch(_nodeShapes[n]) {
44.801 - case CIRCLE:
44.802 - os<< "nc";break;
44.803 - case SQUARE:
44.804 - os<< "nsq";break;
44.805 - case DIAMOND:
44.806 - os<< "ndi";break;
44.807 - case MALE:
44.808 - os<< "nmale";break;
44.809 - case FEMALE:
44.810 - os<< "nfemale";break;
44.811 - }
44.812 - os<<'\n';
44.813 + os << mycoords[n].x << ' ' << mycoords[n].y << ' '
44.814 + << _nodeSizes[n]*_nodeScale << ' '
44.815 + << _nodeColors[n].red() << ' '
44.816 + << _nodeColors[n].green() << ' '
44.817 + << _nodeColors[n].blue() << ' ';
44.818 + switch(_nodeShapes[n]) {
44.819 + case CIRCLE:
44.820 + os<< "nc";break;
44.821 + case SQUARE:
44.822 + os<< "nsq";break;
44.823 + case DIAMOND:
44.824 + os<< "ndi";break;
44.825 + case MALE:
44.826 + os<< "nmale";break;
44.827 + case FEMALE:
44.828 + os<< "nfemale";break;
44.829 + }
44.830 + os<<'\n';
44.831 }
44.832 os << "grestore\n";
44.833 }
44.834 @@ -1034,32 +1034,32 @@
44.835 os << "/fosi " << _nodeTextSize << " def\n";
44.836 os << "(Helvetica) findfont fosi scalefont setfont\n";
44.837 for(NodeIt n(g);n!=INVALID;++n) {
44.838 - switch(_nodeTextColorType) {
44.839 - case DIST_COL:
44.840 - os << psOut(distantColor(_nodeColors[n])) << " setrgbcolor\n";
44.841 - break;
44.842 - case DIST_BW:
44.843 - os << psOut(distantBW(_nodeColors[n])) << " setrgbcolor\n";
44.844 - break;
44.845 - case CUST_COL:
44.846 - os << psOut(distantColor(_nodeTextColors[n])) << " setrgbcolor\n";
44.847 - break;
44.848 - default:
44.849 - os << "0 0 0 setrgbcolor\n";
44.850 - }
44.851 - os << mycoords[n].x << ' ' << mycoords[n].y
44.852 - << " (" << _nodeTexts[n] << ") cshow\n";
44.853 + switch(_nodeTextColorType) {
44.854 + case DIST_COL:
44.855 + os << psOut(distantColor(_nodeColors[n])) << " setrgbcolor\n";
44.856 + break;
44.857 + case DIST_BW:
44.858 + os << psOut(distantBW(_nodeColors[n])) << " setrgbcolor\n";
44.859 + break;
44.860 + case CUST_COL:
44.861 + os << psOut(distantColor(_nodeTextColors[n])) << " setrgbcolor\n";
44.862 + break;
44.863 + default:
44.864 + os << "0 0 0 setrgbcolor\n";
44.865 + }
44.866 + os << mycoords[n].x << ' ' << mycoords[n].y
44.867 + << " (" << _nodeTexts[n] << ") cshow\n";
44.868 }
44.869 os << "grestore\n";
44.870 }
44.871 if(_showNodePsText) {
44.872 os << "%Node PS blocks:\ngsave\n";
44.873 for(NodeIt n(g);n!=INVALID;++n)
44.874 - os << mycoords[n].x << ' ' << mycoords[n].y
44.875 - << " moveto\n" << _nodePsTexts[n] << "\n";
44.876 + os << mycoords[n].x << ' ' << mycoords[n].y
44.877 + << " moveto\n" << _nodePsTexts[n] << "\n";
44.878 os << "grestore\n";
44.879 }
44.880 -
44.881 +
44.882 os << "grestore\nshowpage\n";
44.883
44.884 //CleanUp:
44.885 @@ -1092,16 +1092,16 @@
44.886 {
44.887 return autoArcWidthScale(b);
44.888 }
44.889 -
44.890 +
44.891 ///An alias for absoluteArcWidths()
44.892 GraphToEps<T> &absoluteEdgeWidths(bool b=true)
44.893 {
44.894 return absoluteArcWidths(b);
44.895 }
44.896 -
44.897 +
44.898 ///An alias for parArcDist()
44.899 GraphToEps<T> &parEdgeDist(double d) {return parArcDist(d);}
44.900 -
44.901 +
44.902 ///An alias for hideArcs()
44.903 GraphToEps<T> &hideEdges(bool b=true) {return hideArcs(b);}
44.904
44.905 @@ -1143,13 +1143,13 @@
44.906 ///\sa GraphToEps
44.907 ///\sa graphToEps(G &g, const char *file_name)
44.908 template<class G>
44.909 -GraphToEps<DefaultGraphToEpsTraits<G> >
44.910 +GraphToEps<DefaultGraphToEpsTraits<G> >
44.911 graphToEps(G &g, std::ostream& os=std::cout)
44.912 {
44.913 - return
44.914 + return
44.915 GraphToEps<DefaultGraphToEpsTraits<G> >(DefaultGraphToEpsTraits<G>(g,os));
44.916 }
44.917 -
44.918 +
44.919 ///Generates an EPS file from a graph
44.920
44.921 ///\ingroup eps_io
44.922 @@ -1159,7 +1159,7 @@
44.923 ///instead of a stream.
44.924 ///\sa graphToEps(G &g, std::ostream& os)
44.925 template<class G>
44.926 -GraphToEps<DefaultGraphToEpsTraits<G> >
44.927 +GraphToEps<DefaultGraphToEpsTraits<G> >
44.928 graphToEps(G &g,const char *file_name)
44.929 {
44.930 return GraphToEps<DefaultGraphToEpsTraits<G> >
44.931 @@ -1175,7 +1175,7 @@
44.932 ///instead of a stream.
44.933 ///\sa graphToEps(G &g, std::ostream& os)
44.934 template<class G>
44.935 -GraphToEps<DefaultGraphToEpsTraits<G> >
44.936 +GraphToEps<DefaultGraphToEpsTraits<G> >
44.937 graphToEps(G &g,const std::string& file_name)
44.938 {
44.939 return GraphToEps<DefaultGraphToEpsTraits<G> >
45.1 --- a/lemon/graph_utils.h Sun Jul 13 16:46:56 2008 +0100
45.2 +++ b/lemon/graph_utils.h Sun Jul 13 19:51:02 2008 +0100
45.3 @@ -1,6 +1,6 @@
45.4 -/* -*- C++ -*-
45.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
45.6 *
45.7 - * This file is a part of LEMON, a generic C++ optimization library
45.8 + * This file is a part of LEMON, a generic C++ optimization library.
45.9 *
45.10 * Copyright (C) 2003-2008
45.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
45.12 @@ -46,24 +46,24 @@
45.13
45.14 ///This \c \#define creates convenience typedefs for the following types
45.15 ///of \c Digraph: \c Node, \c NodeIt, \c Arc, \c ArcIt, \c InArcIt,
45.16 - ///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap,
45.17 + ///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap,
45.18 ///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap.
45.19 ///
45.20 ///\note If the graph type is a dependent type, ie. the graph type depend
45.21 ///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS()
45.22 ///macro.
45.23 -#define DIGRAPH_TYPEDEFS(Digraph) \
45.24 - typedef Digraph::Node Node; \
45.25 - typedef Digraph::NodeIt NodeIt; \
45.26 - typedef Digraph::Arc Arc; \
45.27 - typedef Digraph::ArcIt ArcIt; \
45.28 - typedef Digraph::InArcIt InArcIt; \
45.29 - typedef Digraph::OutArcIt OutArcIt; \
45.30 - typedef Digraph::NodeMap<bool> BoolNodeMap; \
45.31 - typedef Digraph::NodeMap<int> IntNodeMap; \
45.32 - typedef Digraph::NodeMap<double> DoubleNodeMap; \
45.33 - typedef Digraph::ArcMap<bool> BoolArcMap; \
45.34 - typedef Digraph::ArcMap<int> IntArcMap; \
45.35 +#define DIGRAPH_TYPEDEFS(Digraph) \
45.36 + typedef Digraph::Node Node; \
45.37 + typedef Digraph::NodeIt NodeIt; \
45.38 + typedef Digraph::Arc Arc; \
45.39 + typedef Digraph::ArcIt ArcIt; \
45.40 + typedef Digraph::InArcIt InArcIt; \
45.41 + typedef Digraph::OutArcIt OutArcIt; \
45.42 + typedef Digraph::NodeMap<bool> BoolNodeMap; \
45.43 + typedef Digraph::NodeMap<int> IntNodeMap; \
45.44 + typedef Digraph::NodeMap<double> DoubleNodeMap; \
45.45 + typedef Digraph::ArcMap<bool> BoolArcMap; \
45.46 + typedef Digraph::ArcMap<int> IntArcMap; \
45.47 typedef Digraph::ArcMap<double> DoubleArcMap
45.48
45.49 ///Creates convenience typedefs for the digraph types and iterators
45.50 @@ -72,20 +72,20 @@
45.51 ///
45.52 ///\note Use this macro, if the graph type is a dependent type,
45.53 ///ie. the graph type depend on a template parameter.
45.54 -#define TEMPLATE_DIGRAPH_TYPEDEFS(Digraph) \
45.55 - typedef typename Digraph::Node Node; \
45.56 - typedef typename Digraph::NodeIt NodeIt; \
45.57 - typedef typename Digraph::Arc Arc; \
45.58 - typedef typename Digraph::ArcIt ArcIt; \
45.59 - typedef typename Digraph::InArcIt InArcIt; \
45.60 - typedef typename Digraph::OutArcIt OutArcIt; \
45.61 - typedef typename Digraph::template NodeMap<bool> BoolNodeMap; \
45.62 - typedef typename Digraph::template NodeMap<int> IntNodeMap; \
45.63 - typedef typename Digraph::template NodeMap<double> DoubleNodeMap; \
45.64 - typedef typename Digraph::template ArcMap<bool> BoolArcMap; \
45.65 - typedef typename Digraph::template ArcMap<int> IntArcMap; \
45.66 +#define TEMPLATE_DIGRAPH_TYPEDEFS(Digraph) \
45.67 + typedef typename Digraph::Node Node; \
45.68 + typedef typename Digraph::NodeIt NodeIt; \
45.69 + typedef typename Digraph::Arc Arc; \
45.70 + typedef typename Digraph::ArcIt ArcIt; \
45.71 + typedef typename Digraph::InArcIt InArcIt; \
45.72 + typedef typename Digraph::OutArcIt OutArcIt; \
45.73 + typedef typename Digraph::template NodeMap<bool> BoolNodeMap; \
45.74 + typedef typename Digraph::template NodeMap<int> IntNodeMap; \
45.75 + typedef typename Digraph::template NodeMap<double> DoubleNodeMap; \
45.76 + typedef typename Digraph::template ArcMap<bool> BoolArcMap; \
45.77 + typedef typename Digraph::template ArcMap<int> IntArcMap; \
45.78 typedef typename Digraph::template ArcMap<double> DoubleArcMap
45.79 -
45.80 +
45.81 ///Creates convenience typedefs for the graph types and iterators
45.82
45.83 ///This \c \#define creates the same convenience typedefs as defined
45.84 @@ -96,13 +96,13 @@
45.85 ///\note If the graph type is a dependent type, ie. the graph type depend
45.86 ///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS()
45.87 ///macro.
45.88 -#define GRAPH_TYPEDEFS(Graph) \
45.89 - DIGRAPH_TYPEDEFS(Graph); \
45.90 - typedef Graph::Edge Edge; \
45.91 - typedef Graph::EdgeIt EdgeIt; \
45.92 - typedef Graph::IncEdgeIt IncEdgeIt; \
45.93 - typedef Graph::EdgeMap<bool> BoolEdgeMap; \
45.94 - typedef Graph::EdgeMap<int> IntEdgeMap; \
45.95 +#define GRAPH_TYPEDEFS(Graph) \
45.96 + DIGRAPH_TYPEDEFS(Graph); \
45.97 + typedef Graph::Edge Edge; \
45.98 + typedef Graph::EdgeIt EdgeIt; \
45.99 + typedef Graph::IncEdgeIt IncEdgeIt; \
45.100 + typedef Graph::EdgeMap<bool> BoolEdgeMap; \
45.101 + typedef Graph::EdgeMap<int> IntEdgeMap; \
45.102 typedef Graph::EdgeMap<double> DoubleEdgeMap
45.103
45.104 ///Creates convenience typedefs for the graph types and iterators
45.105 @@ -111,13 +111,13 @@
45.106 ///
45.107 ///\note Use this macro, if the graph type is a dependent type,
45.108 ///ie. the graph type depend on a template parameter.
45.109 -#define TEMPLATE_GRAPH_TYPEDEFS(Graph) \
45.110 - TEMPLATE_DIGRAPH_TYPEDEFS(Graph); \
45.111 - typedef typename Graph::Edge Edge; \
45.112 - typedef typename Graph::EdgeIt EdgeIt; \
45.113 - typedef typename Graph::IncEdgeIt IncEdgeIt; \
45.114 - typedef typename Graph::template EdgeMap<bool> BoolEdgeMap; \
45.115 - typedef typename Graph::template EdgeMap<int> IntEdgeMap; \
45.116 +#define TEMPLATE_GRAPH_TYPEDEFS(Graph) \
45.117 + TEMPLATE_DIGRAPH_TYPEDEFS(Graph); \
45.118 + typedef typename Graph::Edge Edge; \
45.119 + typedef typename Graph::EdgeIt EdgeIt; \
45.120 + typedef typename Graph::IncEdgeIt IncEdgeIt; \
45.121 + typedef typename Graph::template EdgeMap<bool> BoolEdgeMap; \
45.122 + typedef typename Graph::template EdgeMap<int> IntEdgeMap; \
45.123 typedef typename Graph::template EdgeMap<double> DoubleEdgeMap
45.124
45.125 /// \brief Function to count the items in the graph.
45.126 @@ -138,7 +138,7 @@
45.127 // Node counting:
45.128
45.129 namespace _graph_utils_bits {
45.130 -
45.131 +
45.132 template <typename Graph, typename Enable = void>
45.133 struct CountNodesSelector {
45.134 static int count(const Graph &g) {
45.135 @@ -148,13 +148,13 @@
45.136
45.137 template <typename Graph>
45.138 struct CountNodesSelector<
45.139 - Graph, typename
45.140 - enable_if<typename Graph::NodeNumTag, void>::type>
45.141 + Graph, typename
45.142 + enable_if<typename Graph::NodeNumTag, void>::type>
45.143 {
45.144 static int count(const Graph &g) {
45.145 return g.nodeNum();
45.146 }
45.147 - };
45.148 + };
45.149 }
45.150
45.151 /// \brief Function to count the nodes in the graph.
45.152 @@ -163,7 +163,7 @@
45.153 /// The complexity of the function is O(n) but for some
45.154 /// graph structures it is specialized to run in O(1).
45.155 ///
45.156 - /// If the graph contains a \e nodeNum() member function and a
45.157 + /// If the graph contains a \e nodeNum() member function and a
45.158 /// \e NodeNumTag tag then this function calls directly the member
45.159 /// function to query the cardinality of the node set.
45.160 template <typename Graph>
45.161 @@ -174,7 +174,7 @@
45.162 // Arc counting:
45.163
45.164 namespace _graph_utils_bits {
45.165 -
45.166 +
45.167 template <typename Graph, typename Enable = void>
45.168 struct CountArcsSelector {
45.169 static int count(const Graph &g) {
45.170 @@ -184,13 +184,13 @@
45.171
45.172 template <typename Graph>
45.173 struct CountArcsSelector<
45.174 - Graph,
45.175 - typename enable_if<typename Graph::ArcNumTag, void>::type>
45.176 + Graph,
45.177 + typename enable_if<typename Graph::ArcNumTag, void>::type>
45.178 {
45.179 static int count(const Graph &g) {
45.180 return g.arcNum();
45.181 }
45.182 - };
45.183 + };
45.184 }
45.185
45.186 /// \brief Function to count the arcs in the graph.
45.187 @@ -199,7 +199,7 @@
45.188 /// The complexity of the function is O(e) but for some
45.189 /// graph structures it is specialized to run in O(1).
45.190 ///
45.191 - /// If the graph contains a \e arcNum() member function and a
45.192 + /// If the graph contains a \e arcNum() member function and a
45.193 /// \e EdgeNumTag tag then this function calls directly the member
45.194 /// function to query the cardinality of the arc set.
45.195 template <typename Graph>
45.196 @@ -209,7 +209,7 @@
45.197
45.198 // Edge counting:
45.199 namespace _graph_utils_bits {
45.200 -
45.201 +
45.202 template <typename Graph, typename Enable = void>
45.203 struct CountEdgesSelector {
45.204 static int count(const Graph &g) {
45.205 @@ -219,13 +219,13 @@
45.206
45.207 template <typename Graph>
45.208 struct CountEdgesSelector<
45.209 - Graph,
45.210 - typename enable_if<typename Graph::EdgeNumTag, void>::type>
45.211 + Graph,
45.212 + typename enable_if<typename Graph::EdgeNumTag, void>::type>
45.213 {
45.214 static int count(const Graph &g) {
45.215 return g.edgeNum();
45.216 }
45.217 - };
45.218 + };
45.219 }
45.220
45.221 /// \brief Function to count the edges in the graph.
45.222 @@ -234,7 +234,7 @@
45.223 /// The complexity of the function is O(m) but for some
45.224 /// graph structures it is specialized to run in O(1).
45.225 ///
45.226 - /// If the graph contains a \e edgeNum() member function and a
45.227 + /// If the graph contains a \e edgeNum() member function and a
45.228 /// \e EdgeNumTag tag then this function calls directly the member
45.229 /// function to query the cardinality of the edge set.
45.230 template <typename Graph>
45.231 @@ -256,7 +256,7 @@
45.232 /// \brief Function to count the number of the out-arcs from node \c n.
45.233 ///
45.234 /// This function counts the number of the out-arcs from node \c n
45.235 - /// in the graph.
45.236 + /// in the graph.
45.237 template <typename Graph>
45.238 inline int countOutArcs(const Graph& _g, const typename Graph::Node& _n) {
45.239 return countNodeDegree<Graph, typename Graph::OutArcIt>(_g, _n);
45.240 @@ -265,7 +265,7 @@
45.241 /// \brief Function to count the number of the in-arcs to node \c n.
45.242 ///
45.243 /// This function counts the number of the in-arcs to node \c n
45.244 - /// in the graph.
45.245 + /// in the graph.
45.246 template <typename Graph>
45.247 inline int countInArcs(const Graph& _g, const typename Graph::Node& _n) {
45.248 return countNodeDegree<Graph, typename Graph::InArcIt>(_g, _n);
45.249 @@ -274,14 +274,14 @@
45.250 /// \brief Function to count the number of the inc-edges to node \c n.
45.251 ///
45.252 /// This function counts the number of the inc-edges to node \c n
45.253 - /// in the graph.
45.254 + /// in the graph.
45.255 template <typename Graph>
45.256 inline int countIncEdges(const Graph& _g, const typename Graph::Node& _n) {
45.257 return countNodeDegree<Graph, typename Graph::IncEdgeIt>(_g, _n);
45.258 }
45.259
45.260 namespace _graph_utils_bits {
45.261 -
45.262 +
45.263 template <typename Graph, typename Enable = void>
45.264 struct FindArcSelector {
45.265 typedef typename Graph::Node Node;
45.266 @@ -301,15 +301,15 @@
45.267
45.268 template <typename Graph>
45.269 struct FindArcSelector<
45.270 - Graph,
45.271 - typename enable_if<typename Graph::FindEdgeTag, void>::type>
45.272 + Graph,
45.273 + typename enable_if<typename Graph::FindEdgeTag, void>::type>
45.274 {
45.275 typedef typename Graph::Node Node;
45.276 typedef typename Graph::Arc Arc;
45.277 static Arc find(const Graph &g, Node u, Node v, Arc prev) {
45.278 return g.findArc(u, v, prev);
45.279 }
45.280 - };
45.281 + };
45.282 }
45.283
45.284 /// \brief Finds an arc between two nodes of a graph.
45.285 @@ -333,7 +333,7 @@
45.286 ///\sa DynArcLookUp
45.287 ///\sa ConArcIt
45.288 template <typename Graph>
45.289 - inline typename Graph::Arc
45.290 + inline typename Graph::Arc
45.291 findArc(const Graph &g, typename Graph::Node u, typename Graph::Node v,
45.292 typename Graph::Arc prev = INVALID) {
45.293 return _graph_utils_bits::FindArcSelector<Graph>::find(g, u, v, prev);
45.294 @@ -341,7 +341,7 @@
45.295
45.296 /// \brief Iterator for iterating on arcs connected the same nodes.
45.297 ///
45.298 - /// Iterator for iterating on arcs connected the same nodes. It is
45.299 + /// Iterator for iterating on arcs connected the same nodes. It is
45.300 /// higher level interface for the findArc() function. You can
45.301 /// use it the following way:
45.302 ///\code
45.303 @@ -349,7 +349,7 @@
45.304 /// ...
45.305 /// }
45.306 ///\endcode
45.307 - ///
45.308 + ///
45.309 ///\sa findArc()
45.310 ///\sa ArcLookUp
45.311 ///\sa AllArcLookUp
45.312 @@ -374,16 +374,16 @@
45.313
45.314 /// \brief Constructor.
45.315 ///
45.316 - /// Construct a new ConArcIt which continues the iterating from
45.317 + /// Construct a new ConArcIt which continues the iterating from
45.318 /// the \c e arc.
45.319 ConArcIt(const Graph& g, Arc a) : Parent(a), _graph(g) {}
45.320 -
45.321 +
45.322 /// \brief Increment operator.
45.323 ///
45.324 /// It increments the iterator and gives back the next arc.
45.325 ConArcIt& operator++() {
45.326 - Parent::operator=(findArc(_graph, _graph.source(*this),
45.327 - _graph.target(*this), *this));
45.328 + Parent::operator=(findArc(_graph, _graph.source(*this),
45.329 + _graph.target(*this), *this));
45.330 return *this;
45.331 }
45.332 private:
45.333 @@ -391,7 +391,7 @@
45.334 };
45.335
45.336 namespace _graph_utils_bits {
45.337 -
45.338 +
45.339 template <typename Graph, typename Enable = void>
45.340 struct FindEdgeSelector {
45.341 typedef typename Graph::Node Node;
45.342 @@ -425,15 +425,15 @@
45.343
45.344 template <typename Graph>
45.345 struct FindEdgeSelector<
45.346 - Graph,
45.347 - typename enable_if<typename Graph::FindEdgeTag, void>::type>
45.348 + Graph,
45.349 + typename enable_if<typename Graph::FindEdgeTag, void>::type>
45.350 {
45.351 typedef typename Graph::Node Node;
45.352 typedef typename Graph::Edge Edge;
45.353 static Edge find(const Graph &g, Node u, Node v, Edge prev) {
45.354 return g.findEdge(u, v, prev);
45.355 }
45.356 - };
45.357 + };
45.358 }
45.359
45.360 /// \brief Finds an edge between two nodes of a graph.
45.361 @@ -449,7 +449,7 @@
45.362 ///
45.363 /// Thus you can iterate through each arc from \c u to \c v as it follows.
45.364 ///\code
45.365 - /// for(Edge e = findEdge(g,u,v); e != INVALID;
45.366 + /// for(Edge e = findEdge(g,u,v); e != INVALID;
45.367 /// e = findEdge(g,u,v,e)) {
45.368 /// ...
45.369 /// }
45.370 @@ -458,7 +458,7 @@
45.371 ///\sa ConEdgeIt
45.372
45.373 template <typename Graph>
45.374 - inline typename Graph::Edge
45.375 + inline typename Graph::Edge
45.376 findEdge(const Graph &g, typename Graph::Node u, typename Graph::Node v,
45.377 typename Graph::Edge p = INVALID) {
45.378 return _graph_utils_bits::FindEdgeSelector<Graph>::find(g, u, v, p);
45.379 @@ -466,7 +466,7 @@
45.380
45.381 /// \brief Iterator for iterating on edges connected the same nodes.
45.382 ///
45.383 - /// Iterator for iterating on edges connected the same nodes. It is
45.384 + /// Iterator for iterating on edges connected the same nodes. It is
45.385 /// higher level interface for the findEdge() function. You can
45.386 /// use it the following way:
45.387 ///\code
45.388 @@ -496,16 +496,16 @@
45.389
45.390 /// \brief Constructor.
45.391 ///
45.392 - /// Construct a new ConEdgeIt which continues the iterating from
45.393 + /// Construct a new ConEdgeIt which continues the iterating from
45.394 /// the \c e edge.
45.395 ConEdgeIt(const Graph& g, Edge e) : Parent(e), _graph(g) {}
45.396 -
45.397 +
45.398 /// \brief Increment operator.
45.399 ///
45.400 /// It increments the iterator and gives back the next edge.
45.401 ConEdgeIt& operator++() {
45.402 - Parent::operator=(findEdge(_graph, _graph.u(*this),
45.403 - _graph.v(*this), *this));
45.404 + Parent::operator=(findEdge(_graph, _graph.u(*this),
45.405 + _graph.v(*this), *this));
45.406 return *this;
45.407 }
45.408 private:
45.409 @@ -518,18 +518,18 @@
45.410 class MapCopyBase {
45.411 public:
45.412 virtual void copy(const Digraph& from, const RefMap& refMap) = 0;
45.413 -
45.414 +
45.415 virtual ~MapCopyBase() {}
45.416 };
45.417
45.418 - template <typename Digraph, typename Item, typename RefMap,
45.419 + template <typename Digraph, typename Item, typename RefMap,
45.420 typename ToMap, typename FromMap>
45.421 class MapCopy : public MapCopyBase<Digraph, Item, RefMap> {
45.422 public:
45.423
45.424 - MapCopy(ToMap& tmap, const FromMap& map)
45.425 + MapCopy(ToMap& tmap, const FromMap& map)
45.426 : _tmap(tmap), _map(map) {}
45.427 -
45.428 +
45.429 virtual void copy(const Digraph& digraph, const RefMap& refMap) {
45.430 typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
45.431 for (ItemIt it(digraph); it != INVALID; ++it) {
45.432 @@ -547,7 +547,7 @@
45.433 public:
45.434
45.435 ItemCopy(It& it, const Item& item) : _it(it), _item(item) {}
45.436 -
45.437 +
45.438 virtual void copy(const Digraph&, const RefMap& refMap) {
45.439 _it = refMap[_item];
45.440 }
45.441 @@ -562,7 +562,7 @@
45.442 public:
45.443
45.444 RefCopy(Ref& map) : _map(map) {}
45.445 -
45.446 +
45.447 virtual void copy(const Digraph& digraph, const RefMap& refMap) {
45.448 typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
45.449 for (ItemIt it(digraph); it != INVALID; ++it) {
45.450 @@ -574,13 +574,13 @@
45.451 Ref& _map;
45.452 };
45.453
45.454 - template <typename Digraph, typename Item, typename RefMap,
45.455 + template <typename Digraph, typename Item, typename RefMap,
45.456 typename CrossRef>
45.457 class CrossRefCopy : public MapCopyBase<Digraph, Item, RefMap> {
45.458 public:
45.459
45.460 CrossRefCopy(CrossRef& cmap) : _cmap(cmap) {}
45.461 -
45.462 +
45.463 virtual void copy(const Digraph& digraph, const RefMap& refMap) {
45.464 typedef typename ItemSetTraits<Digraph, Item>::ItemIt ItemIt;
45.465 for (ItemIt it(digraph); it != INVALID; ++it) {
45.466 @@ -601,16 +601,16 @@
45.467 nodeRefMap[it] = to.addNode();
45.468 }
45.469 for (typename From::ArcIt it(from); it != INVALID; ++it) {
45.470 - arcRefMap[it] = to.addArc(nodeRefMap[from.source(it)],
45.471 - nodeRefMap[from.target(it)]);
45.472 + arcRefMap[it] = to.addArc(nodeRefMap[from.source(it)],
45.473 + nodeRefMap[from.target(it)]);
45.474 }
45.475 }
45.476 };
45.477
45.478 template <typename Digraph>
45.479 struct DigraphCopySelector<
45.480 - Digraph,
45.481 - typename enable_if<typename Digraph::BuildTag, void>::type>
45.482 + Digraph,
45.483 + typename enable_if<typename Digraph::BuildTag, void>::type>
45.484 {
45.485 template <typename From, typename NodeRefMap, typename ArcRefMap>
45.486 static void copy(Digraph &to, const From& from,
45.487 @@ -628,16 +628,16 @@
45.488 nodeRefMap[it] = to.addNode();
45.489 }
45.490 for (typename From::EdgeIt it(from); it != INVALID; ++it) {
45.491 - edgeRefMap[it] = to.addEdge(nodeRefMap[from.u(it)],
45.492 - nodeRefMap[from.v(it)]);
45.493 + edgeRefMap[it] = to.addEdge(nodeRefMap[from.u(it)],
45.494 + nodeRefMap[from.v(it)]);
45.495 }
45.496 }
45.497 };
45.498
45.499 template <typename Graph>
45.500 struct GraphCopySelector<
45.501 - Graph,
45.502 - typename enable_if<typename Graph::BuildTag, void>::type>
45.503 + Graph,
45.504 + typename enable_if<typename Graph::BuildTag, void>::type>
45.505 {
45.506 template <typename From, typename NodeRefMap, typename EdgeRefMap>
45.507 static void copy(Graph &to, const From& from,
45.508 @@ -697,16 +697,16 @@
45.509
45.510 typedef typename From::template NodeMap<TNode> NodeRefMap;
45.511 typedef typename From::template ArcMap<TArc> ArcRefMap;
45.512 -
45.513 -
45.514 - public:
45.515 +
45.516 +
45.517 + public:
45.518
45.519
45.520 /// \brief Constructor for the DigraphCopy.
45.521 ///
45.522 /// It copies the content of the \c _from digraph into the
45.523 /// \c _to digraph.
45.524 - DigraphCopy(To& to, const From& from)
45.525 + DigraphCopy(To& to, const From& from)
45.526 : _from(from), _to(to) {}
45.527
45.528 /// \brief Destructor of the DigraphCopy
45.529 @@ -730,8 +730,8 @@
45.530 /// destination graph.
45.531 template <typename NodeRef>
45.532 DigraphCopy& nodeRef(NodeRef& map) {
45.533 - _node_maps.push_back(new _graph_utils_bits::RefCopy<From, Node,
45.534 - NodeRefMap, NodeRef>(map));
45.535 + _node_maps.push_back(new _graph_utils_bits::RefCopy<From, Node,
45.536 + NodeRefMap, NodeRef>(map));
45.537 return *this;
45.538 }
45.539
45.540 @@ -744,7 +744,7 @@
45.541 template <typename NodeCrossRef>
45.542 DigraphCopy& nodeCrossRef(NodeCrossRef& map) {
45.543 _node_maps.push_back(new _graph_utils_bits::CrossRefCopy<From, Node,
45.544 - NodeRefMap, NodeCrossRef>(map));
45.545 + NodeRefMap, NodeCrossRef>(map));
45.546 return *this;
45.547 }
45.548
45.549 @@ -755,8 +755,8 @@
45.550 /// and the copied map's key type is the source graph's node type.
45.551 template <typename ToMap, typename FromMap>
45.552 DigraphCopy& nodeMap(ToMap& tmap, const FromMap& map) {
45.553 - _node_maps.push_back(new _graph_utils_bits::MapCopy<From, Node,
45.554 - NodeRefMap, ToMap, FromMap>(tmap, map));
45.555 + _node_maps.push_back(new _graph_utils_bits::MapCopy<From, Node,
45.556 + NodeRefMap, ToMap, FromMap>(tmap, map));
45.557 return *this;
45.558 }
45.559
45.560 @@ -764,8 +764,8 @@
45.561 ///
45.562 /// Make a copy of the given node.
45.563 DigraphCopy& node(TNode& tnode, const Node& snode) {
45.564 - _node_maps.push_back(new _graph_utils_bits::ItemCopy<From, Node,
45.565 - NodeRefMap, TNode>(tnode, snode));
45.566 + _node_maps.push_back(new _graph_utils_bits::ItemCopy<From, Node,
45.567 + NodeRefMap, TNode>(tnode, snode));
45.568 return *this;
45.569 }
45.570
45.571 @@ -774,8 +774,8 @@
45.572 /// Copies the arc references into the given map.
45.573 template <typename ArcRef>
45.574 DigraphCopy& arcRef(ArcRef& map) {
45.575 - _arc_maps.push_back(new _graph_utils_bits::RefCopy<From, Arc,
45.576 - ArcRefMap, ArcRef>(map));
45.577 + _arc_maps.push_back(new _graph_utils_bits::RefCopy<From, Arc,
45.578 + ArcRefMap, ArcRef>(map));
45.579 return *this;
45.580 }
45.581
45.582 @@ -786,20 +786,20 @@
45.583 template <typename ArcCrossRef>
45.584 DigraphCopy& arcCrossRef(ArcCrossRef& map) {
45.585 _arc_maps.push_back(new _graph_utils_bits::CrossRefCopy<From, Arc,
45.586 - ArcRefMap, ArcCrossRef>(map));
45.587 + ArcRefMap, ArcCrossRef>(map));
45.588 return *this;
45.589 }
45.590
45.591 /// \brief Make copy of the given map.
45.592 ///
45.593 - /// Makes copy of the given map for the newly created digraph.
45.594 + /// Makes copy of the given map for the newly created digraph.
45.595 /// The new map's key type is the to digraph's arc type,
45.596 /// and the copied map's key type is the from digraph's arc
45.597 - /// type.
45.598 + /// type.
45.599 template <typename ToMap, typename FromMap>
45.600 DigraphCopy& arcMap(ToMap& tmap, const FromMap& map) {
45.601 - _arc_maps.push_back(new _graph_utils_bits::MapCopy<From, Arc,
45.602 - ArcRefMap, ToMap, FromMap>(tmap, map));
45.603 + _arc_maps.push_back(new _graph_utils_bits::MapCopy<From, Arc,
45.604 + ArcRefMap, ToMap, FromMap>(tmap, map));
45.605 return *this;
45.606 }
45.607
45.608 @@ -807,8 +807,8 @@
45.609 ///
45.610 /// Make a copy of the given arc.
45.611 DigraphCopy& arc(TArc& tarc, const Arc& sarc) {
45.612 - _arc_maps.push_back(new _graph_utils_bits::ItemCopy<From, Arc,
45.613 - ArcRefMap, TArc>(tarc, sarc));
45.614 + _arc_maps.push_back(new _graph_utils_bits::ItemCopy<From, Arc,
45.615 + ArcRefMap, TArc>(tarc, sarc));
45.616 return *this;
45.617 }
45.618
45.619 @@ -825,7 +825,7 @@
45.620 }
45.621 for (int i = 0; i < int(_arc_maps.size()); ++i) {
45.622 _arc_maps[i]->copy(_from, arcRefMap);
45.623 - }
45.624 + }
45.625 }
45.626
45.627 protected:
45.628 @@ -834,10 +834,10 @@
45.629 const From& _from;
45.630 To& _to;
45.631
45.632 - std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* >
45.633 + std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* >
45.634 _node_maps;
45.635
45.636 - std::vector<_graph_utils_bits::MapCopyBase<From, Arc, ArcRefMap>* >
45.637 + std::vector<_graph_utils_bits::MapCopyBase<From, Arc, ArcRefMap>* >
45.638 _arc_maps;
45.639
45.640 };
45.641 @@ -850,13 +850,13 @@
45.642 ///\code
45.643 /// copyDigraph(trg, src).nodeRef(nr).arcCrossRef(ecr).run();
45.644 ///\endcode
45.645 - ///
45.646 + ///
45.647 /// After the copy the \c nr map will contain the mapping from the
45.648 /// nodes of the \c from digraph to the nodes of the \c to digraph and
45.649 /// \c ecr will contain the mapping from the arcs of the \c to digraph
45.650 /// to the arcs of the \c from digraph.
45.651 ///
45.652 - /// \see DigraphCopy
45.653 + /// \see DigraphCopy
45.654 template <typename To, typename From>
45.655 DigraphCopy<To, From> copyDigraph(To& to, const From& from) {
45.656 return DigraphCopy<To, From>(to, from);
45.657 @@ -917,8 +917,8 @@
45.658
45.659 struct ArcRefMap {
45.660 ArcRefMap(const To& to, const From& from,
45.661 - const EdgeRefMap& edge_ref, const NodeRefMap& node_ref)
45.662 - : _to(to), _from(from),
45.663 + const EdgeRefMap& edge_ref, const NodeRefMap& node_ref)
45.664 + : _to(to), _from(from),
45.665 _edge_ref(edge_ref), _node_ref(node_ref) {}
45.666
45.667 typedef typename From::Arc Key;
45.668 @@ -926,27 +926,27 @@
45.669
45.670 Value operator[](const Key& key) const {
45.671 bool forward = _from.u(key) != _from.v(key) ?
45.672 - _node_ref[_from.source(key)] ==
45.673 - _to.source(_to.direct(_edge_ref[key], true)) :
45.674 - _from.direction(key);
45.675 - return _to.direct(_edge_ref[key], forward);
45.676 + _node_ref[_from.source(key)] ==
45.677 + _to.source(_to.direct(_edge_ref[key], true)) :
45.678 + _from.direction(key);
45.679 + return _to.direct(_edge_ref[key], forward);
45.680 }
45.681 -
45.682 +
45.683 const To& _to;
45.684 const From& _from;
45.685 const EdgeRefMap& _edge_ref;
45.686 const NodeRefMap& _node_ref;
45.687 };
45.688
45.689 -
45.690 - public:
45.691 +
45.692 + public:
45.693
45.694
45.695 /// \brief Constructor for the GraphCopy.
45.696 ///
45.697 /// It copies the content of the \c _from graph into the
45.698 /// \c _to graph.
45.699 - GraphCopy(To& to, const From& from)
45.700 + GraphCopy(To& to, const From& from)
45.701 : _from(from), _to(to) {}
45.702
45.703 /// \brief Destructor of the GraphCopy
45.704 @@ -970,8 +970,8 @@
45.705 /// Copies the node references into the given map.
45.706 template <typename NodeRef>
45.707 GraphCopy& nodeRef(NodeRef& map) {
45.708 - _node_maps.push_back(new _graph_utils_bits::RefCopy<From, Node,
45.709 - NodeRefMap, NodeRef>(map));
45.710 + _node_maps.push_back(new _graph_utils_bits::RefCopy<From, Node,
45.711 + NodeRefMap, NodeRef>(map));
45.712 return *this;
45.713 }
45.714
45.715 @@ -982,20 +982,20 @@
45.716 template <typename NodeCrossRef>
45.717 GraphCopy& nodeCrossRef(NodeCrossRef& map) {
45.718 _node_maps.push_back(new _graph_utils_bits::CrossRefCopy<From, Node,
45.719 - NodeRefMap, NodeCrossRef>(map));
45.720 + NodeRefMap, NodeCrossRef>(map));
45.721 return *this;
45.722 }
45.723
45.724 /// \brief Make copy of the given map.
45.725 ///
45.726 - /// Makes copy of the given map for the newly created graph.
45.727 + /// Makes copy of the given map for the newly created graph.
45.728 /// The new map's key type is the to graph's node type,
45.729 /// and the copied map's key type is the from graph's node
45.730 - /// type.
45.731 + /// type.
45.732 template <typename ToMap, typename FromMap>
45.733 GraphCopy& nodeMap(ToMap& tmap, const FromMap& map) {
45.734 - _node_maps.push_back(new _graph_utils_bits::MapCopy<From, Node,
45.735 - NodeRefMap, ToMap, FromMap>(tmap, map));
45.736 + _node_maps.push_back(new _graph_utils_bits::MapCopy<From, Node,
45.737 + NodeRefMap, ToMap, FromMap>(tmap, map));
45.738 return *this;
45.739 }
45.740
45.741 @@ -1003,8 +1003,8 @@
45.742 ///
45.743 /// Make a copy of the given node.
45.744 GraphCopy& node(TNode& tnode, const Node& snode) {
45.745 - _node_maps.push_back(new _graph_utils_bits::ItemCopy<From, Node,
45.746 - NodeRefMap, TNode>(tnode, snode));
45.747 + _node_maps.push_back(new _graph_utils_bits::ItemCopy<From, Node,
45.748 + NodeRefMap, TNode>(tnode, snode));
45.749 return *this;
45.750 }
45.751
45.752 @@ -1013,8 +1013,8 @@
45.753 /// Copies the arc references into the given map.
45.754 template <typename ArcRef>
45.755 GraphCopy& arcRef(ArcRef& map) {
45.756 - _arc_maps.push_back(new _graph_utils_bits::RefCopy<From, Arc,
45.757 - ArcRefMap, ArcRef>(map));
45.758 + _arc_maps.push_back(new _graph_utils_bits::RefCopy<From, Arc,
45.759 + ArcRefMap, ArcRef>(map));
45.760 return *this;
45.761 }
45.762
45.763 @@ -1025,20 +1025,20 @@
45.764 template <typename ArcCrossRef>
45.765 GraphCopy& arcCrossRef(ArcCrossRef& map) {
45.766 _arc_maps.push_back(new _graph_utils_bits::CrossRefCopy<From, Arc,
45.767 - ArcRefMap, ArcCrossRef>(map));
45.768 + ArcRefMap, ArcCrossRef>(map));
45.769 return *this;
45.770 }
45.771
45.772 /// \brief Make copy of the given map.
45.773 ///
45.774 - /// Makes copy of the given map for the newly created graph.
45.775 + /// Makes copy of the given map for the newly created graph.
45.776 /// The new map's key type is the to graph's arc type,
45.777 /// and the copied map's key type is the from graph's arc
45.778 - /// type.
45.779 + /// type.
45.780 template <typename ToMap, typename FromMap>
45.781 GraphCopy& arcMap(ToMap& tmap, const FromMap& map) {
45.782 - _arc_maps.push_back(new _graph_utils_bits::MapCopy<From, Arc,
45.783 - ArcRefMap, ToMap, FromMap>(tmap, map));
45.784 + _arc_maps.push_back(new _graph_utils_bits::MapCopy<From, Arc,
45.785 + ArcRefMap, ToMap, FromMap>(tmap, map));
45.786 return *this;
45.787 }
45.788
45.789 @@ -1046,8 +1046,8 @@
45.790 ///
45.791 /// Make a copy of the given arc.
45.792 GraphCopy& arc(TArc& tarc, const Arc& sarc) {
45.793 - _arc_maps.push_back(new _graph_utils_bits::ItemCopy<From, Arc,
45.794 - ArcRefMap, TArc>(tarc, sarc));
45.795 + _arc_maps.push_back(new _graph_utils_bits::ItemCopy<From, Arc,
45.796 + ArcRefMap, TArc>(tarc, sarc));
45.797 return *this;
45.798 }
45.799
45.800 @@ -1056,8 +1056,8 @@
45.801 /// Copies the edge references into the given map.
45.802 template <typename EdgeRef>
45.803 GraphCopy& edgeRef(EdgeRef& map) {
45.804 - _edge_maps.push_back(new _graph_utils_bits::RefCopy<From, Edge,
45.805 - EdgeRefMap, EdgeRef>(map));
45.806 + _edge_maps.push_back(new _graph_utils_bits::RefCopy<From, Edge,
45.807 + EdgeRefMap, EdgeRef>(map));
45.808 return *this;
45.809 }
45.810
45.811 @@ -1067,21 +1067,21 @@
45.812 /// references) into the given map.
45.813 template <typename EdgeCrossRef>
45.814 GraphCopy& edgeCrossRef(EdgeCrossRef& map) {
45.815 - _edge_maps.push_back(new _graph_utils_bits::CrossRefCopy<From,
45.816 - Edge, EdgeRefMap, EdgeCrossRef>(map));
45.817 + _edge_maps.push_back(new _graph_utils_bits::CrossRefCopy<From,
45.818 + Edge, EdgeRefMap, EdgeCrossRef>(map));
45.819 return *this;
45.820 }
45.821
45.822 /// \brief Make copy of the given map.
45.823 ///
45.824 - /// Makes copy of the given map for the newly created graph.
45.825 + /// Makes copy of the given map for the newly created graph.
45.826 /// The new map's key type is the to graph's edge type,
45.827 /// and the copied map's key type is the from graph's edge
45.828 - /// type.
45.829 + /// type.
45.830 template <typename ToMap, typename FromMap>
45.831 GraphCopy& edgeMap(ToMap& tmap, const FromMap& map) {
45.832 - _edge_maps.push_back(new _graph_utils_bits::MapCopy<From, Edge,
45.833 - EdgeRefMap, ToMap, FromMap>(tmap, map));
45.834 + _edge_maps.push_back(new _graph_utils_bits::MapCopy<From, Edge,
45.835 + EdgeRefMap, ToMap, FromMap>(tmap, map));
45.836 return *this;
45.837 }
45.838
45.839 @@ -1089,8 +1089,8 @@
45.840 ///
45.841 /// Make a copy of the given edge.
45.842 GraphCopy& edge(TEdge& tedge, const Edge& sedge) {
45.843 - _edge_maps.push_back(new _graph_utils_bits::ItemCopy<From, Edge,
45.844 - EdgeRefMap, TEdge>(tedge, sedge));
45.845 + _edge_maps.push_back(new _graph_utils_bits::ItemCopy<From, Edge,
45.846 + EdgeRefMap, TEdge>(tedge, sedge));
45.847 return *this;
45.848 }
45.849
45.850 @@ -1115,17 +1115,17 @@
45.851 }
45.852
45.853 private:
45.854 -
45.855 +
45.856 const From& _from;
45.857 To& _to;
45.858
45.859 - std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* >
45.860 + std::vector<_graph_utils_bits::MapCopyBase<From, Node, NodeRefMap>* >
45.861 _node_maps;
45.862
45.863 - std::vector<_graph_utils_bits::MapCopyBase<From, Arc, ArcRefMap>* >
45.864 + std::vector<_graph_utils_bits::MapCopyBase<From, Arc, ArcRefMap>* >
45.865 _arc_maps;
45.866
45.867 - std::vector<_graph_utils_bits::MapCopyBase<From, Edge, EdgeRefMap>* >
45.868 + std::vector<_graph_utils_bits::MapCopyBase<From, Edge, EdgeRefMap>* >
45.869 _edge_maps;
45.870
45.871 };
45.872 @@ -1138,15 +1138,15 @@
45.873 ///\code
45.874 /// copyGraph(trg, src).nodeRef(nr).arcCrossRef(ecr).run();
45.875 ///\endcode
45.876 - ///
45.877 + ///
45.878 /// After the copy the \c nr map will contain the mapping from the
45.879 /// nodes of the \c from graph to the nodes of the \c to graph and
45.880 /// \c ecr will contain the mapping from the arcs of the \c to graph
45.881 /// to the arcs of the \c from graph.
45.882 ///
45.883 - /// \see GraphCopy
45.884 + /// \see GraphCopy
45.885 template <typename To, typename From>
45.886 - GraphCopy<To, From>
45.887 + GraphCopy<To, From>
45.888 copyGraph(To& to, const From& from) {
45.889 return GraphCopy<To, From>(to, from);
45.890 }
45.891 @@ -1214,7 +1214,7 @@
45.892 /// \brief Gives back the given item from its id.
45.893 ///
45.894 /// Gives back the given item from its id.
45.895 - ///
45.896 + ///
45.897 Item operator[](int id) const { return _graph->fromId(id, Item());}
45.898
45.899 private:
45.900 @@ -1224,15 +1224,15 @@
45.901 /// \brief Gives back the inverse of the map.
45.902 ///
45.903 /// Gives back the inverse of the IdMap.
45.904 - InverseMap inverse() const { return InverseMap(*_graph);}
45.905 + InverseMap inverse() const { return InverseMap(*_graph);}
45.906
45.907 };
45.908
45.909 -
45.910 +
45.911 /// \brief General invertable graph-map type.
45.912
45.913 - /// This type provides simple invertable graph-maps.
45.914 - /// The InvertableMap wraps an arbitrary ReadWriteMap
45.915 + /// This type provides simple invertable graph-maps.
45.916 + /// The InvertableMap wraps an arbitrary ReadWriteMap
45.917 /// and if a key is set to a new value then store it
45.918 /// in the inverse map.
45.919 ///
45.920 @@ -1247,15 +1247,15 @@
45.921 template <typename _Graph, typename _Item, typename _Value>
45.922 class InvertableMap : protected DefaultMap<_Graph, _Item, _Value> {
45.923 private:
45.924 -
45.925 +
45.926 typedef DefaultMap<_Graph, _Item, _Value> Map;
45.927 typedef _Graph Graph;
45.928
45.929 typedef std::map<_Value, _Item> Container;
45.930 - Container _inv_map;
45.931 + Container _inv_map;
45.932
45.933 public:
45.934 -
45.935 +
45.936 /// The key type of InvertableMap (Node, Arc, Edge).
45.937 typedef typename Map::Key Key;
45.938 /// The value type of the InvertableMap.
45.939 @@ -1267,7 +1267,7 @@
45.940 ///
45.941 /// Construct a new InvertableMap for the graph.
45.942 ///
45.943 - explicit InvertableMap(const Graph& graph) : Map(graph) {}
45.944 + explicit InvertableMap(const Graph& graph) : Map(graph) {}
45.945
45.946 /// \brief Forward iterator for values.
45.947 ///
45.948 @@ -1275,21 +1275,21 @@
45.949 /// iterator on the values of the map. The values can
45.950 /// be accessed in the [beginValue, endValue) range.
45.951 ///
45.952 - class ValueIterator
45.953 + class ValueIterator
45.954 : public std::iterator<std::forward_iterator_tag, Value> {
45.955 friend class InvertableMap;
45.956 private:
45.957 - ValueIterator(typename Container::const_iterator _it)
45.958 + ValueIterator(typename Container::const_iterator _it)
45.959 : it(_it) {}
45.960 public:
45.961 -
45.962 +
45.963 ValueIterator() {}
45.964
45.965 ValueIterator& operator++() { ++it; return *this; }
45.966 - ValueIterator operator++(int) {
45.967 - ValueIterator tmp(*this);
45.968 + ValueIterator operator++(int) {
45.969 + ValueIterator tmp(*this);
45.970 operator++();
45.971 - return tmp;
45.972 + return tmp;
45.973 }
45.974
45.975 const Value& operator*() const { return it->first; }
45.976 @@ -1297,14 +1297,14 @@
45.977
45.978 bool operator==(ValueIterator jt) const { return it == jt.it; }
45.979 bool operator!=(ValueIterator jt) const { return it != jt.it; }
45.980 -
45.981 +
45.982 private:
45.983 typename Container::const_iterator it;
45.984 };
45.985
45.986 /// \brief Returns an iterator to the first value.
45.987 ///
45.988 - /// Returns an stl compatible iterator to the
45.989 + /// Returns an stl compatible iterator to the
45.990 /// first value of the map. The values of the
45.991 /// map can be accessed in the [beginValue, endValue)
45.992 /// range.
45.993 @@ -1314,14 +1314,14 @@
45.994
45.995 /// \brief Returns an iterator after the last value.
45.996 ///
45.997 - /// Returns an stl compatible iterator after the
45.998 + /// Returns an stl compatible iterator after the
45.999 /// last value of the map. The values of the
45.1000 /// map can be accessed in the [beginValue, endValue)
45.1001 /// range.
45.1002 ValueIterator endValue() const {
45.1003 return ValueIterator(_inv_map.end());
45.1004 }
45.1005 -
45.1006 +
45.1007 /// \brief The setter function of the map.
45.1008 ///
45.1009 /// Sets the mapped value.
45.1010 @@ -1329,8 +1329,8 @@
45.1011 Value oldval = Map::operator[](key);
45.1012 typename Container::iterator it = _inv_map.find(oldval);
45.1013 if (it != _inv_map.end() && it->second == key) {
45.1014 - _inv_map.erase(it);
45.1015 - }
45.1016 + _inv_map.erase(it);
45.1017 + }
45.1018 _inv_map.insert(make_pair(val, key));
45.1019 Map::set(key, val);
45.1020 }
45.1021 @@ -1338,7 +1338,7 @@
45.1022 /// \brief The getter function of the map.
45.1023 ///
45.1024 /// It gives back the value associated with the key.
45.1025 - typename MapTraits<Map>::ConstReturnValue
45.1026 + typename MapTraits<Map>::ConstReturnValue
45.1027 operator[](const Key& key) const {
45.1028 return Map::operator[](key);
45.1029 }
45.1030 @@ -1361,7 +1361,7 @@
45.1031 Value val = Map::operator[](key);
45.1032 typename Container::iterator it = _inv_map.find(val);
45.1033 if (it != _inv_map.end() && it->second == key) {
45.1034 - _inv_map.erase(it);
45.1035 + _inv_map.erase(it);
45.1036 }
45.1037 Map::erase(key);
45.1038 }
45.1039 @@ -1372,11 +1372,11 @@
45.1040 /// \c AlterationNotifier.
45.1041 virtual void erase(const std::vector<Key>& keys) {
45.1042 for (int i = 0; i < int(keys.size()); ++i) {
45.1043 - Value val = Map::operator[](keys[i]);
45.1044 - typename Container::iterator it = _inv_map.find(val);
45.1045 - if (it != _inv_map.end() && it->second == keys[i]) {
45.1046 - _inv_map.erase(it);
45.1047 - }
45.1048 + Value val = Map::operator[](keys[i]);
45.1049 + typename Container::iterator it = _inv_map.find(val);
45.1050 + if (it != _inv_map.end() && it->second == keys[i]) {
45.1051 + _inv_map.erase(it);
45.1052 + }
45.1053 }
45.1054 Map::erase(keys);
45.1055 }
45.1056 @@ -1395,28 +1395,28 @@
45.1057 /// \brief The inverse map type.
45.1058 ///
45.1059 /// The inverse of this map. The subscript operator of the map
45.1060 - /// gives back always the item what was last assigned to the value.
45.1061 + /// gives back always the item what was last assigned to the value.
45.1062 class InverseMap {
45.1063 public:
45.1064 /// \brief Constructor of the InverseMap.
45.1065 ///
45.1066 /// Constructor of the InverseMap.
45.1067 - explicit InverseMap(const InvertableMap& inverted)
45.1068 + explicit InverseMap(const InvertableMap& inverted)
45.1069 : _inverted(inverted) {}
45.1070
45.1071 /// The value type of the InverseMap.
45.1072 typedef typename InvertableMap::Key Value;
45.1073 /// The key type of the InverseMap.
45.1074 - typedef typename InvertableMap::Value Key;
45.1075 -
45.1076 - /// \brief Subscript operator.
45.1077 + typedef typename InvertableMap::Value Key;
45.1078 +
45.1079 + /// \brief Subscript operator.
45.1080 ///
45.1081 - /// Subscript operator. It gives back always the item
45.1082 + /// Subscript operator. It gives back always the item
45.1083 /// what was last assigned to the value.
45.1084 Value operator[](const Key& key) const {
45.1085 - return _inverted(key);
45.1086 + return _inverted(key);
45.1087 }
45.1088 -
45.1089 +
45.1090 private:
45.1091 const InvertableMap& _inverted;
45.1092 };
45.1093 @@ -1426,13 +1426,13 @@
45.1094 /// It gives back the just readable inverse map.
45.1095 InverseMap inverse() const {
45.1096 return InverseMap(*this);
45.1097 - }
45.1098 -
45.1099 -
45.1100 -
45.1101 + }
45.1102 +
45.1103 +
45.1104 +
45.1105 };
45.1106
45.1107 - /// \brief Provides a mutable, continuous and unique descriptor for each
45.1108 + /// \brief Provides a mutable, continuous and unique descriptor for each
45.1109 /// item in the graph.
45.1110 ///
45.1111 /// The DescriptorMap class provides a unique and continuous (but mutable)
45.1112 @@ -1445,7 +1445,7 @@
45.1113 /// with its member class \c InverseMap, or with the \c operator() member.
45.1114 ///
45.1115 /// \tparam _Graph The graph class the \c DescriptorMap belongs to.
45.1116 - /// \tparam _Item The Item is the Key of the Map. It may be Node, Arc or
45.1117 + /// \tparam _Item The Item is the Key of the Map. It may be Node, Arc or
45.1118 /// Edge.
45.1119 template <typename _Graph, typename _Item>
45.1120 class DescriptorMap : protected DefaultMap<_Graph, _Item, int> {
45.1121 @@ -1467,11 +1467,11 @@
45.1122 /// Constructor for descriptor map.
45.1123 explicit DescriptorMap(const Graph& _graph) : Map(_graph) {
45.1124 Item it;
45.1125 - const typename Map::Notifier* nf = Map::notifier();
45.1126 + const typename Map::Notifier* nf = Map::notifier();
45.1127 for (nf->first(it); it != INVALID; nf->next(it)) {
45.1128 - Map::set(it, _inv_map.size());
45.1129 - _inv_map.push_back(it);
45.1130 - }
45.1131 + Map::set(it, _inv_map.size());
45.1132 + _inv_map.push_back(it);
45.1133 + }
45.1134 }
45.1135
45.1136 protected:
45.1137 @@ -1493,8 +1493,8 @@
45.1138 virtual void add(const std::vector<Item>& items) {
45.1139 Map::add(items);
45.1140 for (int i = 0; i < int(items.size()); ++i) {
45.1141 - Map::set(items[i], _inv_map.size());
45.1142 - _inv_map.push_back(items[i]);
45.1143 + Map::set(items[i], _inv_map.size());
45.1144 + _inv_map.push_back(items[i]);
45.1145 }
45.1146 }
45.1147
45.1148 @@ -1515,9 +1515,9 @@
45.1149 /// \c AlterationNotifier.
45.1150 virtual void erase(const std::vector<Item>& items) {
45.1151 for (int i = 0; i < int(items.size()); ++i) {
45.1152 - Map::set(_inv_map.back(), Map::operator[](items[i]));
45.1153 - _inv_map[Map::operator[](items[i])] = _inv_map.back();
45.1154 - _inv_map.pop_back();
45.1155 + Map::set(_inv_map.back(), Map::operator[](items[i]));
45.1156 + _inv_map[Map::operator[](items[i])] = _inv_map.back();
45.1157 + _inv_map.pop_back();
45.1158 }
45.1159 Map::erase(items);
45.1160 }
45.1161 @@ -1529,13 +1529,13 @@
45.1162 virtual void build() {
45.1163 Map::build();
45.1164 Item it;
45.1165 - const typename Map::Notifier* nf = Map::notifier();
45.1166 + const typename Map::Notifier* nf = Map::notifier();
45.1167 for (nf->first(it); it != INVALID; nf->next(it)) {
45.1168 - Map::set(it, _inv_map.size());
45.1169 - _inv_map.push_back(it);
45.1170 - }
45.1171 + Map::set(it, _inv_map.size());
45.1172 + _inv_map.push_back(it);
45.1173 + }
45.1174 }
45.1175 -
45.1176 +
45.1177 /// \brief Clear the keys from the map.
45.1178 ///
45.1179 /// Clear the keys from the map. It is called by the
45.1180 @@ -1579,7 +1579,7 @@
45.1181 Item operator()(int id) const {
45.1182 return _inv_map[id];
45.1183 }
45.1184 -
45.1185 +
45.1186 private:
45.1187
45.1188 typedef std::vector<Item> Container;
45.1189 @@ -1594,30 +1594,30 @@
45.1190 /// \brief Constructor of the InverseMap.
45.1191 ///
45.1192 /// Constructor of the InverseMap.
45.1193 - explicit InverseMap(const DescriptorMap& inverted)
45.1194 - : _inverted(inverted) {}
45.1195 + explicit InverseMap(const DescriptorMap& inverted)
45.1196 + : _inverted(inverted) {}
45.1197
45.1198
45.1199 /// The value type of the InverseMap.
45.1200 typedef typename DescriptorMap::Key Value;
45.1201 /// The key type of the InverseMap.
45.1202 - typedef typename DescriptorMap::Value Key;
45.1203 -
45.1204 - /// \brief Subscript operator.
45.1205 + typedef typename DescriptorMap::Value Key;
45.1206 +
45.1207 + /// \brief Subscript operator.
45.1208 ///
45.1209 - /// Subscript operator. It gives back the item
45.1210 + /// Subscript operator. It gives back the item
45.1211 /// that the descriptor belongs to currently.
45.1212 Value operator[](const Key& key) const {
45.1213 - return _inverted(key);
45.1214 + return _inverted(key);
45.1215 }
45.1216
45.1217 /// \brief Size of the map.
45.1218 ///
45.1219 /// Returns the size of the map.
45.1220 unsigned int size() const {
45.1221 - return _inverted.size();
45.1222 + return _inverted.size();
45.1223 }
45.1224 -
45.1225 +
45.1226 private:
45.1227 const DescriptorMap& _inverted;
45.1228 };
45.1229 @@ -1632,7 +1632,7 @@
45.1230
45.1231 /// \brief Returns the source of the given arc.
45.1232 ///
45.1233 - /// The SourceMap gives back the source Node of the given arc.
45.1234 + /// The SourceMap gives back the source Node of the given arc.
45.1235 /// \see TargetMap
45.1236 template <typename Digraph>
45.1237 class SourceMap {
45.1238 @@ -1650,8 +1650,8 @@
45.1239 /// \brief The subscript operator.
45.1240 ///
45.1241 /// The subscript operator.
45.1242 - /// \param arc The arc
45.1243 - /// \return The source of the arc
45.1244 + /// \param arc The arc
45.1245 + /// \return The source of the arc
45.1246 Value operator[](const Key& arc) const {
45.1247 return _digraph.source(arc);
45.1248 }
45.1249 @@ -1667,11 +1667,11 @@
45.1250 template <typename Digraph>
45.1251 inline SourceMap<Digraph> sourceMap(const Digraph& digraph) {
45.1252 return SourceMap<Digraph>(digraph);
45.1253 - }
45.1254 + }
45.1255
45.1256 /// \brief Returns the target of the given arc.
45.1257 ///
45.1258 - /// The TargetMap gives back the target Node of the given arc.
45.1259 + /// The TargetMap gives back the target Node of the given arc.
45.1260 /// \see SourceMap
45.1261 template <typename Digraph>
45.1262 class TargetMap {
45.1263 @@ -1689,8 +1689,8 @@
45.1264 /// \brief The subscript operator.
45.1265 ///
45.1266 /// The subscript operator.
45.1267 - /// \param e The arc
45.1268 - /// \return The target of the arc
45.1269 + /// \param e The arc
45.1270 + /// \return The target of the arc
45.1271 Value operator[](const Key& e) const {
45.1272 return _digraph.target(e);
45.1273 }
45.1274 @@ -1728,8 +1728,8 @@
45.1275 /// \brief The subscript operator.
45.1276 ///
45.1277 /// The subscript operator.
45.1278 - /// \param key An edge
45.1279 - /// \return The "forward" directed arc view of edge
45.1280 + /// \param key An edge
45.1281 + /// \return The "forward" directed arc view of edge
45.1282 Value operator[](const Key& key) const {
45.1283 return _graph.direct(key, true);
45.1284 }
45.1285 @@ -1767,8 +1767,8 @@
45.1286 /// \brief The subscript operator.
45.1287 ///
45.1288 /// The subscript operator.
45.1289 - /// \param key An edge
45.1290 - /// \return The "backward" directed arc view of edge
45.1291 + /// \param key An edge
45.1292 + /// \return The "backward" directed arc view of edge
45.1293 Value operator[](const Key& key) const {
45.1294 return _graph.direct(key, false);
45.1295 }
45.1296 @@ -1800,16 +1800,16 @@
45.1297 /// \brief Constructor
45.1298 ///
45.1299 /// Contructor of the map
45.1300 - explicit PotentialDifferenceMap(const Digraph& digraph,
45.1301 - const NodeMap& potential)
45.1302 + explicit PotentialDifferenceMap(const Digraph& digraph,
45.1303 + const NodeMap& potential)
45.1304 : _digraph(digraph), _potential(potential) {}
45.1305
45.1306 /// \brief Const subscription operator
45.1307 ///
45.1308 /// Const subscription operator
45.1309 Value operator[](const Key& arc) const {
45.1310 - return _potential[_digraph.target(arc)] -
45.1311 - _potential[_digraph.source(arc)];
45.1312 + return _potential[_digraph.target(arc)] -
45.1313 + _potential[_digraph.source(arc)];
45.1314 }
45.1315
45.1316 private:
45.1317 @@ -1822,7 +1822,7 @@
45.1318 /// This function just returns a PotentialDifferenceMap.
45.1319 /// \relates PotentialDifferenceMap
45.1320 template <typename Digraph, typename NodeMap>
45.1321 - PotentialDifferenceMap<Digraph, NodeMap>
45.1322 + PotentialDifferenceMap<Digraph, NodeMap>
45.1323 potentialDifferenceMap(const Digraph& digraph, const NodeMap& potential) {
45.1324 return PotentialDifferenceMap<Digraph, NodeMap>(digraph, potential);
45.1325 }
45.1326 @@ -1845,12 +1845,12 @@
45.1327 /// \sa OutDegMap
45.1328
45.1329 template <typename _Digraph>
45.1330 - class InDegMap
45.1331 + class InDegMap
45.1332 : protected ItemSetTraits<_Digraph, typename _Digraph::Arc>
45.1333 ::ItemNotifier::ObserverBase {
45.1334
45.1335 public:
45.1336 -
45.1337 +
45.1338 typedef _Digraph Digraph;
45.1339 typedef int Value;
45.1340 typedef typename Digraph::Node Key;
45.1341 @@ -1866,26 +1866,26 @@
45.1342 typedef DefaultMap<Digraph, Key, int> Parent;
45.1343
45.1344 AutoNodeMap(const Digraph& digraph) : Parent(digraph, 0) {}
45.1345 -
45.1346 +
45.1347 virtual void add(const Key& key) {
45.1348 - Parent::add(key);
45.1349 - Parent::set(key, 0);
45.1350 + Parent::add(key);
45.1351 + Parent::set(key, 0);
45.1352 }
45.1353
45.1354 virtual void add(const std::vector<Key>& keys) {
45.1355 - Parent::add(keys);
45.1356 - for (int i = 0; i < int(keys.size()); ++i) {
45.1357 - Parent::set(keys[i], 0);
45.1358 - }
45.1359 + Parent::add(keys);
45.1360 + for (int i = 0; i < int(keys.size()); ++i) {
45.1361 + Parent::set(keys[i], 0);
45.1362 + }
45.1363 }
45.1364
45.1365 virtual void build() {
45.1366 - Parent::build();
45.1367 - Key it;
45.1368 - typename Parent::Notifier* nf = Parent::notifier();
45.1369 - for (nf->first(it); it != INVALID; nf->next(it)) {
45.1370 - Parent::set(it, 0);
45.1371 - }
45.1372 + Parent::build();
45.1373 + Key it;
45.1374 + typename Parent::Notifier* nf = Parent::notifier();
45.1375 + for (nf->first(it); it != INVALID; nf->next(it)) {
45.1376 + Parent::set(it, 0);
45.1377 + }
45.1378 }
45.1379 };
45.1380
45.1381 @@ -1894,22 +1894,22 @@
45.1382 /// \brief Constructor.
45.1383 ///
45.1384 /// Constructor for creating in-degree map.
45.1385 - explicit InDegMap(const Digraph& digraph)
45.1386 + explicit InDegMap(const Digraph& digraph)
45.1387 : _digraph(digraph), _deg(digraph) {
45.1388 Parent::attach(_digraph.notifier(typename Digraph::Arc()));
45.1389 -
45.1390 +
45.1391 for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
45.1392 - _deg[it] = countInArcs(_digraph, it);
45.1393 + _deg[it] = countInArcs(_digraph, it);
45.1394 }
45.1395 }
45.1396 -
45.1397 +
45.1398 /// Gives back the in-degree of a Node.
45.1399 int operator[](const Key& key) const {
45.1400 return _deg[key];
45.1401 }
45.1402
45.1403 protected:
45.1404 -
45.1405 +
45.1406 typedef typename Digraph::Arc Arc;
45.1407
45.1408 virtual void add(const Arc& arc) {
45.1409 @@ -1934,17 +1934,17 @@
45.1410
45.1411 virtual void build() {
45.1412 for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
45.1413 - _deg[it] = countInArcs(_digraph, it);
45.1414 - }
45.1415 + _deg[it] = countInArcs(_digraph, it);
45.1416 + }
45.1417 }
45.1418
45.1419 virtual void clear() {
45.1420 for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
45.1421 - _deg[it] = 0;
45.1422 + _deg[it] = 0;
45.1423 }
45.1424 }
45.1425 private:
45.1426 -
45.1427 +
45.1428 const Digraph& _digraph;
45.1429 AutoNodeMap _deg;
45.1430 };
45.1431 @@ -1967,12 +1967,12 @@
45.1432 /// \sa InDegMap
45.1433
45.1434 template <typename _Digraph>
45.1435 - class OutDegMap
45.1436 + class OutDegMap
45.1437 : protected ItemSetTraits<_Digraph, typename _Digraph::Arc>
45.1438 ::ItemNotifier::ObserverBase {
45.1439
45.1440 public:
45.1441 -
45.1442 +
45.1443 typedef _Digraph Digraph;
45.1444 typedef int Value;
45.1445 typedef typename Digraph::Node Key;
45.1446 @@ -1988,24 +1988,24 @@
45.1447 typedef DefaultMap<Digraph, Key, int> Parent;
45.1448
45.1449 AutoNodeMap(const Digraph& digraph) : Parent(digraph, 0) {}
45.1450 -
45.1451 +
45.1452 virtual void add(const Key& key) {
45.1453 - Parent::add(key);
45.1454 - Parent::set(key, 0);
45.1455 + Parent::add(key);
45.1456 + Parent::set(key, 0);
45.1457 }
45.1458 virtual void add(const std::vector<Key>& keys) {
45.1459 - Parent::add(keys);
45.1460 - for (int i = 0; i < int(keys.size()); ++i) {
45.1461 - Parent::set(keys[i], 0);
45.1462 - }
45.1463 + Parent::add(keys);
45.1464 + for (int i = 0; i < int(keys.size()); ++i) {
45.1465 + Parent::set(keys[i], 0);
45.1466 + }
45.1467 }
45.1468 virtual void build() {
45.1469 - Parent::build();
45.1470 - Key it;
45.1471 - typename Parent::Notifier* nf = Parent::notifier();
45.1472 - for (nf->first(it); it != INVALID; nf->next(it)) {
45.1473 - Parent::set(it, 0);
45.1474 - }
45.1475 + Parent::build();
45.1476 + Key it;
45.1477 + typename Parent::Notifier* nf = Parent::notifier();
45.1478 + for (nf->first(it); it != INVALID; nf->next(it)) {
45.1479 + Parent::set(it, 0);
45.1480 + }
45.1481 }
45.1482 };
45.1483
45.1484 @@ -2014,12 +2014,12 @@
45.1485 /// \brief Constructor.
45.1486 ///
45.1487 /// Constructor for creating out-degree map.
45.1488 - explicit OutDegMap(const Digraph& digraph)
45.1489 + explicit OutDegMap(const Digraph& digraph)
45.1490 : _digraph(digraph), _deg(digraph) {
45.1491 Parent::attach(_digraph.notifier(typename Digraph::Arc()));
45.1492 -
45.1493 +
45.1494 for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
45.1495 - _deg[it] = countOutArcs(_digraph, it);
45.1496 + _deg[it] = countOutArcs(_digraph, it);
45.1497 }
45.1498 }
45.1499
45.1500 @@ -2029,7 +2029,7 @@
45.1501 }
45.1502
45.1503 protected:
45.1504 -
45.1505 +
45.1506 typedef typename Digraph::Arc Arc;
45.1507
45.1508 virtual void add(const Arc& arc) {
45.1509 @@ -2054,24 +2054,24 @@
45.1510
45.1511 virtual void build() {
45.1512 for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
45.1513 - _deg[it] = countOutArcs(_digraph, it);
45.1514 - }
45.1515 + _deg[it] = countOutArcs(_digraph, it);
45.1516 + }
45.1517 }
45.1518
45.1519 virtual void clear() {
45.1520 for(typename Digraph::NodeIt it(_digraph); it != INVALID; ++it) {
45.1521 - _deg[it] = 0;
45.1522 + _deg[it] = 0;
45.1523 }
45.1524 }
45.1525 private:
45.1526 -
45.1527 +
45.1528 const Digraph& _digraph;
45.1529 AutoNodeMap _deg;
45.1530 };
45.1531
45.1532
45.1533 ///Dynamic arc look up between given endpoints.
45.1534 -
45.1535 +
45.1536 ///\ingroup gutils
45.1537 ///Using this class, you can find an arc in a digraph from a given
45.1538 ///source to a given target in amortized time <em>O(log d)</em>,
45.1539 @@ -2089,12 +2089,12 @@
45.1540 ///optimal time bound in a constant factor for any distribution of
45.1541 ///queries.
45.1542 ///
45.1543 - ///\tparam G The type of the underlying digraph.
45.1544 + ///\tparam G The type of the underlying digraph.
45.1545 ///
45.1546 - ///\sa ArcLookUp
45.1547 - ///\sa AllArcLookUp
45.1548 + ///\sa ArcLookUp
45.1549 + ///\sa AllArcLookUp
45.1550 template<class G>
45.1551 - class DynArcLookUp
45.1552 + class DynArcLookUp
45.1553 : protected ItemSetTraits<G, typename G::Arc>::ItemNotifier::ObserverBase
45.1554 {
45.1555 public:
45.1556 @@ -2112,26 +2112,26 @@
45.1557 typedef DefaultMap<G, Node, Arc> Parent;
45.1558
45.1559 AutoNodeMap(const G& digraph) : Parent(digraph, INVALID) {}
45.1560 -
45.1561 +
45.1562 virtual void add(const Node& node) {
45.1563 - Parent::add(node);
45.1564 - Parent::set(node, INVALID);
45.1565 + Parent::add(node);
45.1566 + Parent::set(node, INVALID);
45.1567 }
45.1568
45.1569 virtual void add(const std::vector<Node>& nodes) {
45.1570 - Parent::add(nodes);
45.1571 - for (int i = 0; i < int(nodes.size()); ++i) {
45.1572 - Parent::set(nodes[i], INVALID);
45.1573 - }
45.1574 + Parent::add(nodes);
45.1575 + for (int i = 0; i < int(nodes.size()); ++i) {
45.1576 + Parent::set(nodes[i], INVALID);
45.1577 + }
45.1578 }
45.1579
45.1580 virtual void build() {
45.1581 - Parent::build();
45.1582 - Node it;
45.1583 - typename Parent::Notifier* nf = Parent::notifier();
45.1584 - for (nf->first(it); it != INVALID; nf->next(it)) {
45.1585 - Parent::set(it, INVALID);
45.1586 - }
45.1587 + Parent::build();
45.1588 + Node it;
45.1589 + typename Parent::Notifier* nf = Parent::notifier();
45.1590 + for (nf->first(it); it != INVALID; nf->next(it)) {
45.1591 + Parent::set(it, INVALID);
45.1592 + }
45.1593 }
45.1594 };
45.1595
45.1596 @@ -2140,31 +2140,31 @@
45.1597 typename Digraph::template ArcMap<Arc> _parent;
45.1598 typename Digraph::template ArcMap<Arc> _left;
45.1599 typename Digraph::template ArcMap<Arc> _right;
45.1600 -
45.1601 +
45.1602 class ArcLess {
45.1603 const Digraph &g;
45.1604 public:
45.1605 ArcLess(const Digraph &_g) : g(_g) {}
45.1606 - bool operator()(Arc a,Arc b) const
45.1607 + bool operator()(Arc a,Arc b) const
45.1608 {
45.1609 - return g.target(a)<g.target(b);
45.1610 + return g.target(a)<g.target(b);
45.1611 }
45.1612 };
45.1613 -
45.1614 +
45.1615 public:
45.1616 -
45.1617 +
45.1618 ///Constructor
45.1619
45.1620 ///Constructor.
45.1621 ///
45.1622 ///It builds up the search database.
45.1623 - DynArcLookUp(const Digraph &g)
45.1624 - : _g(g),_head(g),_parent(g),_left(g),_right(g)
45.1625 - {
45.1626 + DynArcLookUp(const Digraph &g)
45.1627 + : _g(g),_head(g),_parent(g),_left(g),_right(g)
45.1628 + {
45.1629 Parent::attach(_g.notifier(typename Digraph::Arc()));
45.1630 - refresh();
45.1631 + refresh();
45.1632 }
45.1633 -
45.1634 +
45.1635 protected:
45.1636
45.1637 virtual void add(const Arc& arc) {
45.1638 @@ -2173,7 +2173,7 @@
45.1639
45.1640 virtual void add(const std::vector<Arc>& arcs) {
45.1641 for (int i = 0; i < int(arcs.size()); ++i) {
45.1642 - insert(arcs[i]);
45.1643 + insert(arcs[i]);
45.1644 }
45.1645 }
45.1646
45.1647 @@ -2183,8 +2183,8 @@
45.1648
45.1649 virtual void erase(const std::vector<Arc>& arcs) {
45.1650 for (int i = 0; i < int(arcs.size()); ++i) {
45.1651 - remove(arcs[i]);
45.1652 - }
45.1653 + remove(arcs[i]);
45.1654 + }
45.1655 }
45.1656
45.1657 virtual void build() {
45.1658 @@ -2193,7 +2193,7 @@
45.1659
45.1660 virtual void clear() {
45.1661 for(NodeIt n(_g);n!=INVALID;++n) {
45.1662 - _head.set(n, INVALID);
45.1663 + _head.set(n, INVALID);
45.1664 }
45.1665 }
45.1666
45.1667 @@ -2202,212 +2202,212 @@
45.1668 Node t = _g.target(arc);
45.1669 _left.set(arc, INVALID);
45.1670 _right.set(arc, INVALID);
45.1671 -
45.1672 +
45.1673 Arc e = _head[s];
45.1674 if (e == INVALID) {
45.1675 - _head.set(s, arc);
45.1676 - _parent.set(arc, INVALID);
45.1677 - return;
45.1678 + _head.set(s, arc);
45.1679 + _parent.set(arc, INVALID);
45.1680 + return;
45.1681 }
45.1682 while (true) {
45.1683 - if (t < _g.target(e)) {
45.1684 - if (_left[e] == INVALID) {
45.1685 - _left.set(e, arc);
45.1686 - _parent.set(arc, e);
45.1687 - splay(arc);
45.1688 - return;
45.1689 - } else {
45.1690 - e = _left[e];
45.1691 - }
45.1692 - } else {
45.1693 - if (_right[e] == INVALID) {
45.1694 - _right.set(e, arc);
45.1695 - _parent.set(arc, e);
45.1696 - splay(arc);
45.1697 - return;
45.1698 - } else {
45.1699 - e = _right[e];
45.1700 - }
45.1701 - }
45.1702 + if (t < _g.target(e)) {
45.1703 + if (_left[e] == INVALID) {
45.1704 + _left.set(e, arc);
45.1705 + _parent.set(arc, e);
45.1706 + splay(arc);
45.1707 + return;
45.1708 + } else {
45.1709 + e = _left[e];
45.1710 + }
45.1711 + } else {
45.1712 + if (_right[e] == INVALID) {
45.1713 + _right.set(e, arc);
45.1714 + _parent.set(arc, e);
45.1715 + splay(arc);
45.1716 + return;
45.1717 + } else {
45.1718 + e = _right[e];
45.1719 + }
45.1720 + }
45.1721 }
45.1722 }
45.1723
45.1724 void remove(Arc arc) {
45.1725 if (_left[arc] == INVALID) {
45.1726 - if (_right[arc] != INVALID) {
45.1727 - _parent.set(_right[arc], _parent[arc]);
45.1728 - }
45.1729 - if (_parent[arc] != INVALID) {
45.1730 - if (_left[_parent[arc]] == arc) {
45.1731 - _left.set(_parent[arc], _right[arc]);
45.1732 - } else {
45.1733 - _right.set(_parent[arc], _right[arc]);
45.1734 - }
45.1735 - } else {
45.1736 - _head.set(_g.source(arc), _right[arc]);
45.1737 - }
45.1738 + if (_right[arc] != INVALID) {
45.1739 + _parent.set(_right[arc], _parent[arc]);
45.1740 + }
45.1741 + if (_parent[arc] != INVALID) {
45.1742 + if (_left[_parent[arc]] == arc) {
45.1743 + _left.set(_parent[arc], _right[arc]);
45.1744 + } else {
45.1745 + _right.set(_parent[arc], _right[arc]);
45.1746 + }
45.1747 + } else {
45.1748 + _head.set(_g.source(arc), _right[arc]);
45.1749 + }
45.1750 } else if (_right[arc] == INVALID) {
45.1751 - _parent.set(_left[arc], _parent[arc]);
45.1752 - if (_parent[arc] != INVALID) {
45.1753 - if (_left[_parent[arc]] == arc) {
45.1754 - _left.set(_parent[arc], _left[arc]);
45.1755 - } else {
45.1756 - _right.set(_parent[arc], _left[arc]);
45.1757 - }
45.1758 - } else {
45.1759 - _head.set(_g.source(arc), _left[arc]);
45.1760 - }
45.1761 + _parent.set(_left[arc], _parent[arc]);
45.1762 + if (_parent[arc] != INVALID) {
45.1763 + if (_left[_parent[arc]] == arc) {
45.1764 + _left.set(_parent[arc], _left[arc]);
45.1765 + } else {
45.1766 + _right.set(_parent[arc], _left[arc]);
45.1767 + }
45.1768 + } else {
45.1769 + _head.set(_g.source(arc), _left[arc]);
45.1770 + }
45.1771 } else {
45.1772 - Arc e = _left[arc];
45.1773 - if (_right[e] != INVALID) {
45.1774 - e = _right[e];
45.1775 - while (_right[e] != INVALID) {
45.1776 - e = _right[e];
45.1777 - }
45.1778 - Arc s = _parent[e];
45.1779 - _right.set(_parent[e], _left[e]);
45.1780 - if (_left[e] != INVALID) {
45.1781 - _parent.set(_left[e], _parent[e]);
45.1782 - }
45.1783 -
45.1784 - _left.set(e, _left[arc]);
45.1785 - _parent.set(_left[arc], e);
45.1786 - _right.set(e, _right[arc]);
45.1787 - _parent.set(_right[arc], e);
45.1788 -
45.1789 - _parent.set(e, _parent[arc]);
45.1790 - if (_parent[arc] != INVALID) {
45.1791 - if (_left[_parent[arc]] == arc) {
45.1792 - _left.set(_parent[arc], e);
45.1793 - } else {
45.1794 - _right.set(_parent[arc], e);
45.1795 - }
45.1796 - }
45.1797 - splay(s);
45.1798 - } else {
45.1799 - _right.set(e, _right[arc]);
45.1800 - _parent.set(_right[arc], e);
45.1801 -
45.1802 - if (_parent[arc] != INVALID) {
45.1803 - if (_left[_parent[arc]] == arc) {
45.1804 - _left.set(_parent[arc], e);
45.1805 - } else {
45.1806 - _right.set(_parent[arc], e);
45.1807 - }
45.1808 - } else {
45.1809 - _head.set(_g.source(arc), e);
45.1810 - }
45.1811 - }
45.1812 + Arc e = _left[arc];
45.1813 + if (_right[e] != INVALID) {
45.1814 + e = _right[e];
45.1815 + while (_right[e] != INVALID) {
45.1816 + e = _right[e];
45.1817 + }
45.1818 + Arc s = _parent[e];
45.1819 + _right.set(_parent[e], _left[e]);
45.1820 + if (_left[e] != INVALID) {
45.1821 + _parent.set(_left[e], _parent[e]);
45.1822 + }
45.1823 +
45.1824 + _left.set(e, _left[arc]);
45.1825 + _parent.set(_left[arc], e);
45.1826 + _right.set(e, _right[arc]);
45.1827 + _parent.set(_right[arc], e);
45.1828 +
45.1829 + _parent.set(e, _parent[arc]);
45.1830 + if (_parent[arc] != INVALID) {
45.1831 + if (_left[_parent[arc]] == arc) {
45.1832 + _left.set(_parent[arc], e);
45.1833 + } else {
45.1834 + _right.set(_parent[arc], e);
45.1835 + }
45.1836 + }
45.1837 + splay(s);
45.1838 + } else {
45.1839 + _right.set(e, _right[arc]);
45.1840 + _parent.set(_right[arc], e);
45.1841 +
45.1842 + if (_parent[arc] != INVALID) {
45.1843 + if (_left[_parent[arc]] == arc) {
45.1844 + _left.set(_parent[arc], e);
45.1845 + } else {
45.1846 + _right.set(_parent[arc], e);
45.1847 + }
45.1848 + } else {
45.1849 + _head.set(_g.source(arc), e);
45.1850 + }
45.1851 + }
45.1852 }
45.1853 }
45.1854
45.1855 - Arc refreshRec(std::vector<Arc> &v,int a,int b)
45.1856 + Arc refreshRec(std::vector<Arc> &v,int a,int b)
45.1857 {
45.1858 int m=(a+b)/2;
45.1859 Arc me=v[m];
45.1860 if (a < m) {
45.1861 - Arc left = refreshRec(v,a,m-1);
45.1862 - _left.set(me, left);
45.1863 - _parent.set(left, me);
45.1864 + Arc left = refreshRec(v,a,m-1);
45.1865 + _left.set(me, left);
45.1866 + _parent.set(left, me);
45.1867 } else {
45.1868 - _left.set(me, INVALID);
45.1869 + _left.set(me, INVALID);
45.1870 }
45.1871 if (m < b) {
45.1872 - Arc right = refreshRec(v,m+1,b);
45.1873 - _right.set(me, right);
45.1874 - _parent.set(right, me);
45.1875 + Arc right = refreshRec(v,m+1,b);
45.1876 + _right.set(me, right);
45.1877 + _parent.set(right, me);
45.1878 } else {
45.1879 - _right.set(me, INVALID);
45.1880 + _right.set(me, INVALID);
45.1881 }
45.1882 return me;
45.1883 }
45.1884
45.1885 void refresh() {
45.1886 for(NodeIt n(_g);n!=INVALID;++n) {
45.1887 - std::vector<Arc> v;
45.1888 - for(OutArcIt e(_g,n);e!=INVALID;++e) v.push_back(e);
45.1889 - if(v.size()) {
45.1890 - std::sort(v.begin(),v.end(),ArcLess(_g));
45.1891 - Arc head = refreshRec(v,0,v.size()-1);
45.1892 - _head.set(n, head);
45.1893 - _parent.set(head, INVALID);
45.1894 - }
45.1895 - else _head.set(n, INVALID);
45.1896 + std::vector<Arc> v;
45.1897 + for(OutArcIt e(_g,n);e!=INVALID;++e) v.push_back(e);
45.1898 + if(v.size()) {
45.1899 + std::sort(v.begin(),v.end(),ArcLess(_g));
45.1900 + Arc head = refreshRec(v,0,v.size()-1);
45.1901 + _head.set(n, head);
45.1902 + _parent.set(head, INVALID);
45.1903 + }
45.1904 + else _head.set(n, INVALID);
45.1905 }
45.1906 }
45.1907
45.1908 - void zig(Arc v) {
45.1909 + void zig(Arc v) {
45.1910 Arc w = _parent[v];
45.1911 _parent.set(v, _parent[w]);
45.1912 _parent.set(w, v);
45.1913 _left.set(w, _right[v]);
45.1914 _right.set(v, w);
45.1915 if (_parent[v] != INVALID) {
45.1916 - if (_right[_parent[v]] == w) {
45.1917 - _right.set(_parent[v], v);
45.1918 - } else {
45.1919 - _left.set(_parent[v], v);
45.1920 - }
45.1921 + if (_right[_parent[v]] == w) {
45.1922 + _right.set(_parent[v], v);
45.1923 + } else {
45.1924 + _left.set(_parent[v], v);
45.1925 + }
45.1926 }
45.1927 if (_left[w] != INVALID){
45.1928 - _parent.set(_left[w], w);
45.1929 + _parent.set(_left[w], w);
45.1930 }
45.1931 }
45.1932
45.1933 - void zag(Arc v) {
45.1934 + void zag(Arc v) {
45.1935 Arc w = _parent[v];
45.1936 _parent.set(v, _parent[w]);
45.1937 _parent.set(w, v);
45.1938 _right.set(w, _left[v]);
45.1939 _left.set(v, w);
45.1940 if (_parent[v] != INVALID){
45.1941 - if (_left[_parent[v]] == w) {
45.1942 - _left.set(_parent[v], v);
45.1943 - } else {
45.1944 - _right.set(_parent[v], v);
45.1945 - }
45.1946 + if (_left[_parent[v]] == w) {
45.1947 + _left.set(_parent[v], v);
45.1948 + } else {
45.1949 + _right.set(_parent[v], v);
45.1950 + }
45.1951 }
45.1952 if (_right[w] != INVALID){
45.1953 - _parent.set(_right[w], w);
45.1954 + _parent.set(_right[w], w);
45.1955 }
45.1956 }
45.1957
45.1958 void splay(Arc v) {
45.1959 while (_parent[v] != INVALID) {
45.1960 - if (v == _left[_parent[v]]) {
45.1961 - if (_parent[_parent[v]] == INVALID) {
45.1962 - zig(v);
45.1963 - } else {
45.1964 - if (_parent[v] == _left[_parent[_parent[v]]]) {
45.1965 - zig(_parent[v]);
45.1966 - zig(v);
45.1967 - } else {
45.1968 - zig(v);
45.1969 - zag(v);
45.1970 - }
45.1971 - }
45.1972 - } else {
45.1973 - if (_parent[_parent[v]] == INVALID) {
45.1974 - zag(v);
45.1975 - } else {
45.1976 - if (_parent[v] == _left[_parent[_parent[v]]]) {
45.1977 - zag(v);
45.1978 - zig(v);
45.1979 - } else {
45.1980 - zag(_parent[v]);
45.1981 - zag(v);
45.1982 - }
45.1983 - }
45.1984 - }
45.1985 + if (v == _left[_parent[v]]) {
45.1986 + if (_parent[_parent[v]] == INVALID) {
45.1987 + zig(v);
45.1988 + } else {
45.1989 + if (_parent[v] == _left[_parent[_parent[v]]]) {
45.1990 + zig(_parent[v]);
45.1991 + zig(v);
45.1992 + } else {
45.1993 + zig(v);
45.1994 + zag(v);
45.1995 + }
45.1996 + }
45.1997 + } else {
45.1998 + if (_parent[_parent[v]] == INVALID) {
45.1999 + zag(v);
45.2000 + } else {
45.2001 + if (_parent[v] == _left[_parent[_parent[v]]]) {
45.2002 + zag(v);
45.2003 + zig(v);
45.2004 + } else {
45.2005 + zag(_parent[v]);
45.2006 + zag(v);
45.2007 + }
45.2008 + }
45.2009 + }
45.2010 }
45.2011 _head[_g.source(v)] = v;
45.2012 }
45.2013
45.2014
45.2015 public:
45.2016 -
45.2017 +
45.2018 ///Find an arc between two nodes.
45.2019 -
45.2020 +
45.2021 ///Find an arc between two nodes in time <em>O(</em>log<em>d)</em>, where
45.2022 /// <em>d</em> is the number of outgoing arcs of \c s.
45.2023 ///\param s The source node
45.2024 @@ -2418,33 +2418,33 @@
45.2025 {
45.2026 Arc a = _head[s];
45.2027 while (true) {
45.2028 - if (_g.target(a) == t) {
45.2029 - const_cast<DynArcLookUp&>(*this).splay(a);
45.2030 - return a;
45.2031 - } else if (t < _g.target(a)) {
45.2032 - if (_left[a] == INVALID) {
45.2033 - const_cast<DynArcLookUp&>(*this).splay(a);
45.2034 - return INVALID;
45.2035 - } else {
45.2036 - a = _left[a];
45.2037 - }
45.2038 - } else {
45.2039 - if (_right[a] == INVALID) {
45.2040 - const_cast<DynArcLookUp&>(*this).splay(a);
45.2041 - return INVALID;
45.2042 - } else {
45.2043 - a = _right[a];
45.2044 - }
45.2045 - }
45.2046 + if (_g.target(a) == t) {
45.2047 + const_cast<DynArcLookUp&>(*this).splay(a);
45.2048 + return a;
45.2049 + } else if (t < _g.target(a)) {
45.2050 + if (_left[a] == INVALID) {
45.2051 + const_cast<DynArcLookUp&>(*this).splay(a);
45.2052 + return INVALID;
45.2053 + } else {
45.2054 + a = _left[a];
45.2055 + }
45.2056 + } else {
45.2057 + if (_right[a] == INVALID) {
45.2058 + const_cast<DynArcLookUp&>(*this).splay(a);
45.2059 + return INVALID;
45.2060 + } else {
45.2061 + a = _right[a];
45.2062 + }
45.2063 + }
45.2064 }
45.2065 }
45.2066
45.2067 ///Find the first arc between two nodes.
45.2068 -
45.2069 +
45.2070 ///Find the first arc between two nodes in time
45.2071 /// <em>O(</em>log<em>d)</em>, where <em>d</em> is the number of
45.2072 - /// outgoing arcs of \c s.
45.2073 - ///\param s The source node
45.2074 + /// outgoing arcs of \c s.
45.2075 + ///\param s The source node
45.2076 ///\param t The target node
45.2077 ///\return An arc from \c s to \c t if there exists, \ref INVALID
45.2078 /// otherwise.
45.2079 @@ -2453,33 +2453,33 @@
45.2080 Arc a = _head[s];
45.2081 Arc r = INVALID;
45.2082 while (true) {
45.2083 - if (_g.target(a) < t) {
45.2084 - if (_right[a] == INVALID) {
45.2085 - const_cast<DynArcLookUp&>(*this).splay(a);
45.2086 - return r;
45.2087 - } else {
45.2088 - a = _right[a];
45.2089 - }
45.2090 - } else {
45.2091 - if (_g.target(a) == t) {
45.2092 - r = a;
45.2093 - }
45.2094 - if (_left[a] == INVALID) {
45.2095 - const_cast<DynArcLookUp&>(*this).splay(a);
45.2096 - return r;
45.2097 - } else {
45.2098 - a = _left[a];
45.2099 - }
45.2100 - }
45.2101 + if (_g.target(a) < t) {
45.2102 + if (_right[a] == INVALID) {
45.2103 + const_cast<DynArcLookUp&>(*this).splay(a);
45.2104 + return r;
45.2105 + } else {
45.2106 + a = _right[a];
45.2107 + }
45.2108 + } else {
45.2109 + if (_g.target(a) == t) {
45.2110 + r = a;
45.2111 + }
45.2112 + if (_left[a] == INVALID) {
45.2113 + const_cast<DynArcLookUp&>(*this).splay(a);
45.2114 + return r;
45.2115 + } else {
45.2116 + a = _left[a];
45.2117 + }
45.2118 + }
45.2119 }
45.2120 }
45.2121
45.2122 ///Find the next arc between two nodes.
45.2123 -
45.2124 +
45.2125 ///Find the next arc between two nodes in time
45.2126 /// <em>O(</em>log<em>d)</em>, where <em>d</em> is the number of
45.2127 - /// outgoing arcs of \c s.
45.2128 - ///\param s The source node
45.2129 + /// outgoing arcs of \c s.
45.2130 + ///\param s The source node
45.2131 ///\param t The target node
45.2132 ///\return An arc from \c s to \c t if there exists, \ref INVALID
45.2133 /// otherwise.
45.2134 @@ -2493,30 +2493,30 @@
45.2135 #endif
45.2136 {
45.2137 if (_right[a] != INVALID) {
45.2138 - a = _right[a];
45.2139 - while (_left[a] != INVALID) {
45.2140 - a = _left[a];
45.2141 - }
45.2142 - const_cast<DynArcLookUp&>(*this).splay(a);
45.2143 + a = _right[a];
45.2144 + while (_left[a] != INVALID) {
45.2145 + a = _left[a];
45.2146 + }
45.2147 + const_cast<DynArcLookUp&>(*this).splay(a);
45.2148 } else {
45.2149 - while (_parent[a] != INVALID && _right[_parent[a]] == a) {
45.2150 - a = _parent[a];
45.2151 - }
45.2152 - if (_parent[a] == INVALID) {
45.2153 - return INVALID;
45.2154 - } else {
45.2155 - a = _parent[a];
45.2156 - const_cast<DynArcLookUp&>(*this).splay(a);
45.2157 - }
45.2158 + while (_parent[a] != INVALID && _right[_parent[a]] == a) {
45.2159 + a = _parent[a];
45.2160 + }
45.2161 + if (_parent[a] == INVALID) {
45.2162 + return INVALID;
45.2163 + } else {
45.2164 + a = _parent[a];
45.2165 + const_cast<DynArcLookUp&>(*this).splay(a);
45.2166 + }
45.2167 }
45.2168 if (_g.target(a) == t) return a;
45.2169 - else return INVALID;
45.2170 + else return INVALID;
45.2171 }
45.2172
45.2173 };
45.2174
45.2175 ///Fast arc look up between given endpoints.
45.2176 -
45.2177 +
45.2178 ///\ingroup gutils
45.2179 ///Using this class, you can find an arc in a digraph from a given
45.2180 ///source to a given target in time <em>O(log d)</em>,
45.2181 @@ -2533,9 +2533,9 @@
45.2182 ///\tparam G The type of the underlying digraph.
45.2183 ///
45.2184 ///\sa DynArcLookUp
45.2185 - ///\sa AllArcLookUp
45.2186 + ///\sa AllArcLookUp
45.2187 template<class G>
45.2188 - class ArcLookUp
45.2189 + class ArcLookUp
45.2190 {
45.2191 public:
45.2192 TEMPLATE_DIGRAPH_TYPEDEFS(G);
45.2193 @@ -2546,19 +2546,19 @@
45.2194 typename Digraph::template NodeMap<Arc> _head;
45.2195 typename Digraph::template ArcMap<Arc> _left;
45.2196 typename Digraph::template ArcMap<Arc> _right;
45.2197 -
45.2198 +
45.2199 class ArcLess {
45.2200 const Digraph &g;
45.2201 public:
45.2202 ArcLess(const Digraph &_g) : g(_g) {}
45.2203 - bool operator()(Arc a,Arc b) const
45.2204 + bool operator()(Arc a,Arc b) const
45.2205 {
45.2206 - return g.target(a)<g.target(b);
45.2207 + return g.target(a)<g.target(b);
45.2208 }
45.2209 };
45.2210 -
45.2211 +
45.2212 public:
45.2213 -
45.2214 +
45.2215 ///Constructor
45.2216
45.2217 ///Constructor.
45.2218 @@ -2566,9 +2566,9 @@
45.2219 ///It builds up the search database, which remains valid until the digraph
45.2220 ///changes.
45.2221 ArcLookUp(const Digraph &g) :_g(g),_head(g),_left(g),_right(g) {refresh();}
45.2222 -
45.2223 +
45.2224 private:
45.2225 - Arc refreshRec(std::vector<Arc> &v,int a,int b)
45.2226 + Arc refreshRec(std::vector<Arc> &v,int a,int b)
45.2227 {
45.2228 int m=(a+b)/2;
45.2229 Arc me=v[m];
45.2230 @@ -2583,13 +2583,13 @@
45.2231 ///
45.2232 ///It runs in time <em>O(d</em>log<em>d)</em>, where <em>d</em> is
45.2233 ///the number of the outgoing arcs of \c n.
45.2234 - void refresh(Node n)
45.2235 + void refresh(Node n)
45.2236 {
45.2237 std::vector<Arc> v;
45.2238 for(OutArcIt e(_g,n);e!=INVALID;++e) v.push_back(e);
45.2239 if(v.size()) {
45.2240 - std::sort(v.begin(),v.end(),ArcLess(_g));
45.2241 - _head[n]=refreshRec(v,0,v.size()-1);
45.2242 + std::sort(v.begin(),v.end(),ArcLess(_g));
45.2243 + _head[n]=refreshRec(v,0,v.size()-1);
45.2244 }
45.2245 else _head[n]=INVALID;
45.2246 }
45.2247 @@ -2602,13 +2602,13 @@
45.2248 ///the number of the arcs of \c n and <em>D</em> is the maximum
45.2249 ///out-degree of the digraph.
45.2250
45.2251 - void refresh()
45.2252 + void refresh()
45.2253 {
45.2254 for(NodeIt n(_g);n!=INVALID;++n) refresh(n);
45.2255 }
45.2256 -
45.2257 +
45.2258 ///Find an arc between two nodes.
45.2259 -
45.2260 +
45.2261 ///Find an arc between two nodes in time <em>O(</em>log<em>d)</em>, where
45.2262 /// <em>d</em> is the number of outgoing arcs of \c s.
45.2263 ///\param s The source node
45.2264 @@ -2625,15 +2625,15 @@
45.2265 {
45.2266 Arc e;
45.2267 for(e=_head[s];
45.2268 - e!=INVALID&&_g.target(e)!=t;
45.2269 - e = t < _g.target(e)?_left[e]:_right[e]) ;
45.2270 + e!=INVALID&&_g.target(e)!=t;
45.2271 + e = t < _g.target(e)?_left[e]:_right[e]) ;
45.2272 return e;
45.2273 }
45.2274
45.2275 };
45.2276
45.2277 ///Fast look up of all arcs between given endpoints.
45.2278 -
45.2279 +
45.2280 ///\ingroup gutils
45.2281 ///This class is the same as \ref ArcLookUp, with the addition
45.2282 ///that it makes it possible to find all arcs between given endpoints.
45.2283 @@ -2646,7 +2646,7 @@
45.2284 ///\tparam G The type of the underlying digraph.
45.2285 ///
45.2286 ///\sa DynArcLookUp
45.2287 - ///\sa ArcLookUp
45.2288 + ///\sa ArcLookUp
45.2289 template<class G>
45.2290 class AllArcLookUp : public ArcLookUp<G>
45.2291 {
45.2292 @@ -2657,26 +2657,26 @@
45.2293
45.2294 TEMPLATE_DIGRAPH_TYPEDEFS(G);
45.2295 typedef G Digraph;
45.2296 -
45.2297 +
45.2298 typename Digraph::template ArcMap<Arc> _next;
45.2299 -
45.2300 +
45.2301 Arc refreshNext(Arc head,Arc next=INVALID)
45.2302 {
45.2303 if(head==INVALID) return next;
45.2304 else {
45.2305 - next=refreshNext(_right[head],next);
45.2306 -// _next[head]=next;
45.2307 - _next[head]=( next!=INVALID && _g.target(next)==_g.target(head))
45.2308 - ? next : INVALID;
45.2309 - return refreshNext(_left[head],head);
45.2310 + next=refreshNext(_right[head],next);
45.2311 +// _next[head]=next;
45.2312 + _next[head]=( next!=INVALID && _g.target(next)==_g.target(head))
45.2313 + ? next : INVALID;
45.2314 + return refreshNext(_left[head],head);
45.2315 }
45.2316 }
45.2317 -
45.2318 +
45.2319 void refreshNext()
45.2320 {
45.2321 for(NodeIt n(_g);n!=INVALID;++n) refreshNext(_head[n]);
45.2322 }
45.2323 -
45.2324 +
45.2325 public:
45.2326 ///Constructor
45.2327
45.2328 @@ -2692,13 +2692,13 @@
45.2329 ///
45.2330 ///It runs in time <em>O(d</em>log<em>d)</em>, where <em>d</em> is
45.2331 ///the number of the outgoing arcs of \c n.
45.2332 -
45.2333 - void refresh(Node n)
45.2334 +
45.2335 + void refresh(Node n)
45.2336 {
45.2337 ArcLookUp<G>::refresh(n);
45.2338 refreshNext(_head[n]);
45.2339 }
45.2340 -
45.2341 +
45.2342 ///Refresh the full data structure.
45.2343
45.2344 ///Build up the full search database. In fact, it simply calls
45.2345 @@ -2708,13 +2708,13 @@
45.2346 ///the number of the arcs of \c n and <em>D</em> is the maximum
45.2347 ///out-degree of the digraph.
45.2348
45.2349 - void refresh()
45.2350 + void refresh()
45.2351 {
45.2352 for(NodeIt n(_g);n!=INVALID;++n) refresh(_head[n]);
45.2353 }
45.2354 -
45.2355 +
45.2356 ///Find an arc between two nodes.
45.2357 -
45.2358 +
45.2359 ///Find an arc between two nodes.
45.2360 ///\param s The source node
45.2361 ///\param t The target node
45.2362 @@ -2750,7 +2750,7 @@
45.2363 return prev==INVALID?(*this)(s,t):_next[prev];
45.2364 }
45.2365 #endif
45.2366 -
45.2367 +
45.2368 };
45.2369
45.2370 /// @}
46.1 --- a/lemon/kruskal.h Sun Jul 13 16:46:56 2008 +0100
46.2 +++ b/lemon/kruskal.h Sun Jul 13 19:51:02 2008 +0100
46.3 @@ -1,6 +1,6 @@
46.4 -/* -*- C++ -*-
46.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
46.6 *
46.7 - * This file is a part of LEMON, a generic C++ optimization library
46.8 + * This file is a part of LEMON, a generic C++ optimization library.
46.9 *
46.10 * Copyright (C) 2003-2008
46.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
46.12 @@ -45,18 +45,18 @@
46.13
46.14 template <typename Digraph, typename In, typename Out>
46.15 typename disable_if<lemon::UndirectedTagIndicator<Digraph>,
46.16 - typename In::value_type::second_type >::type
46.17 + typename In::value_type::second_type >::type
46.18 kruskal(const Digraph& digraph, const In& in, Out& out,dummy<0> = 0) {
46.19 typedef typename In::value_type::second_type Value;
46.20 typedef typename Digraph::template NodeMap<int> IndexMap;
46.21 typedef typename Digraph::Node Node;
46.22 -
46.23 +
46.24 IndexMap index(digraph);
46.25 UnionFind<IndexMap> uf(index);
46.26 for (typename Digraph::NodeIt it(digraph); it != INVALID; ++it) {
46.27 uf.insert(it);
46.28 }
46.29 -
46.30 +
46.31 Value tree_value = 0;
46.32 for (typename In::const_iterator it = in.begin(); it != in.end(); ++it) {
46.33 if (uf.join(digraph.target(it->first),digraph.source(it->first))) {
46.34 @@ -74,18 +74,18 @@
46.35
46.36 template <typename Graph, typename In, typename Out>
46.37 typename enable_if<lemon::UndirectedTagIndicator<Graph>,
46.38 - typename In::value_type::second_type >::type
46.39 + typename In::value_type::second_type >::type
46.40 kruskal(const Graph& graph, const In& in, Out& out,dummy<1> = 1) {
46.41 typedef typename In::value_type::second_type Value;
46.42 typedef typename Graph::template NodeMap<int> IndexMap;
46.43 typedef typename Graph::Node Node;
46.44 -
46.45 +
46.46 IndexMap index(graph);
46.47 UnionFind<IndexMap> uf(index);
46.48 for (typename Graph::NodeIt it(graph); it != INVALID; ++it) {
46.49 uf.insert(it);
46.50 }
46.51 -
46.52 +
46.53 Value tree_value = 0;
46.54 for (typename In::const_iterator it = in.begin(); it != in.end(); ++it) {
46.55 if (uf.join(graph.u(it->first),graph.v(it->first))) {
46.56 @@ -104,7 +104,7 @@
46.57 struct PairComp {
46.58 typedef typename Sequence::value_type Value;
46.59 bool operator()(const Value& left, const Value& right) {
46.60 - return left.second < right.second;
46.61 + return left.second < right.second;
46.62 }
46.63 };
46.64
46.65 @@ -114,7 +114,7 @@
46.66 };
46.67
46.68 template <typename In>
46.69 - struct SequenceInputIndicator<In,
46.70 + struct SequenceInputIndicator<In,
46.71 typename exists<typename In::value_type::first_type>::type> {
46.72 static const bool value = true;
46.73 };
46.74 @@ -125,7 +125,7 @@
46.75 };
46.76
46.77 template <typename In>
46.78 - struct MapInputIndicator<In,
46.79 + struct MapInputIndicator<In,
46.80 typename exists<typename In::Value>::type> {
46.81 static const bool value = true;
46.82 };
46.83 @@ -134,9 +134,9 @@
46.84 struct SequenceOutputIndicator {
46.85 static const bool value = false;
46.86 };
46.87 -
46.88 +
46.89 template <typename Out>
46.90 - struct SequenceOutputIndicator<Out,
46.91 + struct SequenceOutputIndicator<Out,
46.92 typename exists<typename Out::value_type>::type> {
46.93 static const bool value = true;
46.94 };
46.95 @@ -147,7 +147,7 @@
46.96 };
46.97
46.98 template <typename Out>
46.99 - struct MapOutputIndicator<Out,
46.100 + struct MapOutputIndicator<Out,
46.101 typename exists<typename Out::Value>::type> {
46.102 static const bool value = true;
46.103 };
46.104 @@ -157,18 +157,18 @@
46.105
46.106 template <typename In>
46.107 struct KruskalValueSelector<In,
46.108 - typename enable_if<SequenceInputIndicator<In>, void>::type>
46.109 + typename enable_if<SequenceInputIndicator<In>, void>::type>
46.110 {
46.111 typedef typename In::value_type::second_type Value;
46.112 - };
46.113 + };
46.114
46.115 template <typename In>
46.116 struct KruskalValueSelector<In,
46.117 - typename enable_if<MapInputIndicator<In>, void>::type>
46.118 + typename enable_if<MapInputIndicator<In>, void>::type>
46.119 {
46.120 typedef typename In::Value Value;
46.121 - };
46.122 -
46.123 + };
46.124 +
46.125 template <typename Graph, typename In, typename Out,
46.126 typename InEnable = void>
46.127 struct KruskalInputSelector {};
46.128 @@ -176,10 +176,10 @@
46.129 template <typename Graph, typename In, typename Out,
46.130 typename InEnable = void>
46.131 struct KruskalOutputSelector {};
46.132 -
46.133 +
46.134 template <typename Graph, typename In, typename Out>
46.135 struct KruskalInputSelector<Graph, In, Out,
46.136 - typename enable_if<SequenceInputIndicator<In>, void>::type >
46.137 + typename enable_if<SequenceInputIndicator<In>, void>::type >
46.138 {
46.139 typedef typename In::value_type::second_type Value;
46.140
46.141 @@ -192,7 +192,7 @@
46.142
46.143 template <typename Graph, typename In, typename Out>
46.144 struct KruskalInputSelector<Graph, In, Out,
46.145 - typename enable_if<MapInputIndicator<In>, void>::type >
46.146 + typename enable_if<MapInputIndicator<In>, void>::type >
46.147 {
46.148 typedef typename In::Value Value;
46.149 static Value kruskal(const Graph& graph, const In& in, Out& out) {
46.150 @@ -201,7 +201,7 @@
46.151 typedef typename ItemSetTraits<Graph, MapArc>::ItemIt MapArcIt;
46.152 typedef std::vector<std::pair<MapArc, Value> > Sequence;
46.153 Sequence seq;
46.154 -
46.155 +
46.156 for (MapArcIt it(graph); it != INVALID; ++it) {
46.157 seq.push_back(std::make_pair(it, in[it]));
46.158 }
46.159 @@ -224,7 +224,7 @@
46.160
46.161 template <typename Graph, typename In, typename Out>
46.162 struct KruskalOutputSelector<Graph, In, Out,
46.163 - typename enable_if<SequenceOutputIndicator<Out>, void>::type >
46.164 + typename enable_if<SequenceOutputIndicator<Out>, void>::type >
46.165 {
46.166 typedef typename In::value_type::second_type Value;
46.167
46.168 @@ -238,7 +238,7 @@
46.169
46.170 template <typename Graph, typename In, typename Out>
46.171 struct KruskalOutputSelector<Graph, In, Out,
46.172 - typename enable_if<MapOutputIndicator<Out>, void>::type >
46.173 + typename enable_if<MapOutputIndicator<Out>, void>::type >
46.174 {
46.175 typedef typename In::value_type::second_type Value;
46.176
46.177 @@ -254,17 +254,17 @@
46.178 /// \brief Kruskal algorithm to find a minimum cost spanning tree of
46.179 /// a graph.
46.180 ///
46.181 - /// This function runs Kruskal's algorithm to find a minimum cost
46.182 + /// This function runs Kruskal's algorithm to find a minimum cost
46.183 /// spanning tree.
46.184 /// Due to some C++ hacking, it accepts various input and output types.
46.185 ///
46.186 /// \param g The graph the algorithm runs on.
46.187 - /// It can be either \ref concepts::Digraph "directed" or
46.188 + /// It can be either \ref concepts::Digraph "directed" or
46.189 /// \ref concepts::Graph "undirected".
46.190 - /// If the graph is directed, the algorithm consider it to be
46.191 + /// If the graph is directed, the algorithm consider it to be
46.192 /// undirected by disregarding the direction of the arcs.
46.193 ///
46.194 - /// \param in This object is used to describe the arc/edge costs.
46.195 + /// \param in This object is used to describe the arc/edge costs.
46.196 /// It can be one of the following choices.
46.197 /// - An STL compatible 'Forward Container' with
46.198 /// <tt>std::pair<GR::Arc,X></tt> or
46.199 @@ -272,7 +272,7 @@
46.200 /// \c X is the type of the costs. The pairs indicates the arcs/edges
46.201 /// along with the assigned cost. <em>They must be in a
46.202 /// cost-ascending order.</em>
46.203 - /// - Any readable arc/edge map. The values of the map indicate the
46.204 + /// - Any readable arc/edge map. The values of the map indicate the
46.205 /// arc/edge costs.
46.206 ///
46.207 /// \retval out Here we also have a choice.
46.208 @@ -292,10 +292,10 @@
46.209 /// kruskal(g,cost,tree.begin());
46.210 ///\endcode
46.211 /// Or if we don't know in advance the size of the tree, we can
46.212 - /// write this.
46.213 + /// write this.
46.214 ///\code
46.215 /// std::vector<Arc> tree;
46.216 - /// kruskal(g,cost,std::back_inserter(tree));
46.217 + /// kruskal(g,cost,std::back_inserter(tree));
46.218 ///\endcode
46.219 ///
46.220 /// \return The total cost of the found spanning tree.
46.221 @@ -307,18 +307,18 @@
46.222 #ifdef DOXYGEN
46.223 template <class Graph, class In, class Out>
46.224 Value kruskal(GR const& g, const In& in, Out& out)
46.225 -#else
46.226 +#else
46.227 template <class Graph, class In, class Out>
46.228 - inline typename _kruskal_bits::KruskalValueSelector<In>::Value
46.229 - kruskal(const Graph& graph, const In& in, Out& out)
46.230 + inline typename _kruskal_bits::KruskalValueSelector<In>::Value
46.231 + kruskal(const Graph& graph, const In& in, Out& out)
46.232 #endif
46.233 {
46.234 return _kruskal_bits::KruskalInputSelector<Graph, In, Out>::
46.235 kruskal(graph, in, out);
46.236 }
46.237
46.238 -
46.239 -
46.240 +
46.241 +
46.242
46.243 template <class Graph, class In, class Out>
46.244 inline typename _kruskal_bits::KruskalValueSelector<In>::Value
46.245 @@ -326,7 +326,7 @@
46.246 {
46.247 return _kruskal_bits::KruskalInputSelector<Graph, In, const Out>::
46.248 kruskal(graph, in, out);
46.249 - }
46.250 + }
46.251
46.252 } //namespace lemon
46.253
47.1 --- a/lemon/lgf_reader.h Sun Jul 13 16:46:56 2008 +0100
47.2 +++ b/lemon/lgf_reader.h Sun Jul 13 19:51:02 2008 +0100
47.3 @@ -1,6 +1,6 @@
47.4 -/* -*- C++ -*-
47.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
47.6 *
47.7 - * This file is a part of LEMON, a generic C++ optimization library
47.8 + * This file is a part of LEMON, a generic C++ optimization library.
47.9 *
47.10 * Copyright (C) 2003-2008
47.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
47.12 @@ -46,26 +46,26 @@
47.13 template <typename Value>
47.14 struct DefaultConverter {
47.15 Value operator()(const std::string& str) {
47.16 - std::istringstream is(str);
47.17 - Value value;
47.18 - is >> value;
47.19 -
47.20 - char c;
47.21 - if (is >> std::ws >> c) {
47.22 - throw DataFormatError("Remaining characters in token");
47.23 - }
47.24 - return value;
47.25 + std::istringstream is(str);
47.26 + Value value;
47.27 + is >> value;
47.28 +
47.29 + char c;
47.30 + if (is >> std::ws >> c) {
47.31 + throw DataFormatError("Remaining characters in token");
47.32 + }
47.33 + return value;
47.34 }
47.35 };
47.36
47.37 template <>
47.38 struct DefaultConverter<std::string> {
47.39 std::string operator()(const std::string& str) {
47.40 - return str;
47.41 + return str;
47.42 }
47.43 };
47.44
47.45 - template <typename _Item>
47.46 + template <typename _Item>
47.47 class MapStorageBase {
47.48 public:
47.49 typedef _Item Item;
47.50 @@ -78,30 +78,30 @@
47.51
47.52 };
47.53
47.54 - template <typename _Item, typename _Map,
47.55 - typename _Converter = DefaultConverter<typename _Map::Value> >
47.56 + template <typename _Item, typename _Map,
47.57 + typename _Converter = DefaultConverter<typename _Map::Value> >
47.58 class MapStorage : public MapStorageBase<_Item> {
47.59 public:
47.60 typedef _Map Map;
47.61 typedef _Converter Converter;
47.62 typedef _Item Item;
47.63 -
47.64 +
47.65 private:
47.66 Map& _map;
47.67 Converter _converter;
47.68
47.69 public:
47.70 - MapStorage(Map& map, const Converter& converter = Converter())
47.71 - : _map(map), _converter(converter) {}
47.72 + MapStorage(Map& map, const Converter& converter = Converter())
47.73 + : _map(map), _converter(converter) {}
47.74 virtual ~MapStorage() {}
47.75
47.76 virtual void set(const Item& item ,const std::string& value) {
47.77 - _map.set(item, _converter(value));
47.78 + _map.set(item, _converter(value));
47.79 }
47.80 };
47.81
47.82 - template <typename _Graph, bool _dir, typename _Map,
47.83 - typename _Converter = DefaultConverter<typename _Map::Value> >
47.84 + template <typename _Graph, bool _dir, typename _Map,
47.85 + typename _Converter = DefaultConverter<typename _Map::Value> >
47.86 class GraphArcMapStorage : public MapStorageBase<typename _Graph::Edge> {
47.87 public:
47.88 typedef _Map Map;
47.89 @@ -109,20 +109,20 @@
47.90 typedef _Graph Graph;
47.91 typedef typename Graph::Edge Item;
47.92 static const bool dir = _dir;
47.93 -
47.94 +
47.95 private:
47.96 const Graph& _graph;
47.97 Map& _map;
47.98 Converter _converter;
47.99
47.100 public:
47.101 - GraphArcMapStorage(const Graph& graph, Map& map,
47.102 - const Converter& converter = Converter())
47.103 - : _graph(graph), _map(map), _converter(converter) {}
47.104 + GraphArcMapStorage(const Graph& graph, Map& map,
47.105 + const Converter& converter = Converter())
47.106 + : _graph(graph), _map(map), _converter(converter) {}
47.107 virtual ~GraphArcMapStorage() {}
47.108
47.109 virtual void set(const Item& item ,const std::string& value) {
47.110 - _map.set(_graph.direct(item, dir), _converter(value));
47.111 + _map.set(_graph.direct(item, dir), _converter(value));
47.112 }
47.113 };
47.114
47.115 @@ -146,10 +146,10 @@
47.116
47.117 public:
47.118 ValueStorage(Value& value, const Converter& converter = Converter())
47.119 - : _value(value), _converter(converter) {}
47.120 + : _value(value), _converter(converter) {}
47.121
47.122 virtual void set(const std::string& value) {
47.123 - _value = _converter(value);
47.124 + _value = _converter(value);
47.125 }
47.126 };
47.127
47.128 @@ -176,45 +176,45 @@
47.129 struct GraphArcLookUpConverter {
47.130 const Graph& _graph;
47.131 const std::map<std::string, typename Graph::Edge>& _map;
47.132 -
47.133 - GraphArcLookUpConverter(const Graph& graph,
47.134 - const std::map<std::string,
47.135 - typename Graph::Edge>& map)
47.136 - : _graph(graph), _map(map) {}
47.137 -
47.138 +
47.139 + GraphArcLookUpConverter(const Graph& graph,
47.140 + const std::map<std::string,
47.141 + typename Graph::Edge>& map)
47.142 + : _graph(graph), _map(map) {}
47.143 +
47.144 typename Graph::Arc operator()(const std::string& str) {
47.145 - if (str.empty() || (str[0] != '+' && str[0] != '-')) {
47.146 - throw DataFormatError("Item must start with '+' or '-'");
47.147 - }
47.148 - typename std::map<std::string, typename Graph::Edge>
47.149 - ::const_iterator it = _map.find(str.substr(1));
47.150 - if (it == _map.end()) {
47.151 - throw DataFormatError("Item not found");
47.152 - }
47.153 - return _graph.direct(it->second, str[0] == '+');
47.154 + if (str.empty() || (str[0] != '+' && str[0] != '-')) {
47.155 + throw DataFormatError("Item must start with '+' or '-'");
47.156 + }
47.157 + typename std::map<std::string, typename Graph::Edge>
47.158 + ::const_iterator it = _map.find(str.substr(1));
47.159 + if (it == _map.end()) {
47.160 + throw DataFormatError("Item not found");
47.161 + }
47.162 + return _graph.direct(it->second, str[0] == '+');
47.163 }
47.164 };
47.165
47.166 inline bool isWhiteSpace(char c) {
47.167 - return c == ' ' || c == '\t' || c == '\v' ||
47.168 - c == '\n' || c == '\r' || c == '\f';
47.169 + return c == ' ' || c == '\t' || c == '\v' ||
47.170 + c == '\n' || c == '\r' || c == '\f';
47.171 }
47.172 -
47.173 +
47.174 inline bool isOct(char c) {
47.175 - return '0' <= c && c <='7';
47.176 + return '0' <= c && c <='7';
47.177 }
47.178 -
47.179 +
47.180 inline int valueOct(char c) {
47.181 LEMON_ASSERT(isOct(c), "The character is not octal.");
47.182 return c - '0';
47.183 }
47.184
47.185 inline bool isHex(char c) {
47.186 - return ('0' <= c && c <= '9') ||
47.187 - ('a' <= c && c <= 'z') ||
47.188 - ('A' <= c && c <= 'Z');
47.189 + return ('0' <= c && c <= '9') ||
47.190 + ('a' <= c && c <= 'z') ||
47.191 + ('A' <= c && c <= 'Z');
47.192 }
47.193 -
47.194 +
47.195 inline int valueHex(char c) {
47.196 LEMON_ASSERT(isHex(c), "The character is not hexadecimal.");
47.197 if ('0' <= c && c <= '9') return c - '0';
47.198 @@ -224,95 +224,95 @@
47.199
47.200 inline bool isIdentifierFirstChar(char c) {
47.201 return ('a' <= c && c <= 'z') ||
47.202 - ('A' <= c && c <= 'Z') || c == '_';
47.203 + ('A' <= c && c <= 'Z') || c == '_';
47.204 }
47.205
47.206 inline bool isIdentifierChar(char c) {
47.207 return isIdentifierFirstChar(c) ||
47.208 - ('0' <= c && c <= '9');
47.209 + ('0' <= c && c <= '9');
47.210 }
47.211
47.212 inline char readEscape(std::istream& is) {
47.213 char c;
47.214 if (!is.get(c))
47.215 - throw DataFormatError("Escape format error");
47.216 + throw DataFormatError("Escape format error");
47.217
47.218 switch (c) {
47.219 case '\\':
47.220 - return '\\';
47.221 + return '\\';
47.222 case '\"':
47.223 - return '\"';
47.224 + return '\"';
47.225 case '\'':
47.226 - return '\'';
47.227 + return '\'';
47.228 case '\?':
47.229 - return '\?';
47.230 + return '\?';
47.231 case 'a':
47.232 - return '\a';
47.233 + return '\a';
47.234 case 'b':
47.235 - return '\b';
47.236 + return '\b';
47.237 case 'f':
47.238 - return '\f';
47.239 + return '\f';
47.240 case 'n':
47.241 - return '\n';
47.242 + return '\n';
47.243 case 'r':
47.244 - return '\r';
47.245 + return '\r';
47.246 case 't':
47.247 - return '\t';
47.248 + return '\t';
47.249 case 'v':
47.250 - return '\v';
47.251 + return '\v';
47.252 case 'x':
47.253 - {
47.254 - int code;
47.255 - if (!is.get(c) || !isHex(c))
47.256 - throw DataFormatError("Escape format error");
47.257 - else if (code = valueHex(c), !is.get(c) || !isHex(c)) is.putback(c);
47.258 - else code = code * 16 + valueHex(c);
47.259 - return code;
47.260 - }
47.261 + {
47.262 + int code;
47.263 + if (!is.get(c) || !isHex(c))
47.264 + throw DataFormatError("Escape format error");
47.265 + else if (code = valueHex(c), !is.get(c) || !isHex(c)) is.putback(c);
47.266 + else code = code * 16 + valueHex(c);
47.267 + return code;
47.268 + }
47.269 default:
47.270 - {
47.271 - int code;
47.272 - if (!isOct(c))
47.273 - throw DataFormatError("Escape format error");
47.274 - else if (code = valueOct(c), !is.get(c) || !isOct(c))
47.275 - is.putback(c);
47.276 - else if (code = code * 8 + valueOct(c), !is.get(c) || !isOct(c))
47.277 - is.putback(c);
47.278 - else code = code * 8 + valueOct(c);
47.279 - return code;
47.280 - }
47.281 - }
47.282 + {
47.283 + int code;
47.284 + if (!isOct(c))
47.285 + throw DataFormatError("Escape format error");
47.286 + else if (code = valueOct(c), !is.get(c) || !isOct(c))
47.287 + is.putback(c);
47.288 + else if (code = code * 8 + valueOct(c), !is.get(c) || !isOct(c))
47.289 + is.putback(c);
47.290 + else code = code * 8 + valueOct(c);
47.291 + return code;
47.292 + }
47.293 + }
47.294 }
47.295 -
47.296 +
47.297 inline std::istream& readToken(std::istream& is, std::string& str) {
47.298 std::ostringstream os;
47.299
47.300 char c;
47.301 is >> std::ws;
47.302 -
47.303 - if (!is.get(c))
47.304 - return is;
47.305 +
47.306 + if (!is.get(c))
47.307 + return is;
47.308
47.309 if (c == '\"') {
47.310 - while (is.get(c) && c != '\"') {
47.311 - if (c == '\\')
47.312 - c = readEscape(is);
47.313 - os << c;
47.314 - }
47.315 - if (!is)
47.316 - throw DataFormatError("Quoted format error");
47.317 + while (is.get(c) && c != '\"') {
47.318 + if (c == '\\')
47.319 + c = readEscape(is);
47.320 + os << c;
47.321 + }
47.322 + if (!is)
47.323 + throw DataFormatError("Quoted format error");
47.324 } else {
47.325 - is.putback(c);
47.326 - while (is.get(c) && !isWhiteSpace(c)) {
47.327 - if (c == '\\')
47.328 - c = readEscape(is);
47.329 - os << c;
47.330 - }
47.331 - if (!is) {
47.332 - is.clear();
47.333 - } else {
47.334 - is.putback(c);
47.335 - }
47.336 + is.putback(c);
47.337 + while (is.get(c) && !isWhiteSpace(c)) {
47.338 + if (c == '\\')
47.339 + c = readEscape(is);
47.340 + os << c;
47.341 + }
47.342 + if (!is) {
47.343 + is.clear();
47.344 + } else {
47.345 + is.putback(c);
47.346 + }
47.347 }
47.348 str = os.str();
47.349 return is;
47.350 @@ -331,28 +331,28 @@
47.351 Functor _functor;
47.352
47.353 public:
47.354 -
47.355 +
47.356 LineSection(const Functor& functor) : _functor(functor) {}
47.357 virtual ~LineSection() {}
47.358
47.359 virtual void process(std::istream& is, int& line_num) {
47.360 - char c;
47.361 - std::string line;
47.362 - while (is.get(c) && c != '@') {
47.363 - if (c == '\n') {
47.364 - ++line_num;
47.365 - } else if (c == '#') {
47.366 - getline(is, line);
47.367 - ++line_num;
47.368 - } else if (!isWhiteSpace(c)) {
47.369 - is.putback(c);
47.370 - getline(is, line);
47.371 - _functor(line);
47.372 - ++line_num;
47.373 - }
47.374 - }
47.375 - if (is) is.putback(c);
47.376 - else if (is.eof()) is.clear();
47.377 + char c;
47.378 + std::string line;
47.379 + while (is.get(c) && c != '@') {
47.380 + if (c == '\n') {
47.381 + ++line_num;
47.382 + } else if (c == '#') {
47.383 + getline(is, line);
47.384 + ++line_num;
47.385 + } else if (!isWhiteSpace(c)) {
47.386 + is.putback(c);
47.387 + getline(is, line);
47.388 + _functor(line);
47.389 + ++line_num;
47.390 + }
47.391 + }
47.392 + if (is) is.putback(c);
47.393 + else if (is.eof()) is.clear();
47.394 }
47.395 };
47.396
47.397 @@ -363,27 +363,27 @@
47.398 Functor _functor;
47.399
47.400 public:
47.401 -
47.402 +
47.403 StreamSection(const Functor& functor) : _functor(functor) {}
47.404 - virtual ~StreamSection() {}
47.405 + virtual ~StreamSection() {}
47.406
47.407 virtual void process(std::istream& is, int& line_num) {
47.408 - _functor(is, line_num);
47.409 - char c;
47.410 - std::string line;
47.411 - while (is.get(c) && c != '@') {
47.412 - if (c == '\n') {
47.413 - ++line_num;
47.414 - } else if (!isWhiteSpace(c)) {
47.415 - getline(is, line);
47.416 - ++line_num;
47.417 - }
47.418 - }
47.419 - if (is) is.putback(c);
47.420 - else if (is.eof()) is.clear();
47.421 + _functor(is, line_num);
47.422 + char c;
47.423 + std::string line;
47.424 + while (is.get(c) && c != '@') {
47.425 + if (c == '\n') {
47.426 + ++line_num;
47.427 + } else if (!isWhiteSpace(c)) {
47.428 + getline(is, line);
47.429 + ++line_num;
47.430 + }
47.431 + }
47.432 + if (is) is.putback(c);
47.433 + else if (is.eof()) is.clear();
47.434 }
47.435 };
47.436 -
47.437 +
47.438 }
47.439
47.440 template <typename Digraph>
47.441 @@ -399,7 +399,7 @@
47.442 DigraphReader<Digraph> digraphReader(const char *fn, Digraph& digraph);
47.443
47.444 /// \ingroup lemon_io
47.445 - ///
47.446 + ///
47.447 /// \brief \ref lgf-format "LGF" reader for directed graphs
47.448 ///
47.449 /// This utility reads an \ref lgf-format "LGF" file.
47.450 @@ -453,7 +453,7 @@
47.451
47.452 typedef _Digraph Digraph;
47.453 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
47.454 -
47.455 +
47.456 private:
47.457
47.458
47.459 @@ -470,16 +470,16 @@
47.460 NodeIndex _node_index;
47.461 typedef std::map<std::string, Arc> ArcIndex;
47.462 ArcIndex _arc_index;
47.463 -
47.464 - typedef std::vector<std::pair<std::string,
47.465 - _reader_bits::MapStorageBase<Node>*> > NodeMaps;
47.466 - NodeMaps _node_maps;
47.467 +
47.468 + typedef std::vector<std::pair<std::string,
47.469 + _reader_bits::MapStorageBase<Node>*> > NodeMaps;
47.470 + NodeMaps _node_maps;
47.471
47.472 typedef std::vector<std::pair<std::string,
47.473 _reader_bits::MapStorageBase<Arc>*> >ArcMaps;
47.474 ArcMaps _arc_maps;
47.475
47.476 - typedef std::multimap<std::string, _reader_bits::ValueStorageBase*>
47.477 + typedef std::multimap<std::string, _reader_bits::ValueStorageBase*>
47.478 Attributes;
47.479 Attributes _attributes;
47.480
47.481 @@ -498,69 +498,69 @@
47.482 ///
47.483 /// Construct a directed graph reader, which reads from the given
47.484 /// input stream.
47.485 - DigraphReader(std::istream& is, Digraph& digraph)
47.486 + DigraphReader(std::istream& is, Digraph& digraph)
47.487 : _is(&is), local_is(false), _digraph(digraph),
47.488 - _use_nodes(false), _use_arcs(false),
47.489 - _skip_nodes(false), _skip_arcs(false) {}
47.490 + _use_nodes(false), _use_arcs(false),
47.491 + _skip_nodes(false), _skip_arcs(false) {}
47.492
47.493 /// \brief Constructor
47.494 ///
47.495 /// Construct a directed graph reader, which reads from the given
47.496 /// file.
47.497 - DigraphReader(const std::string& fn, Digraph& digraph)
47.498 + DigraphReader(const std::string& fn, Digraph& digraph)
47.499 : _is(new std::ifstream(fn.c_str())), local_is(true), _digraph(digraph),
47.500 - _use_nodes(false), _use_arcs(false),
47.501 - _skip_nodes(false), _skip_arcs(false) {}
47.502 -
47.503 + _use_nodes(false), _use_arcs(false),
47.504 + _skip_nodes(false), _skip_arcs(false) {}
47.505 +
47.506 /// \brief Constructor
47.507 ///
47.508 /// Construct a directed graph reader, which reads from the given
47.509 /// file.
47.510 - DigraphReader(const char* fn, Digraph& digraph)
47.511 + DigraphReader(const char* fn, Digraph& digraph)
47.512 : _is(new std::ifstream(fn)), local_is(true), _digraph(digraph),
47.513 - _use_nodes(false), _use_arcs(false),
47.514 - _skip_nodes(false), _skip_arcs(false) {}
47.515 + _use_nodes(false), _use_arcs(false),
47.516 + _skip_nodes(false), _skip_arcs(false) {}
47.517
47.518 /// \brief Destructor
47.519 ~DigraphReader() {
47.520 - for (typename NodeMaps::iterator it = _node_maps.begin();
47.521 - it != _node_maps.end(); ++it) {
47.522 - delete it->second;
47.523 + for (typename NodeMaps::iterator it = _node_maps.begin();
47.524 + it != _node_maps.end(); ++it) {
47.525 + delete it->second;
47.526 }
47.527
47.528 - for (typename ArcMaps::iterator it = _arc_maps.begin();
47.529 - it != _arc_maps.end(); ++it) {
47.530 - delete it->second;
47.531 + for (typename ArcMaps::iterator it = _arc_maps.begin();
47.532 + it != _arc_maps.end(); ++it) {
47.533 + delete it->second;
47.534 }
47.535
47.536 - for (typename Attributes::iterator it = _attributes.begin();
47.537 - it != _attributes.end(); ++it) {
47.538 - delete it->second;
47.539 + for (typename Attributes::iterator it = _attributes.begin();
47.540 + it != _attributes.end(); ++it) {
47.541 + delete it->second;
47.542 }
47.543
47.544 if (local_is) {
47.545 - delete _is;
47.546 + delete _is;
47.547 }
47.548
47.549 }
47.550
47.551 private:
47.552
47.553 - friend DigraphReader<Digraph> digraphReader<>(std::istream& is,
47.554 - Digraph& digraph);
47.555 - friend DigraphReader<Digraph> digraphReader<>(const std::string& fn,
47.556 - Digraph& digraph);
47.557 - friend DigraphReader<Digraph> digraphReader<>(const char *fn,
47.558 - Digraph& digraph);
47.559 -
47.560 - DigraphReader(DigraphReader& other)
47.561 + friend DigraphReader<Digraph> digraphReader<>(std::istream& is,
47.562 + Digraph& digraph);
47.563 + friend DigraphReader<Digraph> digraphReader<>(const std::string& fn,
47.564 + Digraph& digraph);
47.565 + friend DigraphReader<Digraph> digraphReader<>(const char *fn,
47.566 + Digraph& digraph);
47.567 +
47.568 + DigraphReader(DigraphReader& other)
47.569 : _is(other._is), local_is(other.local_is), _digraph(other._digraph),
47.570 - _use_nodes(other._use_nodes), _use_arcs(other._use_arcs),
47.571 - _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
47.572 + _use_nodes(other._use_nodes), _use_arcs(other._use_arcs),
47.573 + _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
47.574
47.575 other._is = 0;
47.576 other.local_is = false;
47.577 -
47.578 +
47.579 _node_index.swap(other._node_index);
47.580 _arc_index.swap(other._arc_index);
47.581
47.582 @@ -580,15 +580,15 @@
47.583
47.584 /// \name Reading rules
47.585 /// @{
47.586 -
47.587 +
47.588 /// \brief Node map reading rule
47.589 ///
47.590 /// Add a node map reading rule to the reader.
47.591 template <typename Map>
47.592 DigraphReader& nodeMap(const std::string& caption, Map& map) {
47.593 checkConcept<concepts::WriteMap<Node, typename Map::Value>, Map>();
47.594 - _reader_bits::MapStorageBase<Node>* storage =
47.595 - new _reader_bits::MapStorage<Node, Map>(map);
47.596 + _reader_bits::MapStorageBase<Node>* storage =
47.597 + new _reader_bits::MapStorage<Node, Map>(map);
47.598 _node_maps.push_back(std::make_pair(caption, storage));
47.599 return *this;
47.600 }
47.601 @@ -598,11 +598,11 @@
47.602 /// Add a node map reading rule with specialized converter to the
47.603 /// reader.
47.604 template <typename Map, typename Converter>
47.605 - DigraphReader& nodeMap(const std::string& caption, Map& map,
47.606 - const Converter& converter = Converter()) {
47.607 + DigraphReader& nodeMap(const std::string& caption, Map& map,
47.608 + const Converter& converter = Converter()) {
47.609 checkConcept<concepts::WriteMap<Node, typename Map::Value>, Map>();
47.610 - _reader_bits::MapStorageBase<Node>* storage =
47.611 - new _reader_bits::MapStorage<Node, Map, Converter>(map, converter);
47.612 + _reader_bits::MapStorageBase<Node>* storage =
47.613 + new _reader_bits::MapStorage<Node, Map, Converter>(map, converter);
47.614 _node_maps.push_back(std::make_pair(caption, storage));
47.615 return *this;
47.616 }
47.617 @@ -613,8 +613,8 @@
47.618 template <typename Map>
47.619 DigraphReader& arcMap(const std::string& caption, Map& map) {
47.620 checkConcept<concepts::WriteMap<Arc, typename Map::Value>, Map>();
47.621 - _reader_bits::MapStorageBase<Arc>* storage =
47.622 - new _reader_bits::MapStorage<Arc, Map>(map);
47.623 + _reader_bits::MapStorageBase<Arc>* storage =
47.624 + new _reader_bits::MapStorage<Arc, Map>(map);
47.625 _arc_maps.push_back(std::make_pair(caption, storage));
47.626 return *this;
47.627 }
47.628 @@ -624,11 +624,11 @@
47.629 /// Add an arc map reading rule with specialized converter to the
47.630 /// reader.
47.631 template <typename Map, typename Converter>
47.632 - DigraphReader& arcMap(const std::string& caption, Map& map,
47.633 - const Converter& converter = Converter()) {
47.634 + DigraphReader& arcMap(const std::string& caption, Map& map,
47.635 + const Converter& converter = Converter()) {
47.636 checkConcept<concepts::WriteMap<Arc, typename Map::Value>, Map>();
47.637 - _reader_bits::MapStorageBase<Arc>* storage =
47.638 - new _reader_bits::MapStorage<Arc, Map, Converter>(map, converter);
47.639 + _reader_bits::MapStorageBase<Arc>* storage =
47.640 + new _reader_bits::MapStorage<Arc, Map, Converter>(map, converter);
47.641 _arc_maps.push_back(std::make_pair(caption, storage));
47.642 return *this;
47.643 }
47.644 @@ -638,8 +638,8 @@
47.645 /// Add an attribute reading rule to the reader.
47.646 template <typename Value>
47.647 DigraphReader& attribute(const std::string& caption, Value& value) {
47.648 - _reader_bits::ValueStorageBase* storage =
47.649 - new _reader_bits::ValueStorage<Value>(value);
47.650 + _reader_bits::ValueStorageBase* storage =
47.651 + new _reader_bits::ValueStorage<Value>(value);
47.652 _attributes.insert(std::make_pair(caption, storage));
47.653 return *this;
47.654 }
47.655 @@ -649,10 +649,10 @@
47.656 /// Add an attribute reading rule with specialized converter to the
47.657 /// reader.
47.658 template <typename Value, typename Converter>
47.659 - DigraphReader& attribute(const std::string& caption, Value& value,
47.660 - const Converter& converter = Converter()) {
47.661 - _reader_bits::ValueStorageBase* storage =
47.662 - new _reader_bits::ValueStorage<Value, Converter>(value, converter);
47.663 + DigraphReader& attribute(const std::string& caption, Value& value,
47.664 + const Converter& converter = Converter()) {
47.665 + _reader_bits::ValueStorageBase* storage =
47.666 + new _reader_bits::ValueStorage<Value, Converter>(value, converter);
47.667 _attributes.insert(std::make_pair(caption, storage));
47.668 return *this;
47.669 }
47.670 @@ -663,8 +663,8 @@
47.671 DigraphReader& node(const std::string& caption, Node& node) {
47.672 typedef _reader_bits::MapLookUpConverter<Node> Converter;
47.673 Converter converter(_node_index);
47.674 - _reader_bits::ValueStorageBase* storage =
47.675 - new _reader_bits::ValueStorage<Node, Converter>(node, converter);
47.676 + _reader_bits::ValueStorageBase* storage =
47.677 + new _reader_bits::ValueStorage<Node, Converter>(node, converter);
47.678 _attributes.insert(std::make_pair(caption, storage));
47.679 return *this;
47.680 }
47.681 @@ -675,8 +675,8 @@
47.682 DigraphReader& arc(const std::string& caption, Arc& arc) {
47.683 typedef _reader_bits::MapLookUpConverter<Arc> Converter;
47.684 Converter converter(_arc_index);
47.685 - _reader_bits::ValueStorageBase* storage =
47.686 - new _reader_bits::ValueStorage<Arc, Converter>(arc, converter);
47.687 + _reader_bits::ValueStorageBase* storage =
47.688 + new _reader_bits::ValueStorage<Arc, Converter>(arc, converter);
47.689 _attributes.insert(std::make_pair(caption, storage));
47.690 return *this;
47.691 }
47.692 @@ -722,11 +722,11 @@
47.693 template <typename Map>
47.694 DigraphReader& useNodes(const Map& map) {
47.695 checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
47.696 - LEMON_ASSERT(!_use_nodes, "Multiple usage of useNodes() member");
47.697 + LEMON_ASSERT(!_use_nodes, "Multiple usage of useNodes() member");
47.698 _use_nodes = true;
47.699 _writer_bits::DefaultConverter<typename Map::Value> converter;
47.700 for (NodeIt n(_digraph); n != INVALID; ++n) {
47.701 - _node_index.insert(std::make_pair(converter(map[n]), n));
47.702 + _node_index.insert(std::make_pair(converter(map[n]), n));
47.703 }
47.704 return *this;
47.705 }
47.706 @@ -737,13 +737,13 @@
47.707 /// label map and a functor which converts the label map values to
47.708 /// \c std::string.
47.709 template <typename Map, typename Converter>
47.710 - DigraphReader& useNodes(const Map& map,
47.711 - const Converter& converter = Converter()) {
47.712 + DigraphReader& useNodes(const Map& map,
47.713 + const Converter& converter = Converter()) {
47.714 checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
47.715 - LEMON_ASSERT(!_use_nodes, "Multiple usage of useNodes() member");
47.716 + LEMON_ASSERT(!_use_nodes, "Multiple usage of useNodes() member");
47.717 _use_nodes = true;
47.718 for (NodeIt n(_digraph); n != INVALID; ++n) {
47.719 - _node_index.insert(std::make_pair(converter(map[n]), n));
47.720 + _node_index.insert(std::make_pair(converter(map[n]), n));
47.721 }
47.722 return *this;
47.723 }
47.724 @@ -759,7 +759,7 @@
47.725 _use_arcs = true;
47.726 _writer_bits::DefaultConverter<typename Map::Value> converter;
47.727 for (ArcIt a(_digraph); a != INVALID; ++a) {
47.728 - _arc_index.insert(std::make_pair(converter(map[a]), a));
47.729 + _arc_index.insert(std::make_pair(converter(map[a]), a));
47.730 }
47.731 return *this;
47.732 }
47.733 @@ -770,13 +770,13 @@
47.734 /// label map and a functor which converts the label map values to
47.735 /// \c std::string.
47.736 template <typename Map, typename Converter>
47.737 - DigraphReader& useArcs(const Map& map,
47.738 - const Converter& converter = Converter()) {
47.739 + DigraphReader& useArcs(const Map& map,
47.740 + const Converter& converter = Converter()) {
47.741 checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>();
47.742 - LEMON_ASSERT(!_use_arcs, "Multiple usage of useArcs() member");
47.743 + LEMON_ASSERT(!_use_arcs, "Multiple usage of useArcs() member");
47.744 _use_arcs = true;
47.745 for (ArcIt a(_digraph); a != INVALID; ++a) {
47.746 - _arc_index.insert(std::make_pair(converter(map[a]), a));
47.747 + _arc_index.insert(std::make_pair(converter(map[a]), a));
47.748 }
47.749 return *this;
47.750 }
47.751 @@ -790,7 +790,7 @@
47.752 /// Therefore \c skipArcs() function should also be used, or
47.753 /// \c useNodes() should be used to specify the label of the nodes.
47.754 DigraphReader& skipNodes() {
47.755 - LEMON_ASSERT(!_skip_nodes, "Skip nodes already set");
47.756 + LEMON_ASSERT(!_skip_nodes, "Skip nodes already set");
47.757 _skip_nodes = true;
47.758 return *this;
47.759 }
47.760 @@ -801,7 +801,7 @@
47.761 /// map reading rule will be abandoned, and the arcs of the graph
47.762 /// will not be constructed.
47.763 DigraphReader& skipArcs() {
47.764 - LEMON_ASSERT(!_skip_arcs, "Skip arcs already set");
47.765 + LEMON_ASSERT(!_skip_arcs, "Skip arcs already set");
47.766 _skip_arcs = true;
47.767 return *this;
47.768 }
47.769 @@ -813,12 +813,12 @@
47.770 bool readLine() {
47.771 std::string str;
47.772 while(++line_num, std::getline(*_is, str)) {
47.773 - line.clear(); line.str(str);
47.774 - char c;
47.775 - if (line >> std::ws >> c && c != '#') {
47.776 - line.putback(c);
47.777 - return true;
47.778 - }
47.779 + line.clear(); line.str(str);
47.780 + char c;
47.781 + if (line >> std::ws >> c && c != '#') {
47.782 + line.putback(c);
47.783 + return true;
47.784 + }
47.785 }
47.786 return false;
47.787 }
47.788 @@ -826,11 +826,11 @@
47.789 bool readSuccess() {
47.790 return static_cast<bool>(*_is);
47.791 }
47.792 -
47.793 +
47.794 void skipSection() {
47.795 char c;
47.796 while (readSuccess() && line >> c && c != '@') {
47.797 - readLine();
47.798 + readLine();
47.799 }
47.800 line.putback(c);
47.801 }
47.802 @@ -842,89 +842,89 @@
47.803
47.804 char c;
47.805 if (!readLine() || !(line >> c) || c == '@') {
47.806 - if (readSuccess() && line) line.putback(c);
47.807 - if (!_node_maps.empty())
47.808 - throw DataFormatError("Cannot find map names");
47.809 - return;
47.810 + if (readSuccess() && line) line.putback(c);
47.811 + if (!_node_maps.empty())
47.812 + throw DataFormatError("Cannot find map names");
47.813 + return;
47.814 }
47.815 line.putback(c);
47.816
47.817 {
47.818 - std::map<std::string, int> maps;
47.819 -
47.820 - std::string map;
47.821 - int index = 0;
47.822 - while (_reader_bits::readToken(line, map)) {
47.823 - if (maps.find(map) != maps.end()) {
47.824 - std::ostringstream msg;
47.825 - msg << "Multiple occurence of node map: " << map;
47.826 - throw DataFormatError(msg.str().c_str());
47.827 - }
47.828 - maps.insert(std::make_pair(map, index));
47.829 - ++index;
47.830 - }
47.831 -
47.832 - for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) {
47.833 - std::map<std::string, int>::iterator jt =
47.834 - maps.find(_node_maps[i].first);
47.835 - if (jt == maps.end()) {
47.836 - std::ostringstream msg;
47.837 - msg << "Map not found in file: " << _node_maps[i].first;
47.838 - throw DataFormatError(msg.str().c_str());
47.839 - }
47.840 - map_index[i] = jt->second;
47.841 - }
47.842 -
47.843 - {
47.844 - std::map<std::string, int>::iterator jt = maps.find("label");
47.845 - if (jt != maps.end()) {
47.846 - label_index = jt->second;
47.847 - } else {
47.848 - label_index = -1;
47.849 - }
47.850 - }
47.851 - map_num = maps.size();
47.852 + std::map<std::string, int> maps;
47.853 +
47.854 + std::string map;
47.855 + int index = 0;
47.856 + while (_reader_bits::readToken(line, map)) {
47.857 + if (maps.find(map) != maps.end()) {
47.858 + std::ostringstream msg;
47.859 + msg << "Multiple occurence of node map: " << map;
47.860 + throw DataFormatError(msg.str().c_str());
47.861 + }
47.862 + maps.insert(std::make_pair(map, index));
47.863 + ++index;
47.864 + }
47.865 +
47.866 + for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) {
47.867 + std::map<std::string, int>::iterator jt =
47.868 + maps.find(_node_maps[i].first);
47.869 + if (jt == maps.end()) {
47.870 + std::ostringstream msg;
47.871 + msg << "Map not found in file: " << _node_maps[i].first;
47.872 + throw DataFormatError(msg.str().c_str());
47.873 + }
47.874 + map_index[i] = jt->second;
47.875 + }
47.876 +
47.877 + {
47.878 + std::map<std::string, int>::iterator jt = maps.find("label");
47.879 + if (jt != maps.end()) {
47.880 + label_index = jt->second;
47.881 + } else {
47.882 + label_index = -1;
47.883 + }
47.884 + }
47.885 + map_num = maps.size();
47.886 }
47.887
47.888 while (readLine() && line >> c && c != '@') {
47.889 - line.putback(c);
47.890 -
47.891 - std::vector<std::string> tokens(map_num);
47.892 - for (int i = 0; i < map_num; ++i) {
47.893 - if (!_reader_bits::readToken(line, tokens[i])) {
47.894 - std::ostringstream msg;
47.895 - msg << "Column not found (" << i + 1 << ")";
47.896 - throw DataFormatError(msg.str().c_str());
47.897 - }
47.898 - }
47.899 - if (line >> std::ws >> c)
47.900 - throw DataFormatError("Extra character on the end of line");
47.901 -
47.902 - Node n;
47.903 - if (!_use_nodes) {
47.904 - n = _digraph.addNode();
47.905 - if (label_index != -1)
47.906 - _node_index.insert(std::make_pair(tokens[label_index], n));
47.907 - } else {
47.908 - if (label_index == -1)
47.909 - throw DataFormatError("Label map not found in file");
47.910 - typename std::map<std::string, Node>::iterator it =
47.911 - _node_index.find(tokens[label_index]);
47.912 - if (it == _node_index.end()) {
47.913 - std::ostringstream msg;
47.914 - msg << "Node with label not found: " << tokens[label_index];
47.915 - throw DataFormatError(msg.str().c_str());
47.916 - }
47.917 - n = it->second;
47.918 - }
47.919 -
47.920 - for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) {
47.921 - _node_maps[i].second->set(n, tokens[map_index[i]]);
47.922 - }
47.923 + line.putback(c);
47.924 +
47.925 + std::vector<std::string> tokens(map_num);
47.926 + for (int i = 0; i < map_num; ++i) {
47.927 + if (!_reader_bits::readToken(line, tokens[i])) {
47.928 + std::ostringstream msg;
47.929 + msg << "Column not found (" << i + 1 << ")";
47.930 + throw DataFormatError(msg.str().c_str());
47.931 + }
47.932 + }
47.933 + if (line >> std::ws >> c)
47.934 + throw DataFormatError("Extra character on the end of line");
47.935 +
47.936 + Node n;
47.937 + if (!_use_nodes) {
47.938 + n = _digraph.addNode();
47.939 + if (label_index != -1)
47.940 + _node_index.insert(std::make_pair(tokens[label_index], n));
47.941 + } else {
47.942 + if (label_index == -1)
47.943 + throw DataFormatError("Label map not found in file");
47.944 + typename std::map<std::string, Node>::iterator it =
47.945 + _node_index.find(tokens[label_index]);
47.946 + if (it == _node_index.end()) {
47.947 + std::ostringstream msg;
47.948 + msg << "Node with label not found: " << tokens[label_index];
47.949 + throw DataFormatError(msg.str().c_str());
47.950 + }
47.951 + n = it->second;
47.952 + }
47.953 +
47.954 + for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) {
47.955 + _node_maps[i].second->set(n, tokens[map_index[i]]);
47.956 + }
47.957
47.958 }
47.959 if (readSuccess()) {
47.960 - line.putback(c);
47.961 + line.putback(c);
47.962 }
47.963 }
47.964
47.965 @@ -935,78 +935,78 @@
47.966
47.967 char c;
47.968 if (!readLine() || !(line >> c) || c == '@') {
47.969 - if (readSuccess() && line) line.putback(c);
47.970 - if (!_arc_maps.empty())
47.971 - throw DataFormatError("Cannot find map names");
47.972 - return;
47.973 + if (readSuccess() && line) line.putback(c);
47.974 + if (!_arc_maps.empty())
47.975 + throw DataFormatError("Cannot find map names");
47.976 + return;
47.977 }
47.978 line.putback(c);
47.979 -
47.980 +
47.981 {
47.982 - std::map<std::string, int> maps;
47.983 -
47.984 - std::string map;
47.985 - int index = 0;
47.986 - while (_reader_bits::readToken(line, map)) {
47.987 - if (maps.find(map) != maps.end()) {
47.988 - std::ostringstream msg;
47.989 - msg << "Multiple occurence of arc map: " << map;
47.990 - throw DataFormatError(msg.str().c_str());
47.991 - }
47.992 - maps.insert(std::make_pair(map, index));
47.993 - ++index;
47.994 - }
47.995 -
47.996 - for (int i = 0; i < static_cast<int>(_arc_maps.size()); ++i) {
47.997 - std::map<std::string, int>::iterator jt =
47.998 - maps.find(_arc_maps[i].first);
47.999 - if (jt == maps.end()) {
47.1000 - std::ostringstream msg;
47.1001 - msg << "Map not found in file: " << _arc_maps[i].first;
47.1002 - throw DataFormatError(msg.str().c_str());
47.1003 - }
47.1004 - map_index[i] = jt->second;
47.1005 - }
47.1006 -
47.1007 - {
47.1008 - std::map<std::string, int>::iterator jt = maps.find("label");
47.1009 - if (jt != maps.end()) {
47.1010 - label_index = jt->second;
47.1011 - } else {
47.1012 - label_index = -1;
47.1013 - }
47.1014 - }
47.1015 - map_num = maps.size();
47.1016 + std::map<std::string, int> maps;
47.1017 +
47.1018 + std::string map;
47.1019 + int index = 0;
47.1020 + while (_reader_bits::readToken(line, map)) {
47.1021 + if (maps.find(map) != maps.end()) {
47.1022 + std::ostringstream msg;
47.1023 + msg << "Multiple occurence of arc map: " << map;
47.1024 + throw DataFormatError(msg.str().c_str());
47.1025 + }
47.1026 + maps.insert(std::make_pair(map, index));
47.1027 + ++index;
47.1028 + }
47.1029 +
47.1030 + for (int i = 0; i < static_cast<int>(_arc_maps.size()); ++i) {
47.1031 + std::map<std::string, int>::iterator jt =
47.1032 + maps.find(_arc_maps[i].first);
47.1033 + if (jt == maps.end()) {
47.1034 + std::ostringstream msg;
47.1035 + msg << "Map not found in file: " << _arc_maps[i].first;
47.1036 + throw DataFormatError(msg.str().c_str());
47.1037 + }
47.1038 + map_index[i] = jt->second;
47.1039 + }
47.1040 +
47.1041 + {
47.1042 + std::map<std::string, int>::iterator jt = maps.find("label");
47.1043 + if (jt != maps.end()) {
47.1044 + label_index = jt->second;
47.1045 + } else {
47.1046 + label_index = -1;
47.1047 + }
47.1048 + }
47.1049 + map_num = maps.size();
47.1050 }
47.1051
47.1052 while (readLine() && line >> c && c != '@') {
47.1053 - line.putback(c);
47.1054 -
47.1055 - std::string source_token;
47.1056 - std::string target_token;
47.1057 -
47.1058 - if (!_reader_bits::readToken(line, source_token))
47.1059 - throw DataFormatError("Source not found");
47.1060 -
47.1061 - if (!_reader_bits::readToken(line, target_token))
47.1062 - throw DataFormatError("Target not found");
47.1063 -
47.1064 - std::vector<std::string> tokens(map_num);
47.1065 - for (int i = 0; i < map_num; ++i) {
47.1066 - if (!_reader_bits::readToken(line, tokens[i])) {
47.1067 - std::ostringstream msg;
47.1068 - msg << "Column not found (" << i + 1 << ")";
47.1069 - throw DataFormatError(msg.str().c_str());
47.1070 - }
47.1071 - }
47.1072 - if (line >> std::ws >> c)
47.1073 - throw DataFormatError("Extra character on the end of line");
47.1074 -
47.1075 - Arc a;
47.1076 - if (!_use_arcs) {
47.1077 + line.putback(c);
47.1078 +
47.1079 + std::string source_token;
47.1080 + std::string target_token;
47.1081 +
47.1082 + if (!_reader_bits::readToken(line, source_token))
47.1083 + throw DataFormatError("Source not found");
47.1084 +
47.1085 + if (!_reader_bits::readToken(line, target_token))
47.1086 + throw DataFormatError("Target not found");
47.1087 +
47.1088 + std::vector<std::string> tokens(map_num);
47.1089 + for (int i = 0; i < map_num; ++i) {
47.1090 + if (!_reader_bits::readToken(line, tokens[i])) {
47.1091 + std::ostringstream msg;
47.1092 + msg << "Column not found (" << i + 1 << ")";
47.1093 + throw DataFormatError(msg.str().c_str());
47.1094 + }
47.1095 + }
47.1096 + if (line >> std::ws >> c)
47.1097 + throw DataFormatError("Extra character on the end of line");
47.1098 +
47.1099 + Arc a;
47.1100 + if (!_use_arcs) {
47.1101
47.1102 typename NodeIndex::iterator it;
47.1103 -
47.1104 +
47.1105 it = _node_index.find(source_token);
47.1106 if (it == _node_index.end()) {
47.1107 std::ostringstream msg;
47.1108 @@ -1016,36 +1016,36 @@
47.1109 Node source = it->second;
47.1110
47.1111 it = _node_index.find(target_token);
47.1112 - if (it == _node_index.end()) {
47.1113 - std::ostringstream msg;
47.1114 + if (it == _node_index.end()) {
47.1115 + std::ostringstream msg;
47.1116 msg << "Item not found: " << target_token;
47.1117 throw DataFormatError(msg.str().c_str());
47.1118 - }
47.1119 - Node target = it->second;
47.1120 -
47.1121 - a = _digraph.addArc(source, target);
47.1122 - if (label_index != -1)
47.1123 - _arc_index.insert(std::make_pair(tokens[label_index], a));
47.1124 - } else {
47.1125 - if (label_index == -1)
47.1126 - throw DataFormatError("Label map not found in file");
47.1127 - typename std::map<std::string, Arc>::iterator it =
47.1128 - _arc_index.find(tokens[label_index]);
47.1129 - if (it == _arc_index.end()) {
47.1130 - std::ostringstream msg;
47.1131 - msg << "Arc with label not found: " << tokens[label_index];
47.1132 - throw DataFormatError(msg.str().c_str());
47.1133 - }
47.1134 - a = it->second;
47.1135 - }
47.1136 -
47.1137 - for (int i = 0; i < static_cast<int>(_arc_maps.size()); ++i) {
47.1138 - _arc_maps[i].second->set(a, tokens[map_index[i]]);
47.1139 - }
47.1140 + }
47.1141 + Node target = it->second;
47.1142 +
47.1143 + a = _digraph.addArc(source, target);
47.1144 + if (label_index != -1)
47.1145 + _arc_index.insert(std::make_pair(tokens[label_index], a));
47.1146 + } else {
47.1147 + if (label_index == -1)
47.1148 + throw DataFormatError("Label map not found in file");
47.1149 + typename std::map<std::string, Arc>::iterator it =
47.1150 + _arc_index.find(tokens[label_index]);
47.1151 + if (it == _arc_index.end()) {
47.1152 + std::ostringstream msg;
47.1153 + msg << "Arc with label not found: " << tokens[label_index];
47.1154 + throw DataFormatError(msg.str().c_str());
47.1155 + }
47.1156 + a = it->second;
47.1157 + }
47.1158 +
47.1159 + for (int i = 0; i < static_cast<int>(_arc_maps.size()); ++i) {
47.1160 + _arc_maps[i].second->set(a, tokens[map_index[i]]);
47.1161 + }
47.1162
47.1163 }
47.1164 if (readSuccess()) {
47.1165 - line.putback(c);
47.1166 + line.putback(c);
47.1167 }
47.1168 }
47.1169
47.1170 @@ -1055,51 +1055,51 @@
47.1171
47.1172 char c;
47.1173 while (readLine() && line >> c && c != '@') {
47.1174 - line.putback(c);
47.1175 -
47.1176 - std::string attr, token;
47.1177 - if (!_reader_bits::readToken(line, attr))
47.1178 - throw DataFormatError("Attribute name not found");
47.1179 - if (!_reader_bits::readToken(line, token))
47.1180 - throw DataFormatError("Attribute value not found");
47.1181 - if (line >> c)
47.1182 - throw DataFormatError("Extra character on the end of line");
47.1183 -
47.1184 - {
47.1185 - std::set<std::string>::iterator it = read_attr.find(attr);
47.1186 - if (it != read_attr.end()) {
47.1187 - std::ostringstream msg;
47.1188 - msg << "Multiple occurence of attribute " << attr;
47.1189 - throw DataFormatError(msg.str().c_str());
47.1190 - }
47.1191 - read_attr.insert(attr);
47.1192 - }
47.1193 -
47.1194 - {
47.1195 - typename Attributes::iterator it = _attributes.lower_bound(attr);
47.1196 - while (it != _attributes.end() && it->first == attr) {
47.1197 - it->second->set(token);
47.1198 - ++it;
47.1199 - }
47.1200 - }
47.1201 + line.putback(c);
47.1202 +
47.1203 + std::string attr, token;
47.1204 + if (!_reader_bits::readToken(line, attr))
47.1205 + throw DataFormatError("Attribute name not found");
47.1206 + if (!_reader_bits::readToken(line, token))
47.1207 + throw DataFormatError("Attribute value not found");
47.1208 + if (line >> c)
47.1209 + throw DataFormatError("Extra character on the end of line");
47.1210 +
47.1211 + {
47.1212 + std::set<std::string>::iterator it = read_attr.find(attr);
47.1213 + if (it != read_attr.end()) {
47.1214 + std::ostringstream msg;
47.1215 + msg << "Multiple occurence of attribute " << attr;
47.1216 + throw DataFormatError(msg.str().c_str());
47.1217 + }
47.1218 + read_attr.insert(attr);
47.1219 + }
47.1220 +
47.1221 + {
47.1222 + typename Attributes::iterator it = _attributes.lower_bound(attr);
47.1223 + while (it != _attributes.end() && it->first == attr) {
47.1224 + it->second->set(token);
47.1225 + ++it;
47.1226 + }
47.1227 + }
47.1228
47.1229 }
47.1230 if (readSuccess()) {
47.1231 - line.putback(c);
47.1232 + line.putback(c);
47.1233 }
47.1234 for (typename Attributes::iterator it = _attributes.begin();
47.1235 - it != _attributes.end(); ++it) {
47.1236 - if (read_attr.find(it->first) == read_attr.end()) {
47.1237 - std::ostringstream msg;
47.1238 - msg << "Attribute not found in file: " << it->first;
47.1239 - throw DataFormatError(msg.str().c_str());
47.1240 - }
47.1241 + it != _attributes.end(); ++it) {
47.1242 + if (read_attr.find(it->first) == read_attr.end()) {
47.1243 + std::ostringstream msg;
47.1244 + msg << "Attribute not found in file: " << it->first;
47.1245 + throw DataFormatError(msg.str().c_str());
47.1246 + }
47.1247 }
47.1248 }
47.1249
47.1250 public:
47.1251
47.1252 - /// \name Execution of the reader
47.1253 + /// \name Execution of the reader
47.1254 /// @{
47.1255
47.1256 /// \brief Start the batch processing
47.1257 @@ -1108,74 +1108,74 @@
47.1258 void run() {
47.1259 LEMON_ASSERT(_is != 0, "This reader assigned to an other reader");
47.1260 if (!*_is) {
47.1261 - throw DataFormatError("Cannot find file");
47.1262 + throw DataFormatError("Cannot find file");
47.1263 }
47.1264 -
47.1265 +
47.1266 bool nodes_done = _skip_nodes;
47.1267 bool arcs_done = _skip_arcs;
47.1268 bool attributes_done = false;
47.1269
47.1270 - line_num = 0;
47.1271 + line_num = 0;
47.1272 readLine();
47.1273 skipSection();
47.1274
47.1275 while (readSuccess()) {
47.1276 - try {
47.1277 - char c;
47.1278 - std::string section, caption;
47.1279 - line >> c;
47.1280 - _reader_bits::readToken(line, section);
47.1281 - _reader_bits::readToken(line, caption);
47.1282 -
47.1283 - if (line >> c)
47.1284 - throw DataFormatError("Extra character on the end of line");
47.1285 -
47.1286 - if (section == "nodes" && !nodes_done) {
47.1287 - if (_nodes_caption.empty() || _nodes_caption == caption) {
47.1288 - readNodes();
47.1289 - nodes_done = true;
47.1290 - }
47.1291 - } else if ((section == "arcs" || section == "edges") &&
47.1292 - !arcs_done) {
47.1293 - if (_arcs_caption.empty() || _arcs_caption == caption) {
47.1294 - readArcs();
47.1295 - arcs_done = true;
47.1296 - }
47.1297 - } else if (section == "attributes" && !attributes_done) {
47.1298 - if (_attributes_caption.empty() || _attributes_caption == caption) {
47.1299 - readAttributes();
47.1300 - attributes_done = true;
47.1301 - }
47.1302 - } else {
47.1303 - readLine();
47.1304 - skipSection();
47.1305 - }
47.1306 - } catch (DataFormatError& error) {
47.1307 - error.line(line_num);
47.1308 - throw;
47.1309 - }
47.1310 + try {
47.1311 + char c;
47.1312 + std::string section, caption;
47.1313 + line >> c;
47.1314 + _reader_bits::readToken(line, section);
47.1315 + _reader_bits::readToken(line, caption);
47.1316 +
47.1317 + if (line >> c)
47.1318 + throw DataFormatError("Extra character on the end of line");
47.1319 +
47.1320 + if (section == "nodes" && !nodes_done) {
47.1321 + if (_nodes_caption.empty() || _nodes_caption == caption) {
47.1322 + readNodes();
47.1323 + nodes_done = true;
47.1324 + }
47.1325 + } else if ((section == "arcs" || section == "edges") &&
47.1326 + !arcs_done) {
47.1327 + if (_arcs_caption.empty() || _arcs_caption == caption) {
47.1328 + readArcs();
47.1329 + arcs_done = true;
47.1330 + }
47.1331 + } else if (section == "attributes" && !attributes_done) {
47.1332 + if (_attributes_caption.empty() || _attributes_caption == caption) {
47.1333 + readAttributes();
47.1334 + attributes_done = true;
47.1335 + }
47.1336 + } else {
47.1337 + readLine();
47.1338 + skipSection();
47.1339 + }
47.1340 + } catch (DataFormatError& error) {
47.1341 + error.line(line_num);
47.1342 + throw;
47.1343 + }
47.1344 }
47.1345
47.1346 if (!nodes_done) {
47.1347 - throw DataFormatError("Section @nodes not found");
47.1348 + throw DataFormatError("Section @nodes not found");
47.1349 }
47.1350
47.1351 if (!arcs_done) {
47.1352 - throw DataFormatError("Section @arcs not found");
47.1353 + throw DataFormatError("Section @arcs not found");
47.1354 }
47.1355
47.1356 if (!attributes_done && !_attributes.empty()) {
47.1357 - throw DataFormatError("Section @attributes not found");
47.1358 + throw DataFormatError("Section @attributes not found");
47.1359 }
47.1360
47.1361 }
47.1362
47.1363 /// @}
47.1364 -
47.1365 +
47.1366 };
47.1367
47.1368 /// \brief Return a \ref DigraphReader class
47.1369 - ///
47.1370 + ///
47.1371 /// This function just returns a \ref DigraphReader class.
47.1372 /// \relates DigraphReader
47.1373 template <typename Digraph>
47.1374 @@ -1185,18 +1185,18 @@
47.1375 }
47.1376
47.1377 /// \brief Return a \ref DigraphReader class
47.1378 - ///
47.1379 + ///
47.1380 /// This function just returns a \ref DigraphReader class.
47.1381 /// \relates DigraphReader
47.1382 template <typename Digraph>
47.1383 - DigraphReader<Digraph> digraphReader(const std::string& fn,
47.1384 - Digraph& digraph) {
47.1385 + DigraphReader<Digraph> digraphReader(const std::string& fn,
47.1386 + Digraph& digraph) {
47.1387 DigraphReader<Digraph> tmp(fn, digraph);
47.1388 return tmp;
47.1389 }
47.1390
47.1391 /// \brief Return a \ref DigraphReader class
47.1392 - ///
47.1393 + ///
47.1394 /// This function just returns a \ref DigraphReader class.
47.1395 /// \relates DigraphReader
47.1396 template <typename Digraph>
47.1397 @@ -1209,16 +1209,16 @@
47.1398 class GraphReader;
47.1399
47.1400 template <typename Graph>
47.1401 - GraphReader<Graph> graphReader(std::istream& is, Graph& graph);
47.1402 + GraphReader<Graph> graphReader(std::istream& is, Graph& graph);
47.1403
47.1404 template <typename Graph>
47.1405 - GraphReader<Graph> graphReader(const std::string& fn, Graph& graph);
47.1406 + GraphReader<Graph> graphReader(const std::string& fn, Graph& graph);
47.1407
47.1408 template <typename Graph>
47.1409 - GraphReader<Graph> graphReader(const char *fn, Graph& graph);
47.1410 + GraphReader<Graph> graphReader(const char *fn, Graph& graph);
47.1411
47.1412 /// \ingroup lemon_io
47.1413 - ///
47.1414 + ///
47.1415 /// \brief \ref lgf-format "LGF" reader for undirected graphs
47.1416 ///
47.1417 /// This utility reads an \ref lgf-format "LGF" file.
47.1418 @@ -1238,7 +1238,7 @@
47.1419
47.1420 typedef _Graph Graph;
47.1421 TEMPLATE_GRAPH_TYPEDEFS(Graph);
47.1422 -
47.1423 +
47.1424 private:
47.1425
47.1426 std::istream* _is;
47.1427 @@ -1254,16 +1254,16 @@
47.1428 NodeIndex _node_index;
47.1429 typedef std::map<std::string, Edge> EdgeIndex;
47.1430 EdgeIndex _edge_index;
47.1431 -
47.1432 - typedef std::vector<std::pair<std::string,
47.1433 - _reader_bits::MapStorageBase<Node>*> > NodeMaps;
47.1434 - NodeMaps _node_maps;
47.1435 +
47.1436 + typedef std::vector<std::pair<std::string,
47.1437 + _reader_bits::MapStorageBase<Node>*> > NodeMaps;
47.1438 + NodeMaps _node_maps;
47.1439
47.1440 typedef std::vector<std::pair<std::string,
47.1441 _reader_bits::MapStorageBase<Edge>*> > EdgeMaps;
47.1442 EdgeMaps _edge_maps;
47.1443
47.1444 - typedef std::multimap<std::string, _reader_bits::ValueStorageBase*>
47.1445 + typedef std::multimap<std::string, _reader_bits::ValueStorageBase*>
47.1446 Attributes;
47.1447 Attributes _attributes;
47.1448
47.1449 @@ -1282,66 +1282,66 @@
47.1450 ///
47.1451 /// Construct an undirected graph reader, which reads from the given
47.1452 /// input stream.
47.1453 - GraphReader(std::istream& is, Graph& graph)
47.1454 + GraphReader(std::istream& is, Graph& graph)
47.1455 : _is(&is), local_is(false), _graph(graph),
47.1456 - _use_nodes(false), _use_edges(false),
47.1457 - _skip_nodes(false), _skip_edges(false) {}
47.1458 + _use_nodes(false), _use_edges(false),
47.1459 + _skip_nodes(false), _skip_edges(false) {}
47.1460
47.1461 /// \brief Constructor
47.1462 ///
47.1463 /// Construct an undirected graph reader, which reads from the given
47.1464 /// file.
47.1465 - GraphReader(const std::string& fn, Graph& graph)
47.1466 + GraphReader(const std::string& fn, Graph& graph)
47.1467 : _is(new std::ifstream(fn.c_str())), local_is(true), _graph(graph),
47.1468 - _use_nodes(false), _use_edges(false),
47.1469 - _skip_nodes(false), _skip_edges(false) {}
47.1470 -
47.1471 + _use_nodes(false), _use_edges(false),
47.1472 + _skip_nodes(false), _skip_edges(false) {}
47.1473 +
47.1474 /// \brief Constructor
47.1475 ///
47.1476 /// Construct an undirected graph reader, which reads from the given
47.1477 /// file.
47.1478 - GraphReader(const char* fn, Graph& graph)
47.1479 + GraphReader(const char* fn, Graph& graph)
47.1480 : _is(new std::ifstream(fn)), local_is(true), _graph(graph),
47.1481 - _use_nodes(false), _use_edges(false),
47.1482 - _skip_nodes(false), _skip_edges(false) {}
47.1483 + _use_nodes(false), _use_edges(false),
47.1484 + _skip_nodes(false), _skip_edges(false) {}
47.1485
47.1486 /// \brief Destructor
47.1487 ~GraphReader() {
47.1488 - for (typename NodeMaps::iterator it = _node_maps.begin();
47.1489 - it != _node_maps.end(); ++it) {
47.1490 - delete it->second;
47.1491 + for (typename NodeMaps::iterator it = _node_maps.begin();
47.1492 + it != _node_maps.end(); ++it) {
47.1493 + delete it->second;
47.1494 }
47.1495
47.1496 - for (typename EdgeMaps::iterator it = _edge_maps.begin();
47.1497 - it != _edge_maps.end(); ++it) {
47.1498 - delete it->second;
47.1499 + for (typename EdgeMaps::iterator it = _edge_maps.begin();
47.1500 + it != _edge_maps.end(); ++it) {
47.1501 + delete it->second;
47.1502 }
47.1503
47.1504 - for (typename Attributes::iterator it = _attributes.begin();
47.1505 - it != _attributes.end(); ++it) {
47.1506 - delete it->second;
47.1507 + for (typename Attributes::iterator it = _attributes.begin();
47.1508 + it != _attributes.end(); ++it) {
47.1509 + delete it->second;
47.1510 }
47.1511
47.1512 if (local_is) {
47.1513 - delete _is;
47.1514 + delete _is;
47.1515 }
47.1516
47.1517 }
47.1518
47.1519 private:
47.1520 - friend GraphReader<Graph> graphReader<>(std::istream& is, Graph& graph);
47.1521 - friend GraphReader<Graph> graphReader<>(const std::string& fn,
47.1522 - Graph& graph);
47.1523 - friend GraphReader<Graph> graphReader<>(const char *fn, Graph& graph);
47.1524 -
47.1525 - GraphReader(GraphReader& other)
47.1526 + friend GraphReader<Graph> graphReader<>(std::istream& is, Graph& graph);
47.1527 + friend GraphReader<Graph> graphReader<>(const std::string& fn,
47.1528 + Graph& graph);
47.1529 + friend GraphReader<Graph> graphReader<>(const char *fn, Graph& graph);
47.1530 +
47.1531 + GraphReader(GraphReader& other)
47.1532 : _is(other._is), local_is(other.local_is), _graph(other._graph),
47.1533 - _use_nodes(other._use_nodes), _use_edges(other._use_edges),
47.1534 - _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
47.1535 + _use_nodes(other._use_nodes), _use_edges(other._use_edges),
47.1536 + _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
47.1537
47.1538 other._is = 0;
47.1539 other.local_is = false;
47.1540 -
47.1541 +
47.1542 _node_index.swap(other._node_index);
47.1543 _edge_index.swap(other._edge_index);
47.1544
47.1545 @@ -1361,15 +1361,15 @@
47.1546
47.1547 /// \name Reading rules
47.1548 /// @{
47.1549 -
47.1550 +
47.1551 /// \brief Node map reading rule
47.1552 ///
47.1553 /// Add a node map reading rule to the reader.
47.1554 template <typename Map>
47.1555 GraphReader& nodeMap(const std::string& caption, Map& map) {
47.1556 checkConcept<concepts::WriteMap<Node, typename Map::Value>, Map>();
47.1557 - _reader_bits::MapStorageBase<Node>* storage =
47.1558 - new _reader_bits::MapStorage<Node, Map>(map);
47.1559 + _reader_bits::MapStorageBase<Node>* storage =
47.1560 + new _reader_bits::MapStorage<Node, Map>(map);
47.1561 _node_maps.push_back(std::make_pair(caption, storage));
47.1562 return *this;
47.1563 }
47.1564 @@ -1379,11 +1379,11 @@
47.1565 /// Add a node map reading rule with specialized converter to the
47.1566 /// reader.
47.1567 template <typename Map, typename Converter>
47.1568 - GraphReader& nodeMap(const std::string& caption, Map& map,
47.1569 - const Converter& converter = Converter()) {
47.1570 + GraphReader& nodeMap(const std::string& caption, Map& map,
47.1571 + const Converter& converter = Converter()) {
47.1572 checkConcept<concepts::WriteMap<Node, typename Map::Value>, Map>();
47.1573 - _reader_bits::MapStorageBase<Node>* storage =
47.1574 - new _reader_bits::MapStorage<Node, Map, Converter>(map, converter);
47.1575 + _reader_bits::MapStorageBase<Node>* storage =
47.1576 + new _reader_bits::MapStorage<Node, Map, Converter>(map, converter);
47.1577 _node_maps.push_back(std::make_pair(caption, storage));
47.1578 return *this;
47.1579 }
47.1580 @@ -1394,8 +1394,8 @@
47.1581 template <typename Map>
47.1582 GraphReader& edgeMap(const std::string& caption, Map& map) {
47.1583 checkConcept<concepts::WriteMap<Edge, typename Map::Value>, Map>();
47.1584 - _reader_bits::MapStorageBase<Edge>* storage =
47.1585 - new _reader_bits::MapStorage<Edge, Map>(map);
47.1586 + _reader_bits::MapStorageBase<Edge>* storage =
47.1587 + new _reader_bits::MapStorage<Edge, Map>(map);
47.1588 _edge_maps.push_back(std::make_pair(caption, storage));
47.1589 return *this;
47.1590 }
47.1591 @@ -1405,11 +1405,11 @@
47.1592 /// Add an edge map reading rule with specialized converter to the
47.1593 /// reader.
47.1594 template <typename Map, typename Converter>
47.1595 - GraphReader& edgeMap(const std::string& caption, Map& map,
47.1596 - const Converter& converter = Converter()) {
47.1597 + GraphReader& edgeMap(const std::string& caption, Map& map,
47.1598 + const Converter& converter = Converter()) {
47.1599 checkConcept<concepts::WriteMap<Edge, typename Map::Value>, Map>();
47.1600 - _reader_bits::MapStorageBase<Edge>* storage =
47.1601 - new _reader_bits::MapStorage<Edge, Map, Converter>(map, converter);
47.1602 + _reader_bits::MapStorageBase<Edge>* storage =
47.1603 + new _reader_bits::MapStorage<Edge, Map, Converter>(map, converter);
47.1604 _edge_maps.push_back(std::make_pair(caption, storage));
47.1605 return *this;
47.1606 }
47.1607 @@ -1420,11 +1420,11 @@
47.1608 template <typename Map>
47.1609 GraphReader& arcMap(const std::string& caption, Map& map) {
47.1610 checkConcept<concepts::WriteMap<Arc, typename Map::Value>, Map>();
47.1611 - _reader_bits::MapStorageBase<Edge>* forward_storage =
47.1612 - new _reader_bits::GraphArcMapStorage<Graph, true, Map>(_graph, map);
47.1613 + _reader_bits::MapStorageBase<Edge>* forward_storage =
47.1614 + new _reader_bits::GraphArcMapStorage<Graph, true, Map>(_graph, map);
47.1615 _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
47.1616 - _reader_bits::MapStorageBase<Edge>* backward_storage =
47.1617 - new _reader_bits::GraphArcMapStorage<Graph, false, Map>(_graph, map);
47.1618 + _reader_bits::MapStorageBase<Edge>* backward_storage =
47.1619 + new _reader_bits::GraphArcMapStorage<Graph, false, Map>(_graph, map);
47.1620 _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
47.1621 return *this;
47.1622 }
47.1623 @@ -1434,16 +1434,16 @@
47.1624 /// Add an arc map reading rule with specialized converter to the
47.1625 /// reader.
47.1626 template <typename Map, typename Converter>
47.1627 - GraphReader& arcMap(const std::string& caption, Map& map,
47.1628 - const Converter& converter = Converter()) {
47.1629 + GraphReader& arcMap(const std::string& caption, Map& map,
47.1630 + const Converter& converter = Converter()) {
47.1631 checkConcept<concepts::WriteMap<Arc, typename Map::Value>, Map>();
47.1632 - _reader_bits::MapStorageBase<Edge>* forward_storage =
47.1633 - new _reader_bits::GraphArcMapStorage<Graph, true, Map, Converter>
47.1634 - (_graph, map, converter);
47.1635 + _reader_bits::MapStorageBase<Edge>* forward_storage =
47.1636 + new _reader_bits::GraphArcMapStorage<Graph, true, Map, Converter>
47.1637 + (_graph, map, converter);
47.1638 _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
47.1639 - _reader_bits::MapStorageBase<Edge>* backward_storage =
47.1640 - new _reader_bits::GraphArcMapStorage<Graph, false, Map, Converter>
47.1641 - (_graph, map, converter);
47.1642 + _reader_bits::MapStorageBase<Edge>* backward_storage =
47.1643 + new _reader_bits::GraphArcMapStorage<Graph, false, Map, Converter>
47.1644 + (_graph, map, converter);
47.1645 _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
47.1646 return *this;
47.1647 }
47.1648 @@ -1453,8 +1453,8 @@
47.1649 /// Add an attribute reading rule to the reader.
47.1650 template <typename Value>
47.1651 GraphReader& attribute(const std::string& caption, Value& value) {
47.1652 - _reader_bits::ValueStorageBase* storage =
47.1653 - new _reader_bits::ValueStorage<Value>(value);
47.1654 + _reader_bits::ValueStorageBase* storage =
47.1655 + new _reader_bits::ValueStorage<Value>(value);
47.1656 _attributes.insert(std::make_pair(caption, storage));
47.1657 return *this;
47.1658 }
47.1659 @@ -1464,10 +1464,10 @@
47.1660 /// Add an attribute reading rule with specialized converter to the
47.1661 /// reader.
47.1662 template <typename Value, typename Converter>
47.1663 - GraphReader& attribute(const std::string& caption, Value& value,
47.1664 - const Converter& converter = Converter()) {
47.1665 - _reader_bits::ValueStorageBase* storage =
47.1666 - new _reader_bits::ValueStorage<Value, Converter>(value, converter);
47.1667 + GraphReader& attribute(const std::string& caption, Value& value,
47.1668 + const Converter& converter = Converter()) {
47.1669 + _reader_bits::ValueStorageBase* storage =
47.1670 + new _reader_bits::ValueStorage<Value, Converter>(value, converter);
47.1671 _attributes.insert(std::make_pair(caption, storage));
47.1672 return *this;
47.1673 }
47.1674 @@ -1478,8 +1478,8 @@
47.1675 GraphReader& node(const std::string& caption, Node& node) {
47.1676 typedef _reader_bits::MapLookUpConverter<Node> Converter;
47.1677 Converter converter(_node_index);
47.1678 - _reader_bits::ValueStorageBase* storage =
47.1679 - new _reader_bits::ValueStorage<Node, Converter>(node, converter);
47.1680 + _reader_bits::ValueStorageBase* storage =
47.1681 + new _reader_bits::ValueStorage<Node, Converter>(node, converter);
47.1682 _attributes.insert(std::make_pair(caption, storage));
47.1683 return *this;
47.1684 }
47.1685 @@ -1490,8 +1490,8 @@
47.1686 GraphReader& edge(const std::string& caption, Edge& edge) {
47.1687 typedef _reader_bits::MapLookUpConverter<Edge> Converter;
47.1688 Converter converter(_edge_index);
47.1689 - _reader_bits::ValueStorageBase* storage =
47.1690 - new _reader_bits::ValueStorage<Edge, Converter>(edge, converter);
47.1691 + _reader_bits::ValueStorageBase* storage =
47.1692 + new _reader_bits::ValueStorage<Edge, Converter>(edge, converter);
47.1693 _attributes.insert(std::make_pair(caption, storage));
47.1694 return *this;
47.1695 }
47.1696 @@ -1502,8 +1502,8 @@
47.1697 GraphReader& arc(const std::string& caption, Arc& arc) {
47.1698 typedef _reader_bits::GraphArcLookUpConverter<Graph> Converter;
47.1699 Converter converter(_graph, _edge_index);
47.1700 - _reader_bits::ValueStorageBase* storage =
47.1701 - new _reader_bits::ValueStorage<Arc, Converter>(arc, converter);
47.1702 + _reader_bits::ValueStorageBase* storage =
47.1703 + new _reader_bits::ValueStorage<Arc, Converter>(arc, converter);
47.1704 _attributes.insert(std::make_pair(caption, storage));
47.1705 return *this;
47.1706 }
47.1707 @@ -1549,11 +1549,11 @@
47.1708 template <typename Map>
47.1709 GraphReader& useNodes(const Map& map) {
47.1710 checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
47.1711 - LEMON_ASSERT(!_use_nodes, "Multiple usage of useNodes() member");
47.1712 + LEMON_ASSERT(!_use_nodes, "Multiple usage of useNodes() member");
47.1713 _use_nodes = true;
47.1714 _writer_bits::DefaultConverter<typename Map::Value> converter;
47.1715 for (NodeIt n(_graph); n != INVALID; ++n) {
47.1716 - _node_index.insert(std::make_pair(converter(map[n]), n));
47.1717 + _node_index.insert(std::make_pair(converter(map[n]), n));
47.1718 }
47.1719 return *this;
47.1720 }
47.1721 @@ -1564,13 +1564,13 @@
47.1722 /// label map and a functor which converts the label map values to
47.1723 /// \c std::string.
47.1724 template <typename Map, typename Converter>
47.1725 - GraphReader& useNodes(const Map& map,
47.1726 - const Converter& converter = Converter()) {
47.1727 + GraphReader& useNodes(const Map& map,
47.1728 + const Converter& converter = Converter()) {
47.1729 checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
47.1730 - LEMON_ASSERT(!_use_nodes, "Multiple usage of useNodes() member");
47.1731 + LEMON_ASSERT(!_use_nodes, "Multiple usage of useNodes() member");
47.1732 _use_nodes = true;
47.1733 for (NodeIt n(_graph); n != INVALID; ++n) {
47.1734 - _node_index.insert(std::make_pair(converter(map[n]), n));
47.1735 + _node_index.insert(std::make_pair(converter(map[n]), n));
47.1736 }
47.1737 return *this;
47.1738 }
47.1739 @@ -1586,7 +1586,7 @@
47.1740 _use_edges = true;
47.1741 _writer_bits::DefaultConverter<typename Map::Value> converter;
47.1742 for (EdgeIt a(_graph); a != INVALID; ++a) {
47.1743 - _edge_index.insert(std::make_pair(converter(map[a]), a));
47.1744 + _edge_index.insert(std::make_pair(converter(map[a]), a));
47.1745 }
47.1746 return *this;
47.1747 }
47.1748 @@ -1597,13 +1597,13 @@
47.1749 /// label map and a functor which converts the label map values to
47.1750 /// \c std::string.
47.1751 template <typename Map, typename Converter>
47.1752 - GraphReader& useEdges(const Map& map,
47.1753 - const Converter& converter = Converter()) {
47.1754 + GraphReader& useEdges(const Map& map,
47.1755 + const Converter& converter = Converter()) {
47.1756 checkConcept<concepts::ReadMap<Edge, typename Map::Value>, Map>();
47.1757 - LEMON_ASSERT(!_use_edges, "Multiple usage of useEdges() member");
47.1758 + LEMON_ASSERT(!_use_edges, "Multiple usage of useEdges() member");
47.1759 _use_edges = true;
47.1760 for (EdgeIt a(_graph); a != INVALID; ++a) {
47.1761 - _edge_index.insert(std::make_pair(converter(map[a]), a));
47.1762 + _edge_index.insert(std::make_pair(converter(map[a]), a));
47.1763 }
47.1764 return *this;
47.1765 }
47.1766 @@ -1618,7 +1618,7 @@
47.1767 /// Therefore \c skipEdges() function should also be used, or
47.1768 /// \c useNodes() should be used to specify the label of the nodes.
47.1769 GraphReader& skipNodes() {
47.1770 - LEMON_ASSERT(!_skip_nodes, "Skip nodes already set");
47.1771 + LEMON_ASSERT(!_skip_nodes, "Skip nodes already set");
47.1772 _skip_nodes = true;
47.1773 return *this;
47.1774 }
47.1775 @@ -1629,7 +1629,7 @@
47.1776 /// map reading rule will be abandoned, and the edges of the graph
47.1777 /// will not be constructed.
47.1778 GraphReader& skipEdges() {
47.1779 - LEMON_ASSERT(!_skip_edges, "Skip edges already set");
47.1780 + LEMON_ASSERT(!_skip_edges, "Skip edges already set");
47.1781 _skip_edges = true;
47.1782 return *this;
47.1783 }
47.1784 @@ -1641,12 +1641,12 @@
47.1785 bool readLine() {
47.1786 std::string str;
47.1787 while(++line_num, std::getline(*_is, str)) {
47.1788 - line.clear(); line.str(str);
47.1789 - char c;
47.1790 - if (line >> std::ws >> c && c != '#') {
47.1791 - line.putback(c);
47.1792 - return true;
47.1793 - }
47.1794 + line.clear(); line.str(str);
47.1795 + char c;
47.1796 + if (line >> std::ws >> c && c != '#') {
47.1797 + line.putback(c);
47.1798 + return true;
47.1799 + }
47.1800 }
47.1801 return false;
47.1802 }
47.1803 @@ -1654,11 +1654,11 @@
47.1804 bool readSuccess() {
47.1805 return static_cast<bool>(*_is);
47.1806 }
47.1807 -
47.1808 +
47.1809 void skipSection() {
47.1810 char c;
47.1811 while (readSuccess() && line >> c && c != '@') {
47.1812 - readLine();
47.1813 + readLine();
47.1814 }
47.1815 line.putback(c);
47.1816 }
47.1817 @@ -1670,89 +1670,89 @@
47.1818
47.1819 char c;
47.1820 if (!readLine() || !(line >> c) || c == '@') {
47.1821 - if (readSuccess() && line) line.putback(c);
47.1822 - if (!_node_maps.empty())
47.1823 - throw DataFormatError("Cannot find map names");
47.1824 - return;
47.1825 + if (readSuccess() && line) line.putback(c);
47.1826 + if (!_node_maps.empty())
47.1827 + throw DataFormatError("Cannot find map names");
47.1828 + return;
47.1829 }
47.1830 line.putback(c);
47.1831 -
47.1832 +
47.1833 {
47.1834 - std::map<std::string, int> maps;
47.1835 -
47.1836 - std::string map;
47.1837 - int index = 0;
47.1838 - while (_reader_bits::readToken(line, map)) {
47.1839 - if (maps.find(map) != maps.end()) {
47.1840 - std::ostringstream msg;
47.1841 - msg << "Multiple occurence of node map: " << map;
47.1842 - throw DataFormatError(msg.str().c_str());
47.1843 - }
47.1844 - maps.insert(std::make_pair(map, index));
47.1845 - ++index;
47.1846 - }
47.1847 -
47.1848 - for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) {
47.1849 - std::map<std::string, int>::iterator jt =
47.1850 - maps.find(_node_maps[i].first);
47.1851 - if (jt == maps.end()) {
47.1852 - std::ostringstream msg;
47.1853 - msg << "Map not found in file: " << _node_maps[i].first;
47.1854 - throw DataFormatError(msg.str().c_str());
47.1855 - }
47.1856 - map_index[i] = jt->second;
47.1857 - }
47.1858 -
47.1859 - {
47.1860 - std::map<std::string, int>::iterator jt = maps.find("label");
47.1861 - if (jt != maps.end()) {
47.1862 - label_index = jt->second;
47.1863 - } else {
47.1864 - label_index = -1;
47.1865 - }
47.1866 - }
47.1867 - map_num = maps.size();
47.1868 + std::map<std::string, int> maps;
47.1869 +
47.1870 + std::string map;
47.1871 + int index = 0;
47.1872 + while (_reader_bits::readToken(line, map)) {
47.1873 + if (maps.find(map) != maps.end()) {
47.1874 + std::ostringstream msg;
47.1875 + msg << "Multiple occurence of node map: " << map;
47.1876 + throw DataFormatError(msg.str().c_str());
47.1877 + }
47.1878 + maps.insert(std::make_pair(map, index));
47.1879 + ++index;
47.1880 + }
47.1881 +
47.1882 + for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) {
47.1883 + std::map<std::string, int>::iterator jt =
47.1884 + maps.find(_node_maps[i].first);
47.1885 + if (jt == maps.end()) {
47.1886 + std::ostringstream msg;
47.1887 + msg << "Map not found in file: " << _node_maps[i].first;
47.1888 + throw DataFormatError(msg.str().c_str());
47.1889 + }
47.1890 + map_index[i] = jt->second;
47.1891 + }
47.1892 +
47.1893 + {
47.1894 + std::map<std::string, int>::iterator jt = maps.find("label");
47.1895 + if (jt != maps.end()) {
47.1896 + label_index = jt->second;
47.1897 + } else {
47.1898 + label_index = -1;
47.1899 + }
47.1900 + }
47.1901 + map_num = maps.size();
47.1902 }
47.1903
47.1904 while (readLine() && line >> c && c != '@') {
47.1905 - line.putback(c);
47.1906 -
47.1907 - std::vector<std::string> tokens(map_num);
47.1908 - for (int i = 0; i < map_num; ++i) {
47.1909 - if (!_reader_bits::readToken(line, tokens[i])) {
47.1910 - std::ostringstream msg;
47.1911 - msg << "Column not found (" << i + 1 << ")";
47.1912 - throw DataFormatError(msg.str().c_str());
47.1913 - }
47.1914 - }
47.1915 - if (line >> std::ws >> c)
47.1916 - throw DataFormatError("Extra character on the end of line");
47.1917 -
47.1918 - Node n;
47.1919 - if (!_use_nodes) {
47.1920 - n = _graph.addNode();
47.1921 - if (label_index != -1)
47.1922 - _node_index.insert(std::make_pair(tokens[label_index], n));
47.1923 - } else {
47.1924 - if (label_index == -1)
47.1925 - throw DataFormatError("Label map not found in file");
47.1926 - typename std::map<std::string, Node>::iterator it =
47.1927 - _node_index.find(tokens[label_index]);
47.1928 - if (it == _node_index.end()) {
47.1929 - std::ostringstream msg;
47.1930 - msg << "Node with label not found: " << tokens[label_index];
47.1931 - throw DataFormatError(msg.str().c_str());
47.1932 - }
47.1933 - n = it->second;
47.1934 - }
47.1935 -
47.1936 - for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) {
47.1937 - _node_maps[i].second->set(n, tokens[map_index[i]]);
47.1938 - }
47.1939 + line.putback(c);
47.1940 +
47.1941 + std::vector<std::string> tokens(map_num);
47.1942 + for (int i = 0; i < map_num; ++i) {
47.1943 + if (!_reader_bits::readToken(line, tokens[i])) {
47.1944 + std::ostringstream msg;
47.1945 + msg << "Column not found (" << i + 1 << ")";
47.1946 + throw DataFormatError(msg.str().c_str());
47.1947 + }
47.1948 + }
47.1949 + if (line >> std::ws >> c)
47.1950 + throw DataFormatError("Extra character on the end of line");
47.1951 +
47.1952 + Node n;
47.1953 + if (!_use_nodes) {
47.1954 + n = _graph.addNode();
47.1955 + if (label_index != -1)
47.1956 + _node_index.insert(std::make_pair(tokens[label_index], n));
47.1957 + } else {
47.1958 + if (label_index == -1)
47.1959 + throw DataFormatError("Label map not found in file");
47.1960 + typename std::map<std::string, Node>::iterator it =
47.1961 + _node_index.find(tokens[label_index]);
47.1962 + if (it == _node_index.end()) {
47.1963 + std::ostringstream msg;
47.1964 + msg << "Node with label not found: " << tokens[label_index];
47.1965 + throw DataFormatError(msg.str().c_str());
47.1966 + }
47.1967 + n = it->second;
47.1968 + }
47.1969 +
47.1970 + for (int i = 0; i < static_cast<int>(_node_maps.size()); ++i) {
47.1971 + _node_maps[i].second->set(n, tokens[map_index[i]]);
47.1972 + }
47.1973
47.1974 }
47.1975 if (readSuccess()) {
47.1976 - line.putback(c);
47.1977 + line.putback(c);
47.1978 }
47.1979 }
47.1980
47.1981 @@ -1763,78 +1763,78 @@
47.1982
47.1983 char c;
47.1984 if (!readLine() || !(line >> c) || c == '@') {
47.1985 - if (readSuccess() && line) line.putback(c);
47.1986 - if (!_edge_maps.empty())
47.1987 - throw DataFormatError("Cannot find map names");
47.1988 - return;
47.1989 + if (readSuccess() && line) line.putback(c);
47.1990 + if (!_edge_maps.empty())
47.1991 + throw DataFormatError("Cannot find map names");
47.1992 + return;
47.1993 }
47.1994 line.putback(c);
47.1995 -
47.1996 +
47.1997 {
47.1998 - std::map<std::string, int> maps;
47.1999 -
47.2000 - std::string map;
47.2001 - int index = 0;
47.2002 - while (_reader_bits::readToken(line, map)) {
47.2003 - if (maps.find(map) != maps.end()) {
47.2004 - std::ostringstream msg;
47.2005 - msg << "Multiple occurence of edge map: " << map;
47.2006 - throw DataFormatError(msg.str().c_str());
47.2007 - }
47.2008 - maps.insert(std::make_pair(map, index));
47.2009 - ++index;
47.2010 - }
47.2011 -
47.2012 - for (int i = 0; i < static_cast<int>(_edge_maps.size()); ++i) {
47.2013 - std::map<std::string, int>::iterator jt =
47.2014 - maps.find(_edge_maps[i].first);
47.2015 - if (jt == maps.end()) {
47.2016 - std::ostringstream msg;
47.2017 - msg << "Map not found in file: " << _edge_maps[i].first;
47.2018 - throw DataFormatError(msg.str().c_str());
47.2019 - }
47.2020 - map_index[i] = jt->second;
47.2021 - }
47.2022 -
47.2023 - {
47.2024 - std::map<std::string, int>::iterator jt = maps.find("label");
47.2025 - if (jt != maps.end()) {
47.2026 - label_index = jt->second;
47.2027 - } else {
47.2028 - label_index = -1;
47.2029 - }
47.2030 - }
47.2031 - map_num = maps.size();
47.2032 + std::map<std::string, int> maps;
47.2033 +
47.2034 + std::string map;
47.2035 + int index = 0;
47.2036 + while (_reader_bits::readToken(line, map)) {
47.2037 + if (maps.find(map) != maps.end()) {
47.2038 + std::ostringstream msg;
47.2039 + msg << "Multiple occurence of edge map: " << map;
47.2040 + throw DataFormatError(msg.str().c_str());
47.2041 + }
47.2042 + maps.insert(std::make_pair(map, index));
47.2043 + ++index;
47.2044 + }
47.2045 +
47.2046 + for (int i = 0; i < static_cast<int>(_edge_maps.size()); ++i) {
47.2047 + std::map<std::string, int>::iterator jt =
47.2048 + maps.find(_edge_maps[i].first);
47.2049 + if (jt == maps.end()) {
47.2050 + std::ostringstream msg;
47.2051 + msg << "Map not found in file: " << _edge_maps[i].first;
47.2052 + throw DataFormatError(msg.str().c_str());
47.2053 + }
47.2054 + map_index[i] = jt->second;
47.2055 + }
47.2056 +
47.2057 + {
47.2058 + std::map<std::string, int>::iterator jt = maps.find("label");
47.2059 + if (jt != maps.end()) {
47.2060 + label_index = jt->second;
47.2061 + } else {
47.2062 + label_index = -1;
47.2063 + }
47.2064 + }
47.2065 + map_num = maps.size();
47.2066 }
47.2067
47.2068 while (readLine() && line >> c && c != '@') {
47.2069 - line.putback(c);
47.2070 -
47.2071 - std::string source_token;
47.2072 - std::string target_token;
47.2073 -
47.2074 - if (!_reader_bits::readToken(line, source_token))
47.2075 - throw DataFormatError("Node u not found");
47.2076 -
47.2077 - if (!_reader_bits::readToken(line, target_token))
47.2078 - throw DataFormatError("Node v not found");
47.2079 -
47.2080 - std::vector<std::string> tokens(map_num);
47.2081 - for (int i = 0; i < map_num; ++i) {
47.2082 - if (!_reader_bits::readToken(line, tokens[i])) {
47.2083 - std::ostringstream msg;
47.2084 - msg << "Column not found (" << i + 1 << ")";
47.2085 - throw DataFormatError(msg.str().c_str());
47.2086 - }
47.2087 - }
47.2088 - if (line >> std::ws >> c)
47.2089 - throw DataFormatError("Extra character on the end of line");
47.2090 -
47.2091 - Edge e;
47.2092 - if (!_use_edges) {
47.2093 + line.putback(c);
47.2094 +
47.2095 + std::string source_token;
47.2096 + std::string target_token;
47.2097 +
47.2098 + if (!_reader_bits::readToken(line, source_token))
47.2099 + throw DataFormatError("Node u not found");
47.2100 +
47.2101 + if (!_reader_bits::readToken(line, target_token))
47.2102 + throw DataFormatError("Node v not found");
47.2103 +
47.2104 + std::vector<std::string> tokens(map_num);
47.2105 + for (int i = 0; i < map_num; ++i) {
47.2106 + if (!_reader_bits::readToken(line, tokens[i])) {
47.2107 + std::ostringstream msg;
47.2108 + msg << "Column not found (" << i + 1 << ")";
47.2109 + throw DataFormatError(msg.str().c_str());
47.2110 + }
47.2111 + }
47.2112 + if (line >> std::ws >> c)
47.2113 + throw DataFormatError("Extra character on the end of line");
47.2114 +
47.2115 + Edge e;
47.2116 + if (!_use_edges) {
47.2117
47.2118 typename NodeIndex::iterator it;
47.2119 -
47.2120 +
47.2121 it = _node_index.find(source_token);
47.2122 if (it == _node_index.end()) {
47.2123 std::ostringstream msg;
47.2124 @@ -1844,36 +1844,36 @@
47.2125 Node source = it->second;
47.2126
47.2127 it = _node_index.find(target_token);
47.2128 - if (it == _node_index.end()) {
47.2129 - std::ostringstream msg;
47.2130 + if (it == _node_index.end()) {
47.2131 + std::ostringstream msg;
47.2132 msg << "Item not found: " << target_token;
47.2133 throw DataFormatError(msg.str().c_str());
47.2134 - }
47.2135 - Node target = it->second;
47.2136 -
47.2137 - e = _graph.addEdge(source, target);
47.2138 - if (label_index != -1)
47.2139 - _edge_index.insert(std::make_pair(tokens[label_index], e));
47.2140 - } else {
47.2141 - if (label_index == -1)
47.2142 - throw DataFormatError("Label map not found in file");
47.2143 - typename std::map<std::string, Edge>::iterator it =
47.2144 - _edge_index.find(tokens[label_index]);
47.2145 - if (it == _edge_index.end()) {
47.2146 - std::ostringstream msg;
47.2147 - msg << "Edge with label not found: " << tokens[label_index];
47.2148 - throw DataFormatError(msg.str().c_str());
47.2149 - }
47.2150 - e = it->second;
47.2151 - }
47.2152 -
47.2153 - for (int i = 0; i < static_cast<int>(_edge_maps.size()); ++i) {
47.2154 - _edge_maps[i].second->set(e, tokens[map_index[i]]);
47.2155 - }
47.2156 + }
47.2157 + Node target = it->second;
47.2158 +
47.2159 + e = _graph.addEdge(source, target);
47.2160 + if (label_index != -1)
47.2161 + _edge_index.insert(std::make_pair(tokens[label_index], e));
47.2162 + } else {
47.2163 + if (label_index == -1)
47.2164 + throw DataFormatError("Label map not found in file");
47.2165 + typename std::map<std::string, Edge>::iterator it =
47.2166 + _edge_index.find(tokens[label_index]);
47.2167 + if (it == _edge_index.end()) {
47.2168 + std::ostringstream msg;
47.2169 + msg << "Edge with label not found: " << tokens[label_index];
47.2170 + throw DataFormatError(msg.str().c_str());
47.2171 + }
47.2172 + e = it->second;
47.2173 + }
47.2174 +
47.2175 + for (int i = 0; i < static_cast<int>(_edge_maps.size()); ++i) {
47.2176 + _edge_maps[i].second->set(e, tokens[map_index[i]]);
47.2177 + }
47.2178
47.2179 }
47.2180 if (readSuccess()) {
47.2181 - line.putback(c);
47.2182 + line.putback(c);
47.2183 }
47.2184 }
47.2185
47.2186 @@ -1883,125 +1883,125 @@
47.2187
47.2188 char c;
47.2189 while (readLine() && line >> c && c != '@') {
47.2190 - line.putback(c);
47.2191 -
47.2192 - std::string attr, token;
47.2193 - if (!_reader_bits::readToken(line, attr))
47.2194 - throw DataFormatError("Attribute name not found");
47.2195 - if (!_reader_bits::readToken(line, token))
47.2196 - throw DataFormatError("Attribute value not found");
47.2197 - if (line >> c)
47.2198 - throw DataFormatError("Extra character on the end of line");
47.2199 -
47.2200 - {
47.2201 - std::set<std::string>::iterator it = read_attr.find(attr);
47.2202 - if (it != read_attr.end()) {
47.2203 - std::ostringstream msg;
47.2204 - msg << "Multiple occurence of attribute " << attr;
47.2205 - throw DataFormatError(msg.str().c_str());
47.2206 - }
47.2207 - read_attr.insert(attr);
47.2208 - }
47.2209 -
47.2210 - {
47.2211 - typename Attributes::iterator it = _attributes.lower_bound(attr);
47.2212 - while (it != _attributes.end() && it->first == attr) {
47.2213 - it->second->set(token);
47.2214 - ++it;
47.2215 - }
47.2216 - }
47.2217 + line.putback(c);
47.2218 +
47.2219 + std::string attr, token;
47.2220 + if (!_reader_bits::readToken(line, attr))
47.2221 + throw DataFormatError("Attribute name not found");
47.2222 + if (!_reader_bits::readToken(line, token))
47.2223 + throw DataFormatError("Attribute value not found");
47.2224 + if (line >> c)
47.2225 + throw DataFormatError("Extra character on the end of line");
47.2226 +
47.2227 + {
47.2228 + std::set<std::string>::iterator it = read_attr.find(attr);
47.2229 + if (it != read_attr.end()) {
47.2230 + std::ostringstream msg;
47.2231 + msg << "Multiple occurence of attribute " << attr;
47.2232 + throw DataFormatError(msg.str().c_str());
47.2233 + }
47.2234 + read_attr.insert(attr);
47.2235 + }
47.2236 +
47.2237 + {
47.2238 + typename Attributes::iterator it = _attributes.lower_bound(attr);
47.2239 + while (it != _attributes.end() && it->first == attr) {
47.2240 + it->second->set(token);
47.2241 + ++it;
47.2242 + }
47.2243 + }
47.2244
47.2245 }
47.2246 if (readSuccess()) {
47.2247 - line.putback(c);
47.2248 + line.putback(c);
47.2249 }
47.2250 for (typename Attributes::iterator it = _attributes.begin();
47.2251 - it != _attributes.end(); ++it) {
47.2252 - if (read_attr.find(it->first) == read_attr.end()) {
47.2253 - std::ostringstream msg;
47.2254 - msg << "Attribute not found in file: " << it->first;
47.2255 - throw DataFormatError(msg.str().c_str());
47.2256 - }
47.2257 + it != _attributes.end(); ++it) {
47.2258 + if (read_attr.find(it->first) == read_attr.end()) {
47.2259 + std::ostringstream msg;
47.2260 + msg << "Attribute not found in file: " << it->first;
47.2261 + throw DataFormatError(msg.str().c_str());
47.2262 + }
47.2263 }
47.2264 }
47.2265
47.2266 public:
47.2267
47.2268 - /// \name Execution of the reader
47.2269 + /// \name Execution of the reader
47.2270 /// @{
47.2271
47.2272 /// \brief Start the batch processing
47.2273 ///
47.2274 /// This function starts the batch processing
47.2275 void run() {
47.2276 -
47.2277 +
47.2278 LEMON_ASSERT(_is != 0, "This reader assigned to an other reader");
47.2279 -
47.2280 +
47.2281 bool nodes_done = _skip_nodes;
47.2282 bool edges_done = _skip_edges;
47.2283 bool attributes_done = false;
47.2284
47.2285 - line_num = 0;
47.2286 + line_num = 0;
47.2287 readLine();
47.2288 skipSection();
47.2289
47.2290 while (readSuccess()) {
47.2291 - try {
47.2292 - char c;
47.2293 - std::string section, caption;
47.2294 - line >> c;
47.2295 - _reader_bits::readToken(line, section);
47.2296 - _reader_bits::readToken(line, caption);
47.2297 -
47.2298 - if (line >> c)
47.2299 - throw DataFormatError("Extra character on the end of line");
47.2300 -
47.2301 - if (section == "nodes" && !nodes_done) {
47.2302 - if (_nodes_caption.empty() || _nodes_caption == caption) {
47.2303 - readNodes();
47.2304 - nodes_done = true;
47.2305 - }
47.2306 - } else if ((section == "edges" || section == "arcs") &&
47.2307 - !edges_done) {
47.2308 - if (_edges_caption.empty() || _edges_caption == caption) {
47.2309 - readEdges();
47.2310 - edges_done = true;
47.2311 - }
47.2312 - } else if (section == "attributes" && !attributes_done) {
47.2313 - if (_attributes_caption.empty() || _attributes_caption == caption) {
47.2314 - readAttributes();
47.2315 - attributes_done = true;
47.2316 - }
47.2317 - } else {
47.2318 - readLine();
47.2319 - skipSection();
47.2320 - }
47.2321 - } catch (DataFormatError& error) {
47.2322 - error.line(line_num);
47.2323 - throw;
47.2324 - }
47.2325 + try {
47.2326 + char c;
47.2327 + std::string section, caption;
47.2328 + line >> c;
47.2329 + _reader_bits::readToken(line, section);
47.2330 + _reader_bits::readToken(line, caption);
47.2331 +
47.2332 + if (line >> c)
47.2333 + throw DataFormatError("Extra character on the end of line");
47.2334 +
47.2335 + if (section == "nodes" && !nodes_done) {
47.2336 + if (_nodes_caption.empty() || _nodes_caption == caption) {
47.2337 + readNodes();
47.2338 + nodes_done = true;
47.2339 + }
47.2340 + } else if ((section == "edges" || section == "arcs") &&
47.2341 + !edges_done) {
47.2342 + if (_edges_caption.empty() || _edges_caption == caption) {
47.2343 + readEdges();
47.2344 + edges_done = true;
47.2345 + }
47.2346 + } else if (section == "attributes" && !attributes_done) {
47.2347 + if (_attributes_caption.empty() || _attributes_caption == caption) {
47.2348 + readAttributes();
47.2349 + attributes_done = true;
47.2350 + }
47.2351 + } else {
47.2352 + readLine();
47.2353 + skipSection();
47.2354 + }
47.2355 + } catch (DataFormatError& error) {
47.2356 + error.line(line_num);
47.2357 + throw;
47.2358 + }
47.2359 }
47.2360
47.2361 if (!nodes_done) {
47.2362 - throw DataFormatError("Section @nodes not found");
47.2363 + throw DataFormatError("Section @nodes not found");
47.2364 }
47.2365
47.2366 if (!edges_done) {
47.2367 - throw DataFormatError("Section @edges not found");
47.2368 + throw DataFormatError("Section @edges not found");
47.2369 }
47.2370
47.2371 if (!attributes_done && !_attributes.empty()) {
47.2372 - throw DataFormatError("Section @attributes not found");
47.2373 + throw DataFormatError("Section @attributes not found");
47.2374 }
47.2375
47.2376 }
47.2377
47.2378 /// @}
47.2379 -
47.2380 +
47.2381 };
47.2382
47.2383 /// \brief Return a \ref GraphReader class
47.2384 - ///
47.2385 + ///
47.2386 /// This function just returns a \ref GraphReader class.
47.2387 /// \relates GraphReader
47.2388 template <typename Graph>
47.2389 @@ -2011,18 +2011,18 @@
47.2390 }
47.2391
47.2392 /// \brief Return a \ref GraphReader class
47.2393 - ///
47.2394 + ///
47.2395 /// This function just returns a \ref GraphReader class.
47.2396 /// \relates GraphReader
47.2397 template <typename Graph>
47.2398 - GraphReader<Graph> graphReader(const std::string& fn,
47.2399 - Graph& graph) {
47.2400 + GraphReader<Graph> graphReader(const std::string& fn,
47.2401 + Graph& graph) {
47.2402 GraphReader<Graph> tmp(fn, graph);
47.2403 return tmp;
47.2404 }
47.2405
47.2406 /// \brief Return a \ref GraphReader class
47.2407 - ///
47.2408 + ///
47.2409 /// This function just returns a \ref GraphReader class.
47.2410 /// \relates GraphReader
47.2411 template <typename Graph>
47.2412 @@ -2036,21 +2036,21 @@
47.2413 SectionReader sectionReader(std::istream& is);
47.2414 SectionReader sectionReader(const std::string& fn);
47.2415 SectionReader sectionReader(const char* fn);
47.2416 -
47.2417 +
47.2418 /// \ingroup lemon_io
47.2419 ///
47.2420 /// \brief Section reader class
47.2421 ///
47.2422 - /// In the \ref lgf-format "LGF" file extra sections can be placed,
47.2423 + /// In the \ref lgf-format "LGF" file extra sections can be placed,
47.2424 /// which contain any data in arbitrary format. Such sections can be
47.2425 - /// read with this class. A reading rule can be added to the class
47.2426 + /// read with this class. A reading rule can be added to the class
47.2427 /// with two different functions. With the \c sectionLines() function a
47.2428 /// functor can process the section line-by-line, while with the \c
47.2429 /// sectionStream() member the section can be read from an input
47.2430 /// stream.
47.2431 class SectionReader {
47.2432 private:
47.2433 -
47.2434 +
47.2435 std::istream* _is;
47.2436 bool local_is;
47.2437
47.2438 @@ -2066,30 +2066,30 @@
47.2439 ///
47.2440 /// Construct a section reader, which reads from the given input
47.2441 /// stream.
47.2442 - SectionReader(std::istream& is)
47.2443 + SectionReader(std::istream& is)
47.2444 : _is(&is), local_is(false) {}
47.2445
47.2446 /// \brief Constructor
47.2447 ///
47.2448 /// Construct a section reader, which reads from the given file.
47.2449 - SectionReader(const std::string& fn)
47.2450 + SectionReader(const std::string& fn)
47.2451 : _is(new std::ifstream(fn.c_str())), local_is(true) {}
47.2452 -
47.2453 +
47.2454 /// \brief Constructor
47.2455 ///
47.2456 /// Construct a section reader, which reads from the given file.
47.2457 - SectionReader(const char* fn)
47.2458 + SectionReader(const char* fn)
47.2459 : _is(new std::ifstream(fn)), local_is(true) {}
47.2460
47.2461 /// \brief Destructor
47.2462 ~SectionReader() {
47.2463 - for (Sections::iterator it = _sections.begin();
47.2464 - it != _sections.end(); ++it) {
47.2465 - delete it->second;
47.2466 + for (Sections::iterator it = _sections.begin();
47.2467 + it != _sections.end(); ++it) {
47.2468 + delete it->second;
47.2469 }
47.2470
47.2471 if (local_is) {
47.2472 - delete _is;
47.2473 + delete _is;
47.2474 }
47.2475
47.2476 }
47.2477 @@ -2100,15 +2100,15 @@
47.2478 friend SectionReader sectionReader(const std::string& fn);
47.2479 friend SectionReader sectionReader(const char* fn);
47.2480
47.2481 - SectionReader(SectionReader& other)
47.2482 + SectionReader(SectionReader& other)
47.2483 : _is(other._is), local_is(other.local_is) {
47.2484
47.2485 other._is = 0;
47.2486 other.local_is = false;
47.2487 -
47.2488 +
47.2489 _sections.swap(other._sections);
47.2490 }
47.2491 -
47.2492 +
47.2493 SectionReader& operator=(const SectionReader&);
47.2494
47.2495 public:
47.2496 @@ -2148,14 +2148,14 @@
47.2497 ///
47.2498 /// // ...
47.2499 ///
47.2500 - /// reader.sectionLines("numbers", NumberSection(vec));
47.2501 + /// reader.sectionLines("numbers", NumberSection(vec));
47.2502 ///\endcode
47.2503 template <typename Functor>
47.2504 SectionReader& sectionLines(const std::string& type, Functor functor) {
47.2505 LEMON_ASSERT(!type.empty(), "Type is empty.");
47.2506 - LEMON_ASSERT(_sections.find(type) == _sections.end(),
47.2507 - "Multiple reading of section.");
47.2508 - _sections.insert(std::make_pair(type,
47.2509 + LEMON_ASSERT(_sections.find(type) == _sections.end(),
47.2510 + "Multiple reading of section.");
47.2511 + _sections.insert(std::make_pair(type,
47.2512 new _reader_bits::LineSection<Functor>(functor)));
47.2513 return *this;
47.2514 }
47.2515 @@ -2171,13 +2171,13 @@
47.2516 template <typename Functor>
47.2517 SectionReader& sectionStream(const std::string& type, Functor functor) {
47.2518 LEMON_ASSERT(!type.empty(), "Type is empty.");
47.2519 - LEMON_ASSERT(_sections.find(type) == _sections.end(),
47.2520 - "Multiple reading of section.");
47.2521 - _sections.insert(std::make_pair(type,
47.2522 - new _reader_bits::StreamSection<Functor>(functor)));
47.2523 + LEMON_ASSERT(_sections.find(type) == _sections.end(),
47.2524 + "Multiple reading of section.");
47.2525 + _sections.insert(std::make_pair(type,
47.2526 + new _reader_bits::StreamSection<Functor>(functor)));
47.2527 return *this;
47.2528 - }
47.2529 -
47.2530 + }
47.2531 +
47.2532 /// @}
47.2533
47.2534 private:
47.2535 @@ -2185,12 +2185,12 @@
47.2536 bool readLine() {
47.2537 std::string str;
47.2538 while(++line_num, std::getline(*_is, str)) {
47.2539 - line.clear(); line.str(str);
47.2540 - char c;
47.2541 - if (line >> std::ws >> c && c != '#') {
47.2542 - line.putback(c);
47.2543 - return true;
47.2544 - }
47.2545 + line.clear(); line.str(str);
47.2546 + char c;
47.2547 + if (line >> std::ws >> c && c != '#') {
47.2548 + line.putback(c);
47.2549 + return true;
47.2550 + }
47.2551 }
47.2552 return false;
47.2553 }
47.2554 @@ -2198,11 +2198,11 @@
47.2555 bool readSuccess() {
47.2556 return static_cast<bool>(*_is);
47.2557 }
47.2558 -
47.2559 +
47.2560 void skipSection() {
47.2561 char c;
47.2562 while (readSuccess() && line >> c && c != '@') {
47.2563 - readLine();
47.2564 + readLine();
47.2565 }
47.2566 line.putback(c);
47.2567 }
47.2568 @@ -2210,66 +2210,66 @@
47.2569 public:
47.2570
47.2571
47.2572 - /// \name Execution of the reader
47.2573 + /// \name Execution of the reader
47.2574 /// @{
47.2575
47.2576 /// \brief Start the batch processing
47.2577 ///
47.2578 /// This function starts the batch processing.
47.2579 void run() {
47.2580 -
47.2581 +
47.2582 LEMON_ASSERT(_is != 0, "This reader assigned to an other reader");
47.2583 -
47.2584 +
47.2585 std::set<std::string> extra_sections;
47.2586
47.2587 - line_num = 0;
47.2588 + line_num = 0;
47.2589 readLine();
47.2590 skipSection();
47.2591
47.2592 while (readSuccess()) {
47.2593 - try {
47.2594 - char c;
47.2595 - std::string section, caption;
47.2596 - line >> c;
47.2597 - _reader_bits::readToken(line, section);
47.2598 - _reader_bits::readToken(line, caption);
47.2599 -
47.2600 - if (line >> c)
47.2601 - throw DataFormatError("Extra character on the end of line");
47.2602 -
47.2603 - if (extra_sections.find(section) != extra_sections.end()) {
47.2604 - std::ostringstream msg;
47.2605 - msg << "Multiple occurence of section " << section;
47.2606 - throw DataFormatError(msg.str().c_str());
47.2607 - }
47.2608 - Sections::iterator it = _sections.find(section);
47.2609 - if (it != _sections.end()) {
47.2610 - extra_sections.insert(section);
47.2611 - it->second->process(*_is, line_num);
47.2612 - }
47.2613 - readLine();
47.2614 - skipSection();
47.2615 - } catch (DataFormatError& error) {
47.2616 - error.line(line_num);
47.2617 - throw;
47.2618 - }
47.2619 + try {
47.2620 + char c;
47.2621 + std::string section, caption;
47.2622 + line >> c;
47.2623 + _reader_bits::readToken(line, section);
47.2624 + _reader_bits::readToken(line, caption);
47.2625 +
47.2626 + if (line >> c)
47.2627 + throw DataFormatError("Extra character on the end of line");
47.2628 +
47.2629 + if (extra_sections.find(section) != extra_sections.end()) {
47.2630 + std::ostringstream msg;
47.2631 + msg << "Multiple occurence of section " << section;
47.2632 + throw DataFormatError(msg.str().c_str());
47.2633 + }
47.2634 + Sections::iterator it = _sections.find(section);
47.2635 + if (it != _sections.end()) {
47.2636 + extra_sections.insert(section);
47.2637 + it->second->process(*_is, line_num);
47.2638 + }
47.2639 + readLine();
47.2640 + skipSection();
47.2641 + } catch (DataFormatError& error) {
47.2642 + error.line(line_num);
47.2643 + throw;
47.2644 + }
47.2645 }
47.2646 for (Sections::iterator it = _sections.begin();
47.2647 - it != _sections.end(); ++it) {
47.2648 - if (extra_sections.find(it->first) == extra_sections.end()) {
47.2649 - std::ostringstream os;
47.2650 - os << "Cannot find section: " << it->first;
47.2651 - throw DataFormatError(os.str().c_str());
47.2652 - }
47.2653 + it != _sections.end(); ++it) {
47.2654 + if (extra_sections.find(it->first) == extra_sections.end()) {
47.2655 + std::ostringstream os;
47.2656 + os << "Cannot find section: " << it->first;
47.2657 + throw DataFormatError(os.str().c_str());
47.2658 + }
47.2659 }
47.2660 }
47.2661
47.2662 /// @}
47.2663 -
47.2664 +
47.2665 };
47.2666
47.2667 /// \brief Return a \ref SectionReader class
47.2668 - ///
47.2669 + ///
47.2670 /// This function just returns a \ref SectionReader class.
47.2671 /// \relates SectionReader
47.2672 inline SectionReader sectionReader(std::istream& is) {
47.2673 @@ -2278,7 +2278,7 @@
47.2674 }
47.2675
47.2676 /// \brief Return a \ref SectionReader class
47.2677 - ///
47.2678 + ///
47.2679 /// This function just returns a \ref SectionReader class.
47.2680 /// \relates SectionReader
47.2681 inline SectionReader sectionReader(const std::string& fn) {
47.2682 @@ -2287,7 +2287,7 @@
47.2683 }
47.2684
47.2685 /// \brief Return a \ref SectionReader class
47.2686 - ///
47.2687 + ///
47.2688 /// This function just returns a \ref SectionReader class.
47.2689 /// \relates SectionReader
47.2690 inline SectionReader sectionReader(const char* fn) {
47.2691 @@ -2297,7 +2297,7 @@
47.2692
47.2693 /// \ingroup lemon_io
47.2694 ///
47.2695 - /// \brief Reader for the contents of the \ref lgf-format "LGF" file
47.2696 + /// \brief Reader for the contents of the \ref lgf-format "LGF" file
47.2697 ///
47.2698 /// This class can be used to read the sections, the map names and
47.2699 /// the attributes from a file. Usually, the Lemon programs know
47.2700 @@ -2307,8 +2307,8 @@
47.2701 /// reads the graph and stores the appropriate information for
47.2702 /// reading the graph.
47.2703 ///
47.2704 - ///\code
47.2705 - /// LgfContents contents("graph.lgf");
47.2706 + ///\code
47.2707 + /// LgfContents contents("graph.lgf");
47.2708 /// contents.run();
47.2709 ///
47.2710 /// // Does it contain any node section and arc section?
47.2711 @@ -2316,14 +2316,14 @@
47.2712 /// std::cerr << "Failure, cannot find graph." << std::endl;
47.2713 /// return -1;
47.2714 /// }
47.2715 - /// std::cout << "The name of the default node section: "
47.2716 + /// std::cout << "The name of the default node section: "
47.2717 /// << contents.nodeSection(0) << std::endl;
47.2718 - /// std::cout << "The number of the arc maps: "
47.2719 + /// std::cout << "The number of the arc maps: "
47.2720 /// << contents.arcMaps(0).size() << std::endl;
47.2721 - /// std::cout << "The name of second arc map: "
47.2722 + /// std::cout << "The name of second arc map: "
47.2723 /// << contents.arcMaps(0)[1] << std::endl;
47.2724 ///\endcode
47.2725 - class LgfContents {
47.2726 + class LgfContents {
47.2727 private:
47.2728
47.2729 std::istream* _is;
47.2730 @@ -2344,21 +2344,21 @@
47.2731
47.2732 int line_num;
47.2733 std::istringstream line;
47.2734 -
47.2735 +
47.2736 public:
47.2737
47.2738 /// \brief Constructor
47.2739 ///
47.2740 /// Construct an \e LGF contents reader, which reads from the given
47.2741 /// input stream.
47.2742 - LgfContents(std::istream& is)
47.2743 + LgfContents(std::istream& is)
47.2744 : _is(&is), local_is(false) {}
47.2745
47.2746 /// \brief Constructor
47.2747 ///
47.2748 /// Construct an \e LGF contents reader, which reads from the given
47.2749 /// file.
47.2750 - LgfContents(const std::string& fn)
47.2751 + LgfContents(const std::string& fn)
47.2752 : _is(new std::ifstream(fn.c_str())), local_is(true) {}
47.2753
47.2754 /// \brief Constructor
47.2755 @@ -2367,14 +2367,14 @@
47.2756 /// file.
47.2757 LgfContents(const char* fn)
47.2758 : _is(new std::ifstream(fn)), local_is(true) {}
47.2759 -
47.2760 +
47.2761 /// \brief Destructor
47.2762 ~LgfContents() {
47.2763 if (local_is) delete _is;
47.2764 }
47.2765
47.2766 private:
47.2767 -
47.2768 +
47.2769 LgfContents(const LgfContents&);
47.2770 LgfContents& operator=(const LgfContents&);
47.2771
47.2772 @@ -2391,9 +2391,9 @@
47.2773 return _node_sections.size();
47.2774 }
47.2775
47.2776 - /// \brief Returns the node section name at the given position.
47.2777 + /// \brief Returns the node section name at the given position.
47.2778 ///
47.2779 - /// Returns the node section name at the given position.
47.2780 + /// Returns the node section name at the given position.
47.2781 const std::string& nodeSection(int i) const {
47.2782 return _node_sections[i];
47.2783 }
47.2784 @@ -2407,7 +2407,7 @@
47.2785
47.2786 /// @}
47.2787
47.2788 - /// \name Arc/Edge sections
47.2789 + /// \name Arc/Edge sections
47.2790 /// @{
47.2791
47.2792 /// \brief Gives back the number of arc/edge sections in the file.
47.2793 @@ -2418,9 +2418,9 @@
47.2794 return _edge_sections.size();
47.2795 }
47.2796
47.2797 - /// \brief Returns the arc/edge section name at the given position.
47.2798 + /// \brief Returns the arc/edge section name at the given position.
47.2799 ///
47.2800 - /// Returns the arc/edge section name at the given position.
47.2801 + /// Returns the arc/edge section name at the given position.
47.2802 /// \note It is synonym of \c edgeSection().
47.2803 const std::string& arcSection(int i) const {
47.2804 return _edge_sections[i];
47.2805 @@ -2447,9 +2447,9 @@
47.2806 return _edge_sections.size();
47.2807 }
47.2808
47.2809 - /// \brief Returns the section name at the given position.
47.2810 + /// \brief Returns the section name at the given position.
47.2811 ///
47.2812 - /// Returns the section name at the given position.
47.2813 + /// Returns the section name at the given position.
47.2814 /// \note It is synonym of \c arcSection().
47.2815 const std::string& edgeSection(int i) const {
47.2816 return _edge_sections[i];
47.2817 @@ -2465,7 +2465,7 @@
47.2818
47.2819 /// @}
47.2820
47.2821 - /// \name Attribute sections
47.2822 + /// \name Attribute sections
47.2823 /// @{
47.2824
47.2825 /// \brief Gives back the number of attribute sections in the file.
47.2826 @@ -2475,9 +2475,9 @@
47.2827 return _attribute_sections.size();
47.2828 }
47.2829
47.2830 - /// \brief Returns the attribute section name at the given position.
47.2831 + /// \brief Returns the attribute section name at the given position.
47.2832 ///
47.2833 - /// Returns the attribute section name at the given position.
47.2834 + /// Returns the attribute section name at the given position.
47.2835 const std::string& attributeSectionNames(int i) const {
47.2836 return _attribute_sections[i];
47.2837 }
47.2838 @@ -2491,7 +2491,7 @@
47.2839
47.2840 /// @}
47.2841
47.2842 - /// \name Extra sections
47.2843 + /// \name Extra sections
47.2844 /// @{
47.2845
47.2846 /// \brief Gives back the number of extra sections in the file.
47.2847 @@ -2501,9 +2501,9 @@
47.2848 return _extra_sections.size();
47.2849 }
47.2850
47.2851 - /// \brief Returns the extra section type at the given position.
47.2852 + /// \brief Returns the extra section type at the given position.
47.2853 ///
47.2854 - /// Returns the section type at the given position.
47.2855 + /// Returns the section type at the given position.
47.2856 const std::string& extraSection(int i) const {
47.2857 return _extra_sections[i];
47.2858 }
47.2859 @@ -2515,12 +2515,12 @@
47.2860 bool readLine() {
47.2861 std::string str;
47.2862 while(++line_num, std::getline(*_is, str)) {
47.2863 - line.clear(); line.str(str);
47.2864 - char c;
47.2865 - if (line >> std::ws >> c && c != '#') {
47.2866 - line.putback(c);
47.2867 - return true;
47.2868 - }
47.2869 + line.clear(); line.str(str);
47.2870 + char c;
47.2871 + if (line >> std::ws >> c && c != '#') {
47.2872 + line.putback(c);
47.2873 + return true;
47.2874 + }
47.2875 }
47.2876 return false;
47.2877 }
47.2878 @@ -2532,7 +2532,7 @@
47.2879 void skipSection() {
47.2880 char c;
47.2881 while (readSuccess() && line >> c && c != '@') {
47.2882 - readLine();
47.2883 + readLine();
47.2884 }
47.2885 line.putback(c);
47.2886 }
47.2887 @@ -2540,13 +2540,13 @@
47.2888 void readMaps(std::vector<std::string>& maps) {
47.2889 char c;
47.2890 if (!readLine() || !(line >> c) || c == '@') {
47.2891 - if (readSuccess() && line) line.putback(c);
47.2892 - return;
47.2893 + if (readSuccess() && line) line.putback(c);
47.2894 + return;
47.2895 }
47.2896 line.putback(c);
47.2897 std::string map;
47.2898 while (_reader_bits::readToken(line, map)) {
47.2899 - maps.push_back(map);
47.2900 + maps.push_back(map);
47.2901 }
47.2902 }
47.2903
47.2904 @@ -2554,18 +2554,18 @@
47.2905 readLine();
47.2906 char c;
47.2907 while (readSuccess() && line >> c && c != '@') {
47.2908 - line.putback(c);
47.2909 - std::string attr;
47.2910 - _reader_bits::readToken(line, attr);
47.2911 - attrs.push_back(attr);
47.2912 - readLine();
47.2913 + line.putback(c);
47.2914 + std::string attr;
47.2915 + _reader_bits::readToken(line, attr);
47.2916 + attrs.push_back(attr);
47.2917 + readLine();
47.2918 }
47.2919 line.putback(c);
47.2920 }
47.2921
47.2922 public:
47.2923
47.2924 - /// \name Execution of the contents reader
47.2925 + /// \name Execution of the contents reader
47.2926 /// @{
47.2927
47.2928 /// \brief Starts the reading
47.2929 @@ -2578,37 +2578,37 @@
47.2930
47.2931 while (readSuccess()) {
47.2932
47.2933 - char c;
47.2934 - line >> c;
47.2935 -
47.2936 - std::string section, caption;
47.2937 - _reader_bits::readToken(line, section);
47.2938 - _reader_bits::readToken(line, caption);
47.2939 -
47.2940 - if (section == "nodes") {
47.2941 - _node_sections.push_back(caption);
47.2942 - _node_maps.push_back(std::vector<std::string>());
47.2943 - readMaps(_node_maps.back());
47.2944 - readLine(); skipSection();
47.2945 - } else if (section == "arcs" || section == "edges") {
47.2946 - _edge_sections.push_back(caption);
47.2947 - _arc_sections.push_back(section == "arcs");
47.2948 - _edge_maps.push_back(std::vector<std::string>());
47.2949 - readMaps(_edge_maps.back());
47.2950 - readLine(); skipSection();
47.2951 - } else if (section == "attributes") {
47.2952 - _attribute_sections.push_back(caption);
47.2953 - _attributes.push_back(std::vector<std::string>());
47.2954 - readAttributes(_attributes.back());
47.2955 - } else {
47.2956 - _extra_sections.push_back(section);
47.2957 - readLine(); skipSection();
47.2958 - }
47.2959 + char c;
47.2960 + line >> c;
47.2961 +
47.2962 + std::string section, caption;
47.2963 + _reader_bits::readToken(line, section);
47.2964 + _reader_bits::readToken(line, caption);
47.2965 +
47.2966 + if (section == "nodes") {
47.2967 + _node_sections.push_back(caption);
47.2968 + _node_maps.push_back(std::vector<std::string>());
47.2969 + readMaps(_node_maps.back());
47.2970 + readLine(); skipSection();
47.2971 + } else if (section == "arcs" || section == "edges") {
47.2972 + _edge_sections.push_back(caption);
47.2973 + _arc_sections.push_back(section == "arcs");
47.2974 + _edge_maps.push_back(std::vector<std::string>());
47.2975 + readMaps(_edge_maps.back());
47.2976 + readLine(); skipSection();
47.2977 + } else if (section == "attributes") {
47.2978 + _attribute_sections.push_back(caption);
47.2979 + _attributes.push_back(std::vector<std::string>());
47.2980 + readAttributes(_attributes.back());
47.2981 + } else {
47.2982 + _extra_sections.push_back(section);
47.2983 + readLine(); skipSection();
47.2984 + }
47.2985 }
47.2986 }
47.2987
47.2988 /// @}
47.2989 -
47.2990 +
47.2991 };
47.2992 }
47.2993
48.1 --- a/lemon/lgf_writer.h Sun Jul 13 16:46:56 2008 +0100
48.2 +++ b/lemon/lgf_writer.h Sun Jul 13 19:51:02 2008 +0100
48.3 @@ -1,6 +1,6 @@
48.4 -/* -*- C++ -*-
48.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
48.6 *
48.7 - * This file is a part of LEMON, a generic C++ optimization library
48.8 + * This file is a part of LEMON, a generic C++ optimization library.
48.9 *
48.10 * Copyright (C) 2003-2008
48.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
48.12 @@ -43,9 +43,9 @@
48.13 template <typename Value>
48.14 struct DefaultConverter {
48.15 std::string operator()(const Value& value) {
48.16 - std::ostringstream os;
48.17 - os << value;
48.18 - return os.str();
48.19 + std::ostringstream os;
48.20 + os << value;
48.21 + return os.str();
48.22 }
48.23 };
48.24
48.25 @@ -62,12 +62,12 @@
48.26
48.27 private:
48.28 const Map& _map;
48.29 -
48.30 +
48.31 public:
48.32 MapLess(const Map& map) : _map(map) {}
48.33
48.34 bool operator()(const Item& left, const Item& right) {
48.35 - return _map[left] < _map[right];
48.36 + return _map[left] < _map[right];
48.37 }
48.38 };
48.39
48.40 @@ -81,18 +81,18 @@
48.41 private:
48.42 const Graph& _graph;
48.43 const Map& _map;
48.44 -
48.45 +
48.46 public:
48.47 - GraphArcMapLess(const Graph& graph, const Map& map)
48.48 - : _graph(graph), _map(map) {}
48.49 + GraphArcMapLess(const Graph& graph, const Map& map)
48.50 + : _graph(graph), _map(map) {}
48.51
48.52 bool operator()(const Item& left, const Item& right) {
48.53 - return _map[_graph.direct(left, _dir)] <
48.54 - _map[_graph.direct(right, _dir)];
48.55 + return _map[_graph.direct(left, _dir)] <
48.56 + _map[_graph.direct(right, _dir)];
48.57 }
48.58 };
48.59
48.60 - template <typename _Item>
48.61 + template <typename _Item>
48.62 class MapStorageBase {
48.63 public:
48.64 typedef _Item Item;
48.65 @@ -105,34 +105,34 @@
48.66 virtual void sort(std::vector<Item>&) = 0;
48.67 };
48.68
48.69 - template <typename _Item, typename _Map,
48.70 - typename _Converter = DefaultConverter<typename _Map::Value> >
48.71 + template <typename _Item, typename _Map,
48.72 + typename _Converter = DefaultConverter<typename _Map::Value> >
48.73 class MapStorage : public MapStorageBase<_Item> {
48.74 public:
48.75 typedef _Map Map;
48.76 typedef _Converter Converter;
48.77 typedef _Item Item;
48.78 -
48.79 +
48.80 private:
48.81 const Map& _map;
48.82 Converter _converter;
48.83
48.84 public:
48.85 - MapStorage(const Map& map, const Converter& converter = Converter())
48.86 - : _map(map), _converter(converter) {}
48.87 + MapStorage(const Map& map, const Converter& converter = Converter())
48.88 + : _map(map), _converter(converter) {}
48.89 virtual ~MapStorage() {}
48.90
48.91 virtual std::string get(const Item& item) {
48.92 - return _converter(_map[item]);
48.93 + return _converter(_map[item]);
48.94 }
48.95 virtual void sort(std::vector<Item>& items) {
48.96 - MapLess<Map> less(_map);
48.97 - std::sort(items.begin(), items.end(), less);
48.98 + MapLess<Map> less(_map);
48.99 + std::sort(items.begin(), items.end(), less);
48.100 }
48.101 };
48.102
48.103 - template <typename _Graph, bool _dir, typename _Map,
48.104 - typename _Converter = DefaultConverter<typename _Map::Value> >
48.105 + template <typename _Graph, bool _dir, typename _Map,
48.106 + typename _Converter = DefaultConverter<typename _Map::Value> >
48.107 class GraphArcMapStorage : public MapStorageBase<typename _Graph::Edge> {
48.108 public:
48.109 typedef _Map Map;
48.110 @@ -140,24 +140,24 @@
48.111 typedef _Graph Graph;
48.112 typedef typename Graph::Edge Item;
48.113 static const bool dir = _dir;
48.114 -
48.115 +
48.116 private:
48.117 const Graph& _graph;
48.118 const Map& _map;
48.119 Converter _converter;
48.120
48.121 public:
48.122 - GraphArcMapStorage(const Graph& graph, const Map& map,
48.123 - const Converter& converter = Converter())
48.124 - : _graph(graph), _map(map), _converter(converter) {}
48.125 + GraphArcMapStorage(const Graph& graph, const Map& map,
48.126 + const Converter& converter = Converter())
48.127 + : _graph(graph), _map(map), _converter(converter) {}
48.128 virtual ~GraphArcMapStorage() {}
48.129
48.130 virtual std::string get(const Item& item) {
48.131 - return _converter(_map[_graph.direct(item, dir)]);
48.132 + return _converter(_map[_graph.direct(item, dir)]);
48.133 }
48.134 virtual void sort(std::vector<Item>& items) {
48.135 - GraphArcMapLess<Graph, dir, Map> less(_graph, _map);
48.136 - std::sort(items.begin(), items.end(), less);
48.137 + GraphArcMapLess<Graph, dir, Map> less(_graph, _map);
48.138 + std::sort(items.begin(), items.end(), less);
48.139 }
48.140 };
48.141
48.142 @@ -166,7 +166,7 @@
48.143 ValueStorageBase() {}
48.144 virtual ~ValueStorageBase() {}
48.145
48.146 - virtual std::string get() = 0;
48.147 + virtual std::string get() = 0;
48.148 };
48.149
48.150 template <typename _Value, typename _Converter = DefaultConverter<_Value> >
48.151 @@ -181,27 +181,27 @@
48.152
48.153 public:
48.154 ValueStorage(const Value& value, const Converter& converter = Converter())
48.155 - : _value(value), _converter(converter) {}
48.156 + : _value(value), _converter(converter) {}
48.157
48.158 virtual std::string get() {
48.159 - return _converter(_value);
48.160 + return _converter(_value);
48.161 }
48.162 };
48.163
48.164 template <typename Value>
48.165 struct MapLookUpConverter {
48.166 const std::map<Value, std::string>& _map;
48.167 -
48.168 - MapLookUpConverter(const std::map<Value, std::string>& map)
48.169 - : _map(map) {}
48.170 -
48.171 +
48.172 + MapLookUpConverter(const std::map<Value, std::string>& map)
48.173 + : _map(map) {}
48.174 +
48.175 std::string operator()(const Value& str) {
48.176 - typename std::map<Value, std::string>::const_iterator it =
48.177 - _map.find(str);
48.178 - if (it == _map.end()) {
48.179 - throw DataFormatError("Item not found");
48.180 - }
48.181 - return it->second;
48.182 + typename std::map<Value, std::string>::const_iterator it =
48.183 + _map.find(str);
48.184 + if (it == _map.end()) {
48.185 + throw DataFormatError("Item not found");
48.186 + }
48.187 + return it->second;
48.188 }
48.189 };
48.190
48.191 @@ -209,71 +209,71 @@
48.192 struct GraphArcLookUpConverter {
48.193 const Graph& _graph;
48.194 const std::map<typename Graph::Edge, std::string>& _map;
48.195 -
48.196 - GraphArcLookUpConverter(const Graph& graph,
48.197 - const std::map<typename Graph::Edge,
48.198 - std::string>& map)
48.199 - : _graph(graph), _map(map) {}
48.200 -
48.201 +
48.202 + GraphArcLookUpConverter(const Graph& graph,
48.203 + const std::map<typename Graph::Edge,
48.204 + std::string>& map)
48.205 + : _graph(graph), _map(map) {}
48.206 +
48.207 std::string operator()(const typename Graph::Arc& val) {
48.208 - typename std::map<typename Graph::Edge, std::string>
48.209 - ::const_iterator it = _map.find(val);
48.210 - if (it == _map.end()) {
48.211 - throw DataFormatError("Item not found");
48.212 - }
48.213 - return (_graph.direction(val) ? '+' : '-') + it->second;
48.214 + typename std::map<typename Graph::Edge, std::string>
48.215 + ::const_iterator it = _map.find(val);
48.216 + if (it == _map.end()) {
48.217 + throw DataFormatError("Item not found");
48.218 + }
48.219 + return (_graph.direction(val) ? '+' : '-') + it->second;
48.220 }
48.221 };
48.222
48.223 inline bool isWhiteSpace(char c) {
48.224 - return c == ' ' || c == '\t' || c == '\v' ||
48.225 - c == '\n' || c == '\r' || c == '\f';
48.226 + return c == ' ' || c == '\t' || c == '\v' ||
48.227 + c == '\n' || c == '\r' || c == '\f';
48.228 }
48.229
48.230 inline bool isEscaped(char c) {
48.231 - return c == '\\' || c == '\"' || c == '\'' ||
48.232 - c == '\a' || c == '\b';
48.233 + return c == '\\' || c == '\"' || c == '\'' ||
48.234 + c == '\a' || c == '\b';
48.235 }
48.236
48.237 inline static void writeEscape(std::ostream& os, char c) {
48.238 switch (c) {
48.239 case '\\':
48.240 - os << "\\\\";
48.241 - return;
48.242 + os << "\\\\";
48.243 + return;
48.244 case '\"':
48.245 - os << "\\\"";
48.246 - return;
48.247 + os << "\\\"";
48.248 + return;
48.249 case '\a':
48.250 - os << "\\a";
48.251 - return;
48.252 + os << "\\a";
48.253 + return;
48.254 case '\b':
48.255 - os << "\\b";
48.256 - return;
48.257 + os << "\\b";
48.258 + return;
48.259 case '\f':
48.260 - os << "\\f";
48.261 - return;
48.262 + os << "\\f";
48.263 + return;
48.264 case '\r':
48.265 - os << "\\r";
48.266 - return;
48.267 + os << "\\r";
48.268 + return;
48.269 case '\n':
48.270 - os << "\\n";
48.271 - return;
48.272 + os << "\\n";
48.273 + return;
48.274 case '\t':
48.275 - os << "\\t";
48.276 - return;
48.277 + os << "\\t";
48.278 + return;
48.279 case '\v':
48.280 - os << "\\v";
48.281 - return;
48.282 + os << "\\v";
48.283 + return;
48.284 default:
48.285 - if (c < 0x20) {
48.286 - std::ios::fmtflags flags = os.flags();
48.287 - os << '\\' << std::oct << static_cast<int>(c);
48.288 - os.flags(flags);
48.289 - } else {
48.290 - os << c;
48.291 - }
48.292 - return;
48.293 - }
48.294 + if (c < 0x20) {
48.295 + std::ios::fmtflags flags = os.flags();
48.296 + os << '\\' << std::oct << static_cast<int>(c);
48.297 + os.flags(flags);
48.298 + } else {
48.299 + os << c;
48.300 + }
48.301 + return;
48.302 + }
48.303 }
48.304
48.305 inline bool requireEscape(const std::string& str) {
48.306 @@ -281,24 +281,24 @@
48.307 std::istringstream is(str);
48.308 char c;
48.309 while (is.get(c)) {
48.310 - if (isWhiteSpace(c) || isEscaped(c)) {
48.311 - return true;
48.312 - }
48.313 + if (isWhiteSpace(c) || isEscaped(c)) {
48.314 + return true;
48.315 + }
48.316 }
48.317 return false;
48.318 }
48.319 -
48.320 +
48.321 inline std::ostream& writeToken(std::ostream& os, const std::string& str) {
48.322
48.323 if (requireEscape(str)) {
48.324 - os << '\"';
48.325 - for (std::string::const_iterator it = str.begin();
48.326 - it != str.end(); ++it) {
48.327 - writeEscape(os, *it);
48.328 - }
48.329 - os << '\"';
48.330 + os << '\"';
48.331 + for (std::string::const_iterator it = str.begin();
48.332 + it != str.end(); ++it) {
48.333 + writeEscape(os, *it);
48.334 + }
48.335 + os << '\"';
48.336 } else {
48.337 - os << str;
48.338 + os << str;
48.339 }
48.340 return os;
48.341 }
48.342 @@ -309,19 +309,19 @@
48.343 class DigraphWriter;
48.344
48.345 template <typename Digraph>
48.346 - DigraphWriter<Digraph> digraphWriter(std::ostream& os,
48.347 - const Digraph& digraph);
48.348 + DigraphWriter<Digraph> digraphWriter(std::ostream& os,
48.349 + const Digraph& digraph);
48.350
48.351 template <typename Digraph>
48.352 - DigraphWriter<Digraph> digraphWriter(const std::string& fn,
48.353 - const Digraph& digraph);
48.354 + DigraphWriter<Digraph> digraphWriter(const std::string& fn,
48.355 + const Digraph& digraph);
48.356
48.357 template <typename Digraph>
48.358 - DigraphWriter<Digraph> digraphWriter(const char *fn,
48.359 - const Digraph& digraph);
48.360 -
48.361 + DigraphWriter<Digraph> digraphWriter(const char *fn,
48.362 + const Digraph& digraph);
48.363 +
48.364 /// \ingroup lemon_io
48.365 - ///
48.366 + ///
48.367 /// \brief \ref lgf-format "LGF" writer for directed graphs
48.368 ///
48.369 /// This utility writes an \ref lgf-format "LGF" file.
48.370 @@ -370,7 +370,7 @@
48.371
48.372 typedef _Digraph Digraph;
48.373 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
48.374 -
48.375 +
48.376 private:
48.377
48.378
48.379 @@ -382,21 +382,21 @@
48.380 std::string _nodes_caption;
48.381 std::string _arcs_caption;
48.382 std::string _attributes_caption;
48.383 -
48.384 +
48.385 typedef std::map<Node, std::string> NodeIndex;
48.386 NodeIndex _node_index;
48.387 typedef std::map<Arc, std::string> ArcIndex;
48.388 ArcIndex _arc_index;
48.389
48.390 - typedef std::vector<std::pair<std::string,
48.391 - _writer_bits::MapStorageBase<Node>* > > NodeMaps;
48.392 - NodeMaps _node_maps;
48.393 + typedef std::vector<std::pair<std::string,
48.394 + _writer_bits::MapStorageBase<Node>* > > NodeMaps;
48.395 + NodeMaps _node_maps;
48.396
48.397 - typedef std::vector<std::pair<std::string,
48.398 + typedef std::vector<std::pair<std::string,
48.399 _writer_bits::MapStorageBase<Arc>* > >ArcMaps;
48.400 ArcMaps _arc_maps;
48.401
48.402 - typedef std::vector<std::pair<std::string,
48.403 + typedef std::vector<std::pair<std::string,
48.404 _writer_bits::ValueStorageBase*> > Attributes;
48.405 Attributes _attributes;
48.406
48.407 @@ -409,60 +409,60 @@
48.408 ///
48.409 /// Construct a directed graph writer, which writes to the given
48.410 /// output stream.
48.411 - DigraphWriter(std::ostream& is, const Digraph& digraph)
48.412 + DigraphWriter(std::ostream& is, const Digraph& digraph)
48.413 : _os(&is), local_os(false), _digraph(digraph),
48.414 - _skip_nodes(false), _skip_arcs(false) {}
48.415 + _skip_nodes(false), _skip_arcs(false) {}
48.416
48.417 /// \brief Constructor
48.418 ///
48.419 /// Construct a directed graph writer, which writes to the given
48.420 /// output file.
48.421 - DigraphWriter(const std::string& fn, const Digraph& digraph)
48.422 + DigraphWriter(const std::string& fn, const Digraph& digraph)
48.423 : _os(new std::ofstream(fn.c_str())), local_os(true), _digraph(digraph),
48.424 - _skip_nodes(false), _skip_arcs(false) {}
48.425 + _skip_nodes(false), _skip_arcs(false) {}
48.426
48.427 /// \brief Constructor
48.428 ///
48.429 /// Construct a directed graph writer, which writes to the given
48.430 /// output file.
48.431 - DigraphWriter(const char* fn, const Digraph& digraph)
48.432 + DigraphWriter(const char* fn, const Digraph& digraph)
48.433 : _os(new std::ofstream(fn)), local_os(true), _digraph(digraph),
48.434 - _skip_nodes(false), _skip_arcs(false) {}
48.435 + _skip_nodes(false), _skip_arcs(false) {}
48.436
48.437 /// \brief Destructor
48.438 ~DigraphWriter() {
48.439 - for (typename NodeMaps::iterator it = _node_maps.begin();
48.440 - it != _node_maps.end(); ++it) {
48.441 - delete it->second;
48.442 + for (typename NodeMaps::iterator it = _node_maps.begin();
48.443 + it != _node_maps.end(); ++it) {
48.444 + delete it->second;
48.445 }
48.446
48.447 - for (typename ArcMaps::iterator it = _arc_maps.begin();
48.448 - it != _arc_maps.end(); ++it) {
48.449 - delete it->second;
48.450 + for (typename ArcMaps::iterator it = _arc_maps.begin();
48.451 + it != _arc_maps.end(); ++it) {
48.452 + delete it->second;
48.453 }
48.454
48.455 - for (typename Attributes::iterator it = _attributes.begin();
48.456 - it != _attributes.end(); ++it) {
48.457 - delete it->second;
48.458 + for (typename Attributes::iterator it = _attributes.begin();
48.459 + it != _attributes.end(); ++it) {
48.460 + delete it->second;
48.461 }
48.462
48.463 if (local_os) {
48.464 - delete _os;
48.465 + delete _os;
48.466 }
48.467 }
48.468
48.469 private:
48.470
48.471 - friend DigraphWriter<Digraph> digraphWriter<>(std::ostream& os,
48.472 - const Digraph& digraph);
48.473 - friend DigraphWriter<Digraph> digraphWriter<>(const std::string& fn,
48.474 - const Digraph& digraph);
48.475 - friend DigraphWriter<Digraph> digraphWriter<>(const char *fn,
48.476 - const Digraph& digraph);
48.477 + friend DigraphWriter<Digraph> digraphWriter<>(std::ostream& os,
48.478 + const Digraph& digraph);
48.479 + friend DigraphWriter<Digraph> digraphWriter<>(const std::string& fn,
48.480 + const Digraph& digraph);
48.481 + friend DigraphWriter<Digraph> digraphWriter<>(const char *fn,
48.482 + const Digraph& digraph);
48.483
48.484 - DigraphWriter(DigraphWriter& other)
48.485 + DigraphWriter(DigraphWriter& other)
48.486 : _os(other._os), local_os(other.local_os), _digraph(other._digraph),
48.487 - _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
48.488 + _skip_nodes(other._skip_nodes), _skip_arcs(other._skip_arcs) {
48.489
48.490 other._os = 0;
48.491 other.local_os = false;
48.492 @@ -478,22 +478,22 @@
48.493 _arcs_caption = other._arcs_caption;
48.494 _attributes_caption = other._attributes_caption;
48.495 }
48.496 -
48.497 +
48.498 DigraphWriter& operator=(const DigraphWriter&);
48.499
48.500 public:
48.501
48.502 /// \name Writing rules
48.503 /// @{
48.504 -
48.505 +
48.506 /// \brief Node map writing rule
48.507 ///
48.508 /// Add a node map writing rule to the writer.
48.509 template <typename Map>
48.510 DigraphWriter& nodeMap(const std::string& caption, const Map& map) {
48.511 checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
48.512 - _writer_bits::MapStorageBase<Node>* storage =
48.513 - new _writer_bits::MapStorage<Node, Map>(map);
48.514 + _writer_bits::MapStorageBase<Node>* storage =
48.515 + new _writer_bits::MapStorage<Node, Map>(map);
48.516 _node_maps.push_back(std::make_pair(caption, storage));
48.517 return *this;
48.518 }
48.519 @@ -503,11 +503,11 @@
48.520 /// Add a node map writing rule with specialized converter to the
48.521 /// writer.
48.522 template <typename Map, typename Converter>
48.523 - DigraphWriter& nodeMap(const std::string& caption, const Map& map,
48.524 - const Converter& converter = Converter()) {
48.525 + DigraphWriter& nodeMap(const std::string& caption, const Map& map,
48.526 + const Converter& converter = Converter()) {
48.527 checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
48.528 - _writer_bits::MapStorageBase<Node>* storage =
48.529 - new _writer_bits::MapStorage<Node, Map, Converter>(map, converter);
48.530 + _writer_bits::MapStorageBase<Node>* storage =
48.531 + new _writer_bits::MapStorage<Node, Map, Converter>(map, converter);
48.532 _node_maps.push_back(std::make_pair(caption, storage));
48.533 return *this;
48.534 }
48.535 @@ -518,8 +518,8 @@
48.536 template <typename Map>
48.537 DigraphWriter& arcMap(const std::string& caption, const Map& map) {
48.538 checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>();
48.539 - _writer_bits::MapStorageBase<Arc>* storage =
48.540 - new _writer_bits::MapStorage<Arc, Map>(map);
48.541 + _writer_bits::MapStorageBase<Arc>* storage =
48.542 + new _writer_bits::MapStorage<Arc, Map>(map);
48.543 _arc_maps.push_back(std::make_pair(caption, storage));
48.544 return *this;
48.545 }
48.546 @@ -529,11 +529,11 @@
48.547 /// Add an arc map writing rule with specialized converter to the
48.548 /// writer.
48.549 template <typename Map, typename Converter>
48.550 - DigraphWriter& arcMap(const std::string& caption, const Map& map,
48.551 - const Converter& converter = Converter()) {
48.552 + DigraphWriter& arcMap(const std::string& caption, const Map& map,
48.553 + const Converter& converter = Converter()) {
48.554 checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>();
48.555 - _writer_bits::MapStorageBase<Arc>* storage =
48.556 - new _writer_bits::MapStorage<Arc, Map, Converter>(map, converter);
48.557 + _writer_bits::MapStorageBase<Arc>* storage =
48.558 + new _writer_bits::MapStorage<Arc, Map, Converter>(map, converter);
48.559 _arc_maps.push_back(std::make_pair(caption, storage));
48.560 return *this;
48.561 }
48.562 @@ -543,8 +543,8 @@
48.563 /// Add an attribute writing rule to the writer.
48.564 template <typename Value>
48.565 DigraphWriter& attribute(const std::string& caption, const Value& value) {
48.566 - _writer_bits::ValueStorageBase* storage =
48.567 - new _writer_bits::ValueStorage<Value>(value);
48.568 + _writer_bits::ValueStorageBase* storage =
48.569 + new _writer_bits::ValueStorage<Value>(value);
48.570 _attributes.push_back(std::make_pair(caption, storage));
48.571 return *this;
48.572 }
48.573 @@ -554,10 +554,10 @@
48.574 /// Add an attribute writing rule with specialized converter to the
48.575 /// writer.
48.576 template <typename Value, typename Converter>
48.577 - DigraphWriter& attribute(const std::string& caption, const Value& value,
48.578 - const Converter& converter = Converter()) {
48.579 - _writer_bits::ValueStorageBase* storage =
48.580 - new _writer_bits::ValueStorage<Value, Converter>(value, converter);
48.581 + DigraphWriter& attribute(const std::string& caption, const Value& value,
48.582 + const Converter& converter = Converter()) {
48.583 + _writer_bits::ValueStorageBase* storage =
48.584 + new _writer_bits::ValueStorage<Value, Converter>(value, converter);
48.585 _attributes.push_back(std::make_pair(caption, storage));
48.586 return *this;
48.587 }
48.588 @@ -568,8 +568,8 @@
48.589 DigraphWriter& node(const std::string& caption, const Node& node) {
48.590 typedef _writer_bits::MapLookUpConverter<Node> Converter;
48.591 Converter converter(_node_index);
48.592 - _writer_bits::ValueStorageBase* storage =
48.593 - new _writer_bits::ValueStorage<Node, Converter>(node, converter);
48.594 + _writer_bits::ValueStorageBase* storage =
48.595 + new _writer_bits::ValueStorage<Node, Converter>(node, converter);
48.596 _attributes.push_back(std::make_pair(caption, storage));
48.597 return *this;
48.598 }
48.599 @@ -580,8 +580,8 @@
48.600 DigraphWriter& arc(const std::string& caption, const Arc& arc) {
48.601 typedef _writer_bits::MapLookUpConverter<Arc> Converter;
48.602 Converter converter(_arc_index);
48.603 - _writer_bits::ValueStorageBase* storage =
48.604 - new _writer_bits::ValueStorage<Arc, Converter>(arc, converter);
48.605 + _writer_bits::ValueStorageBase* storage =
48.606 + new _writer_bits::ValueStorage<Arc, Converter>(arc, converter);
48.607 _attributes.push_back(std::make_pair(caption, storage));
48.608 return *this;
48.609 }
48.610 @@ -641,175 +641,175 @@
48.611 void writeNodes() {
48.612 _writer_bits::MapStorageBase<Node>* label = 0;
48.613 for (typename NodeMaps::iterator it = _node_maps.begin();
48.614 - it != _node_maps.end(); ++it) {
48.615 + it != _node_maps.end(); ++it) {
48.616 if (it->first == "label") {
48.617 - label = it->second;
48.618 - break;
48.619 - }
48.620 + label = it->second;
48.621 + break;
48.622 + }
48.623 }
48.624
48.625 *_os << "@nodes";
48.626 if (!_nodes_caption.empty()) {
48.627 - _writer_bits::writeToken(*_os << ' ', _nodes_caption);
48.628 + _writer_bits::writeToken(*_os << ' ', _nodes_caption);
48.629 }
48.630 *_os << std::endl;
48.631
48.632 if (label == 0) {
48.633 - *_os << "label" << '\t';
48.634 + *_os << "label" << '\t';
48.635 }
48.636 for (typename NodeMaps::iterator it = _node_maps.begin();
48.637 - it != _node_maps.end(); ++it) {
48.638 - _writer_bits::writeToken(*_os, it->first) << '\t';
48.639 + it != _node_maps.end(); ++it) {
48.640 + _writer_bits::writeToken(*_os, it->first) << '\t';
48.641 }
48.642 *_os << std::endl;
48.643
48.644 std::vector<Node> nodes;
48.645 for (NodeIt n(_digraph); n != INVALID; ++n) {
48.646 - nodes.push_back(n);
48.647 + nodes.push_back(n);
48.648 }
48.649 -
48.650 +
48.651 if (label == 0) {
48.652 - IdMap<Digraph, Node> id_map(_digraph);
48.653 - _writer_bits::MapLess<IdMap<Digraph, Node> > id_less(id_map);
48.654 - std::sort(nodes.begin(), nodes.end(), id_less);
48.655 + IdMap<Digraph, Node> id_map(_digraph);
48.656 + _writer_bits::MapLess<IdMap<Digraph, Node> > id_less(id_map);
48.657 + std::sort(nodes.begin(), nodes.end(), id_less);
48.658 } else {
48.659 - label->sort(nodes);
48.660 + label->sort(nodes);
48.661 }
48.662
48.663 for (int i = 0; i < static_cast<int>(nodes.size()); ++i) {
48.664 - Node n = nodes[i];
48.665 - if (label == 0) {
48.666 - std::ostringstream os;
48.667 - os << _digraph.id(n);
48.668 - _writer_bits::writeToken(*_os, os.str());
48.669 - *_os << '\t';
48.670 - _node_index.insert(std::make_pair(n, os.str()));
48.671 - }
48.672 - for (typename NodeMaps::iterator it = _node_maps.begin();
48.673 - it != _node_maps.end(); ++it) {
48.674 - std::string value = it->second->get(n);
48.675 - _writer_bits::writeToken(*_os, value);
48.676 - if (it->first == "label") {
48.677 - _node_index.insert(std::make_pair(n, value));
48.678 - }
48.679 - *_os << '\t';
48.680 - }
48.681 - *_os << std::endl;
48.682 + Node n = nodes[i];
48.683 + if (label == 0) {
48.684 + std::ostringstream os;
48.685 + os << _digraph.id(n);
48.686 + _writer_bits::writeToken(*_os, os.str());
48.687 + *_os << '\t';
48.688 + _node_index.insert(std::make_pair(n, os.str()));
48.689 + }
48.690 + for (typename NodeMaps::iterator it = _node_maps.begin();
48.691 + it != _node_maps.end(); ++it) {
48.692 + std::string value = it->second->get(n);
48.693 + _writer_bits::writeToken(*_os, value);
48.694 + if (it->first == "label") {
48.695 + _node_index.insert(std::make_pair(n, value));
48.696 + }
48.697 + *_os << '\t';
48.698 + }
48.699 + *_os << std::endl;
48.700 }
48.701 }
48.702
48.703 void createNodeIndex() {
48.704 _writer_bits::MapStorageBase<Node>* label = 0;
48.705 for (typename NodeMaps::iterator it = _node_maps.begin();
48.706 - it != _node_maps.end(); ++it) {
48.707 + it != _node_maps.end(); ++it) {
48.708 if (it->first == "label") {
48.709 - label = it->second;
48.710 - break;
48.711 - }
48.712 + label = it->second;
48.713 + break;
48.714 + }
48.715 }
48.716
48.717 if (label == 0) {
48.718 - for (NodeIt n(_digraph); n != INVALID; ++n) {
48.719 - std::ostringstream os;
48.720 - os << _digraph.id(n);
48.721 - _node_index.insert(std::make_pair(n, os.str()));
48.722 - }
48.723 + for (NodeIt n(_digraph); n != INVALID; ++n) {
48.724 + std::ostringstream os;
48.725 + os << _digraph.id(n);
48.726 + _node_index.insert(std::make_pair(n, os.str()));
48.727 + }
48.728 } else {
48.729 - for (NodeIt n(_digraph); n != INVALID; ++n) {
48.730 - std::string value = label->get(n);
48.731 - _node_index.insert(std::make_pair(n, value));
48.732 - }
48.733 + for (NodeIt n(_digraph); n != INVALID; ++n) {
48.734 + std::string value = label->get(n);
48.735 + _node_index.insert(std::make_pair(n, value));
48.736 + }
48.737 }
48.738 }
48.739
48.740 void writeArcs() {
48.741 _writer_bits::MapStorageBase<Arc>* label = 0;
48.742 for (typename ArcMaps::iterator it = _arc_maps.begin();
48.743 - it != _arc_maps.end(); ++it) {
48.744 + it != _arc_maps.end(); ++it) {
48.745 if (it->first == "label") {
48.746 - label = it->second;
48.747 - break;
48.748 - }
48.749 + label = it->second;
48.750 + break;
48.751 + }
48.752 }
48.753
48.754 *_os << "@arcs";
48.755 if (!_arcs_caption.empty()) {
48.756 - _writer_bits::writeToken(*_os << ' ', _arcs_caption);
48.757 + _writer_bits::writeToken(*_os << ' ', _arcs_caption);
48.758 }
48.759 *_os << std::endl;
48.760
48.761 *_os << '\t' << '\t';
48.762 if (label == 0) {
48.763 - *_os << "label" << '\t';
48.764 + *_os << "label" << '\t';
48.765 }
48.766 for (typename ArcMaps::iterator it = _arc_maps.begin();
48.767 - it != _arc_maps.end(); ++it) {
48.768 - _writer_bits::writeToken(*_os, it->first) << '\t';
48.769 + it != _arc_maps.end(); ++it) {
48.770 + _writer_bits::writeToken(*_os, it->first) << '\t';
48.771 }
48.772 *_os << std::endl;
48.773
48.774 std::vector<Arc> arcs;
48.775 for (ArcIt n(_digraph); n != INVALID; ++n) {
48.776 - arcs.push_back(n);
48.777 + arcs.push_back(n);
48.778 }
48.779 -
48.780 +
48.781 if (label == 0) {
48.782 - IdMap<Digraph, Arc> id_map(_digraph);
48.783 - _writer_bits::MapLess<IdMap<Digraph, Arc> > id_less(id_map);
48.784 - std::sort(arcs.begin(), arcs.end(), id_less);
48.785 + IdMap<Digraph, Arc> id_map(_digraph);
48.786 + _writer_bits::MapLess<IdMap<Digraph, Arc> > id_less(id_map);
48.787 + std::sort(arcs.begin(), arcs.end(), id_less);
48.788 } else {
48.789 - label->sort(arcs);
48.790 + label->sort(arcs);
48.791 }
48.792
48.793 for (int i = 0; i < static_cast<int>(arcs.size()); ++i) {
48.794 - Arc a = arcs[i];
48.795 - _writer_bits::writeToken(*_os, _node_index.
48.796 - find(_digraph.source(a))->second);
48.797 - *_os << '\t';
48.798 - _writer_bits::writeToken(*_os, _node_index.
48.799 - find(_digraph.target(a))->second);
48.800 - *_os << '\t';
48.801 - if (label == 0) {
48.802 - std::ostringstream os;
48.803 - os << _digraph.id(a);
48.804 - _writer_bits::writeToken(*_os, os.str());
48.805 - *_os << '\t';
48.806 - _arc_index.insert(std::make_pair(a, os.str()));
48.807 - }
48.808 - for (typename ArcMaps::iterator it = _arc_maps.begin();
48.809 - it != _arc_maps.end(); ++it) {
48.810 - std::string value = it->second->get(a);
48.811 - _writer_bits::writeToken(*_os, value);
48.812 - if (it->first == "label") {
48.813 - _arc_index.insert(std::make_pair(a, value));
48.814 - }
48.815 - *_os << '\t';
48.816 - }
48.817 - *_os << std::endl;
48.818 + Arc a = arcs[i];
48.819 + _writer_bits::writeToken(*_os, _node_index.
48.820 + find(_digraph.source(a))->second);
48.821 + *_os << '\t';
48.822 + _writer_bits::writeToken(*_os, _node_index.
48.823 + find(_digraph.target(a))->second);
48.824 + *_os << '\t';
48.825 + if (label == 0) {
48.826 + std::ostringstream os;
48.827 + os << _digraph.id(a);
48.828 + _writer_bits::writeToken(*_os, os.str());
48.829 + *_os << '\t';
48.830 + _arc_index.insert(std::make_pair(a, os.str()));
48.831 + }
48.832 + for (typename ArcMaps::iterator it = _arc_maps.begin();
48.833 + it != _arc_maps.end(); ++it) {
48.834 + std::string value = it->second->get(a);
48.835 + _writer_bits::writeToken(*_os, value);
48.836 + if (it->first == "label") {
48.837 + _arc_index.insert(std::make_pair(a, value));
48.838 + }
48.839 + *_os << '\t';
48.840 + }
48.841 + *_os << std::endl;
48.842 }
48.843 }
48.844
48.845 void createArcIndex() {
48.846 _writer_bits::MapStorageBase<Arc>* label = 0;
48.847 for (typename ArcMaps::iterator it = _arc_maps.begin();
48.848 - it != _arc_maps.end(); ++it) {
48.849 + it != _arc_maps.end(); ++it) {
48.850 if (it->first == "label") {
48.851 - label = it->second;
48.852 - break;
48.853 - }
48.854 + label = it->second;
48.855 + break;
48.856 + }
48.857 }
48.858
48.859 if (label == 0) {
48.860 - for (ArcIt a(_digraph); a != INVALID; ++a) {
48.861 - std::ostringstream os;
48.862 - os << _digraph.id(a);
48.863 - _arc_index.insert(std::make_pair(a, os.str()));
48.864 - }
48.865 + for (ArcIt a(_digraph); a != INVALID; ++a) {
48.866 + std::ostringstream os;
48.867 + os << _digraph.id(a);
48.868 + _arc_index.insert(std::make_pair(a, os.str()));
48.869 + }
48.870 } else {
48.871 - for (ArcIt a(_digraph); a != INVALID; ++a) {
48.872 - std::string value = label->get(a);
48.873 - _arc_index.insert(std::make_pair(a, value));
48.874 - }
48.875 + for (ArcIt a(_digraph); a != INVALID; ++a) {
48.876 + std::string value = label->get(a);
48.877 + _arc_index.insert(std::make_pair(a, value));
48.878 + }
48.879 }
48.880 }
48.881
48.882 @@ -817,20 +817,20 @@
48.883 if (_attributes.empty()) return;
48.884 *_os << "@attributes";
48.885 if (!_attributes_caption.empty()) {
48.886 - _writer_bits::writeToken(*_os << ' ', _attributes_caption);
48.887 + _writer_bits::writeToken(*_os << ' ', _attributes_caption);
48.888 }
48.889 *_os << std::endl;
48.890 for (typename Attributes::iterator it = _attributes.begin();
48.891 - it != _attributes.end(); ++it) {
48.892 - _writer_bits::writeToken(*_os, it->first) << ' ';
48.893 - _writer_bits::writeToken(*_os, it->second->get());
48.894 - *_os << std::endl;
48.895 + it != _attributes.end(); ++it) {
48.896 + _writer_bits::writeToken(*_os, it->first) << ' ';
48.897 + _writer_bits::writeToken(*_os, it->second->get());
48.898 + *_os << std::endl;
48.899 }
48.900 }
48.901 -
48.902 +
48.903 public:
48.904 -
48.905 - /// \name Execution of the writer
48.906 +
48.907 + /// \name Execution of the writer
48.908 /// @{
48.909
48.910 /// \brief Start the batch processing
48.911 @@ -838,14 +838,14 @@
48.912 /// This function starts the batch processing.
48.913 void run() {
48.914 if (!_skip_nodes) {
48.915 - writeNodes();
48.916 + writeNodes();
48.917 } else {
48.918 - createNodeIndex();
48.919 + createNodeIndex();
48.920 }
48.921 - if (!_skip_arcs) {
48.922 - writeArcs();
48.923 + if (!_skip_arcs) {
48.924 + writeArcs();
48.925 } else {
48.926 - createArcIndex();
48.927 + createArcIndex();
48.928 }
48.929 writeAttributes();
48.930 }
48.931 @@ -861,34 +861,34 @@
48.932 };
48.933
48.934 /// \brief Return a \ref DigraphWriter class
48.935 - ///
48.936 + ///
48.937 /// This function just returns a \ref DigraphWriter class.
48.938 /// \relates DigraphWriter
48.939 template <typename Digraph>
48.940 - DigraphWriter<Digraph> digraphWriter(std::ostream& os,
48.941 - const Digraph& digraph) {
48.942 + DigraphWriter<Digraph> digraphWriter(std::ostream& os,
48.943 + const Digraph& digraph) {
48.944 DigraphWriter<Digraph> tmp(os, digraph);
48.945 return tmp;
48.946 }
48.947
48.948 /// \brief Return a \ref DigraphWriter class
48.949 - ///
48.950 + ///
48.951 /// This function just returns a \ref DigraphWriter class.
48.952 /// \relates DigraphWriter
48.953 template <typename Digraph>
48.954 - DigraphWriter<Digraph> digraphWriter(const std::string& fn,
48.955 - const Digraph& digraph) {
48.956 + DigraphWriter<Digraph> digraphWriter(const std::string& fn,
48.957 + const Digraph& digraph) {
48.958 DigraphWriter<Digraph> tmp(fn, digraph);
48.959 return tmp;
48.960 }
48.961
48.962 /// \brief Return a \ref DigraphWriter class
48.963 - ///
48.964 + ///
48.965 /// This function just returns a \ref DigraphWriter class.
48.966 /// \relates DigraphWriter
48.967 template <typename Digraph>
48.968 - DigraphWriter<Digraph> digraphWriter(const char* fn,
48.969 - const Digraph& digraph) {
48.970 + DigraphWriter<Digraph> digraphWriter(const char* fn,
48.971 + const Digraph& digraph) {
48.972 DigraphWriter<Digraph> tmp(fn, digraph);
48.973 return tmp;
48.974 }
48.975 @@ -897,16 +897,16 @@
48.976 class GraphWriter;
48.977
48.978 template <typename Graph>
48.979 - GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph);
48.980 + GraphWriter<Graph> graphWriter(std::ostream& os, const Graph& graph);
48.981
48.982 template <typename Graph>
48.983 - GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph);
48.984 + GraphWriter<Graph> graphWriter(const std::string& fn, const Graph& graph);
48.985
48.986 template <typename Graph>
48.987 - GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph);
48.988 + GraphWriter<Graph> graphWriter(const char *fn, const Graph& graph);
48.989
48.990 /// \ingroup lemon_io
48.991 - ///
48.992 + ///
48.993 /// \brief \ref lgf-format "LGF" writer for directed graphs
48.994 ///
48.995 /// This utility writes an \ref lgf-format "LGF" file.
48.996 @@ -926,7 +926,7 @@
48.997
48.998 typedef _Graph Graph;
48.999 TEMPLATE_GRAPH_TYPEDEFS(Graph);
48.1000 -
48.1001 +
48.1002 private:
48.1003
48.1004
48.1005 @@ -938,21 +938,21 @@
48.1006 std::string _nodes_caption;
48.1007 std::string _edges_caption;
48.1008 std::string _attributes_caption;
48.1009 -
48.1010 +
48.1011 typedef std::map<Node, std::string> NodeIndex;
48.1012 NodeIndex _node_index;
48.1013 typedef std::map<Edge, std::string> EdgeIndex;
48.1014 EdgeIndex _edge_index;
48.1015
48.1016 - typedef std::vector<std::pair<std::string,
48.1017 - _writer_bits::MapStorageBase<Node>* > > NodeMaps;
48.1018 - NodeMaps _node_maps;
48.1019 + typedef std::vector<std::pair<std::string,
48.1020 + _writer_bits::MapStorageBase<Node>* > > NodeMaps;
48.1021 + NodeMaps _node_maps;
48.1022
48.1023 - typedef std::vector<std::pair<std::string,
48.1024 + typedef std::vector<std::pair<std::string,
48.1025 _writer_bits::MapStorageBase<Edge>* > >EdgeMaps;
48.1026 EdgeMaps _edge_maps;
48.1027
48.1028 - typedef std::vector<std::pair<std::string,
48.1029 + typedef std::vector<std::pair<std::string,
48.1030 _writer_bits::ValueStorageBase*> > Attributes;
48.1031 Attributes _attributes;
48.1032
48.1033 @@ -965,60 +965,60 @@
48.1034 ///
48.1035 /// Construct a directed graph writer, which writes to the given
48.1036 /// output stream.
48.1037 - GraphWriter(std::ostream& is, const Graph& graph)
48.1038 + GraphWriter(std::ostream& is, const Graph& graph)
48.1039 : _os(&is), local_os(false), _graph(graph),
48.1040 - _skip_nodes(false), _skip_edges(false) {}
48.1041 + _skip_nodes(false), _skip_edges(false) {}
48.1042
48.1043 /// \brief Constructor
48.1044 ///
48.1045 /// Construct a directed graph writer, which writes to the given
48.1046 /// output file.
48.1047 - GraphWriter(const std::string& fn, const Graph& graph)
48.1048 + GraphWriter(const std::string& fn, const Graph& graph)
48.1049 : _os(new std::ofstream(fn.c_str())), local_os(true), _graph(graph),
48.1050 - _skip_nodes(false), _skip_edges(false) {}
48.1051 + _skip_nodes(false), _skip_edges(false) {}
48.1052
48.1053 /// \brief Constructor
48.1054 ///
48.1055 /// Construct a directed graph writer, which writes to the given
48.1056 /// output file.
48.1057 - GraphWriter(const char* fn, const Graph& graph)
48.1058 + GraphWriter(const char* fn, const Graph& graph)
48.1059 : _os(new std::ofstream(fn)), local_os(true), _graph(graph),
48.1060 - _skip_nodes(false), _skip_edges(false) {}
48.1061 + _skip_nodes(false), _skip_edges(false) {}
48.1062
48.1063 /// \brief Destructor
48.1064 ~GraphWriter() {
48.1065 - for (typename NodeMaps::iterator it = _node_maps.begin();
48.1066 - it != _node_maps.end(); ++it) {
48.1067 - delete it->second;
48.1068 + for (typename NodeMaps::iterator it = _node_maps.begin();
48.1069 + it != _node_maps.end(); ++it) {
48.1070 + delete it->second;
48.1071 }
48.1072
48.1073 - for (typename EdgeMaps::iterator it = _edge_maps.begin();
48.1074 - it != _edge_maps.end(); ++it) {
48.1075 - delete it->second;
48.1076 + for (typename EdgeMaps::iterator it = _edge_maps.begin();
48.1077 + it != _edge_maps.end(); ++it) {
48.1078 + delete it->second;
48.1079 }
48.1080
48.1081 - for (typename Attributes::iterator it = _attributes.begin();
48.1082 - it != _attributes.end(); ++it) {
48.1083 - delete it->second;
48.1084 + for (typename Attributes::iterator it = _attributes.begin();
48.1085 + it != _attributes.end(); ++it) {
48.1086 + delete it->second;
48.1087 }
48.1088
48.1089 if (local_os) {
48.1090 - delete _os;
48.1091 + delete _os;
48.1092 }
48.1093 }
48.1094 -
48.1095 +
48.1096 private:
48.1097
48.1098 - friend GraphWriter<Graph> graphWriter<>(std::ostream& os,
48.1099 - const Graph& graph);
48.1100 - friend GraphWriter<Graph> graphWriter<>(const std::string& fn,
48.1101 - const Graph& graph);
48.1102 - friend GraphWriter<Graph> graphWriter<>(const char *fn,
48.1103 - const Graph& graph);
48.1104 + friend GraphWriter<Graph> graphWriter<>(std::ostream& os,
48.1105 + const Graph& graph);
48.1106 + friend GraphWriter<Graph> graphWriter<>(const std::string& fn,
48.1107 + const Graph& graph);
48.1108 + friend GraphWriter<Graph> graphWriter<>(const char *fn,
48.1109 + const Graph& graph);
48.1110
48.1111 - GraphWriter(GraphWriter& other)
48.1112 + GraphWriter(GraphWriter& other)
48.1113 : _os(other._os), local_os(other.local_os), _graph(other._graph),
48.1114 - _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
48.1115 + _skip_nodes(other._skip_nodes), _skip_edges(other._skip_edges) {
48.1116
48.1117 other._os = 0;
48.1118 other.local_os = false;
48.1119 @@ -1041,15 +1041,15 @@
48.1120
48.1121 /// \name Writing rules
48.1122 /// @{
48.1123 -
48.1124 +
48.1125 /// \brief Node map writing rule
48.1126 ///
48.1127 /// Add a node map writing rule to the writer.
48.1128 template <typename Map>
48.1129 GraphWriter& nodeMap(const std::string& caption, const Map& map) {
48.1130 checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
48.1131 - _writer_bits::MapStorageBase<Node>* storage =
48.1132 - new _writer_bits::MapStorage<Node, Map>(map);
48.1133 + _writer_bits::MapStorageBase<Node>* storage =
48.1134 + new _writer_bits::MapStorage<Node, Map>(map);
48.1135 _node_maps.push_back(std::make_pair(caption, storage));
48.1136 return *this;
48.1137 }
48.1138 @@ -1059,11 +1059,11 @@
48.1139 /// Add a node map writing rule with specialized converter to the
48.1140 /// writer.
48.1141 template <typename Map, typename Converter>
48.1142 - GraphWriter& nodeMap(const std::string& caption, const Map& map,
48.1143 - const Converter& converter = Converter()) {
48.1144 + GraphWriter& nodeMap(const std::string& caption, const Map& map,
48.1145 + const Converter& converter = Converter()) {
48.1146 checkConcept<concepts::ReadMap<Node, typename Map::Value>, Map>();
48.1147 - _writer_bits::MapStorageBase<Node>* storage =
48.1148 - new _writer_bits::MapStorage<Node, Map, Converter>(map, converter);
48.1149 + _writer_bits::MapStorageBase<Node>* storage =
48.1150 + new _writer_bits::MapStorage<Node, Map, Converter>(map, converter);
48.1151 _node_maps.push_back(std::make_pair(caption, storage));
48.1152 return *this;
48.1153 }
48.1154 @@ -1074,8 +1074,8 @@
48.1155 template <typename Map>
48.1156 GraphWriter& edgeMap(const std::string& caption, const Map& map) {
48.1157 checkConcept<concepts::ReadMap<Edge, typename Map::Value>, Map>();
48.1158 - _writer_bits::MapStorageBase<Edge>* storage =
48.1159 - new _writer_bits::MapStorage<Edge, Map>(map);
48.1160 + _writer_bits::MapStorageBase<Edge>* storage =
48.1161 + new _writer_bits::MapStorage<Edge, Map>(map);
48.1162 _edge_maps.push_back(std::make_pair(caption, storage));
48.1163 return *this;
48.1164 }
48.1165 @@ -1085,11 +1085,11 @@
48.1166 /// Add an edge map writing rule with specialized converter to the
48.1167 /// writer.
48.1168 template <typename Map, typename Converter>
48.1169 - GraphWriter& edgeMap(const std::string& caption, const Map& map,
48.1170 - const Converter& converter = Converter()) {
48.1171 + GraphWriter& edgeMap(const std::string& caption, const Map& map,
48.1172 + const Converter& converter = Converter()) {
48.1173 checkConcept<concepts::ReadMap<Edge, typename Map::Value>, Map>();
48.1174 - _writer_bits::MapStorageBase<Edge>* storage =
48.1175 - new _writer_bits::MapStorage<Edge, Map, Converter>(map, converter);
48.1176 + _writer_bits::MapStorageBase<Edge>* storage =
48.1177 + new _writer_bits::MapStorage<Edge, Map, Converter>(map, converter);
48.1178 _edge_maps.push_back(std::make_pair(caption, storage));
48.1179 return *this;
48.1180 }
48.1181 @@ -1100,11 +1100,11 @@
48.1182 template <typename Map>
48.1183 GraphWriter& arcMap(const std::string& caption, const Map& map) {
48.1184 checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>();
48.1185 - _writer_bits::MapStorageBase<Edge>* forward_storage =
48.1186 - new _writer_bits::GraphArcMapStorage<Graph, true, Map>(_graph, map);
48.1187 + _writer_bits::MapStorageBase<Edge>* forward_storage =
48.1188 + new _writer_bits::GraphArcMapStorage<Graph, true, Map>(_graph, map);
48.1189 _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
48.1190 - _writer_bits::MapStorageBase<Edge>* backward_storage =
48.1191 - new _writer_bits::GraphArcMapStorage<Graph, false, Map>(_graph, map);
48.1192 + _writer_bits::MapStorageBase<Edge>* backward_storage =
48.1193 + new _writer_bits::GraphArcMapStorage<Graph, false, Map>(_graph, map);
48.1194 _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
48.1195 return *this;
48.1196 }
48.1197 @@ -1114,16 +1114,16 @@
48.1198 /// Add an arc map writing rule with specialized converter to the
48.1199 /// writer.
48.1200 template <typename Map, typename Converter>
48.1201 - GraphWriter& arcMap(const std::string& caption, const Map& map,
48.1202 - const Converter& converter = Converter()) {
48.1203 + GraphWriter& arcMap(const std::string& caption, const Map& map,
48.1204 + const Converter& converter = Converter()) {
48.1205 checkConcept<concepts::ReadMap<Arc, typename Map::Value>, Map>();
48.1206 - _writer_bits::MapStorageBase<Edge>* forward_storage =
48.1207 - new _writer_bits::GraphArcMapStorage<Graph, true, Map, Converter>
48.1208 - (_graph, map, converter);
48.1209 + _writer_bits::MapStorageBase<Edge>* forward_storage =
48.1210 + new _writer_bits::GraphArcMapStorage<Graph, true, Map, Converter>
48.1211 + (_graph, map, converter);
48.1212 _edge_maps.push_back(std::make_pair('+' + caption, forward_storage));
48.1213 - _writer_bits::MapStorageBase<Edge>* backward_storage =
48.1214 - new _writer_bits::GraphArcMapStorage<Graph, false, Map, Converter>
48.1215 - (_graph, map, converter);
48.1216 + _writer_bits::MapStorageBase<Edge>* backward_storage =
48.1217 + new _writer_bits::GraphArcMapStorage<Graph, false, Map, Converter>
48.1218 + (_graph, map, converter);
48.1219 _edge_maps.push_back(std::make_pair('-' + caption, backward_storage));
48.1220 return *this;
48.1221 }
48.1222 @@ -1133,8 +1133,8 @@
48.1223 /// Add an attribute writing rule to the writer.
48.1224 template <typename Value>
48.1225 GraphWriter& attribute(const std::string& caption, const Value& value) {
48.1226 - _writer_bits::ValueStorageBase* storage =
48.1227 - new _writer_bits::ValueStorage<Value>(value);
48.1228 + _writer_bits::ValueStorageBase* storage =
48.1229 + new _writer_bits::ValueStorage<Value>(value);
48.1230 _attributes.push_back(std::make_pair(caption, storage));
48.1231 return *this;
48.1232 }
48.1233 @@ -1144,10 +1144,10 @@
48.1234 /// Add an attribute writing rule with specialized converter to the
48.1235 /// writer.
48.1236 template <typename Value, typename Converter>
48.1237 - GraphWriter& attribute(const std::string& caption, const Value& value,
48.1238 - const Converter& converter = Converter()) {
48.1239 - _writer_bits::ValueStorageBase* storage =
48.1240 - new _writer_bits::ValueStorage<Value, Converter>(value, converter);
48.1241 + GraphWriter& attribute(const std::string& caption, const Value& value,
48.1242 + const Converter& converter = Converter()) {
48.1243 + _writer_bits::ValueStorageBase* storage =
48.1244 + new _writer_bits::ValueStorage<Value, Converter>(value, converter);
48.1245 _attributes.push_back(std::make_pair(caption, storage));
48.1246 return *this;
48.1247 }
48.1248 @@ -1158,8 +1158,8 @@
48.1249 GraphWriter& node(const std::string& caption, const Node& node) {
48.1250 typedef _writer_bits::MapLookUpConverter<Node> Converter;
48.1251 Converter converter(_node_index);
48.1252 - _writer_bits::ValueStorageBase* storage =
48.1253 - new _writer_bits::ValueStorage<Node, Converter>(node, converter);
48.1254 + _writer_bits::ValueStorageBase* storage =
48.1255 + new _writer_bits::ValueStorage<Node, Converter>(node, converter);
48.1256 _attributes.push_back(std::make_pair(caption, storage));
48.1257 return *this;
48.1258 }
48.1259 @@ -1170,8 +1170,8 @@
48.1260 GraphWriter& edge(const std::string& caption, const Edge& edge) {
48.1261 typedef _writer_bits::MapLookUpConverter<Edge> Converter;
48.1262 Converter converter(_edge_index);
48.1263 - _writer_bits::ValueStorageBase* storage =
48.1264 - new _writer_bits::ValueStorage<Edge, Converter>(edge, converter);
48.1265 + _writer_bits::ValueStorageBase* storage =
48.1266 + new _writer_bits::ValueStorage<Edge, Converter>(edge, converter);
48.1267 _attributes.push_back(std::make_pair(caption, storage));
48.1268 return *this;
48.1269 }
48.1270 @@ -1182,8 +1182,8 @@
48.1271 GraphWriter& arc(const std::string& caption, const Arc& arc) {
48.1272 typedef _writer_bits::GraphArcLookUpConverter<Graph> Converter;
48.1273 Converter converter(_graph, _edge_index);
48.1274 - _writer_bits::ValueStorageBase* storage =
48.1275 - new _writer_bits::ValueStorage<Arc, Converter>(arc, converter);
48.1276 + _writer_bits::ValueStorageBase* storage =
48.1277 + new _writer_bits::ValueStorage<Arc, Converter>(arc, converter);
48.1278 _attributes.push_back(std::make_pair(caption, storage));
48.1279 return *this;
48.1280 }
48.1281 @@ -1243,175 +1243,175 @@
48.1282 void writeNodes() {
48.1283 _writer_bits::MapStorageBase<Node>* label = 0;
48.1284 for (typename NodeMaps::iterator it = _node_maps.begin();
48.1285 - it != _node_maps.end(); ++it) {
48.1286 + it != _node_maps.end(); ++it) {
48.1287 if (it->first == "label") {
48.1288 - label = it->second;
48.1289 - break;
48.1290 - }
48.1291 + label = it->second;
48.1292 + break;
48.1293 + }
48.1294 }
48.1295
48.1296 *_os << "@nodes";
48.1297 if (!_nodes_caption.empty()) {
48.1298 - _writer_bits::writeToken(*_os << ' ', _nodes_caption);
48.1299 + _writer_bits::writeToken(*_os << ' ', _nodes_caption);
48.1300 }
48.1301 *_os << std::endl;
48.1302
48.1303 if (label == 0) {
48.1304 - *_os << "label" << '\t';
48.1305 + *_os << "label" << '\t';
48.1306 }
48.1307 for (typename NodeMaps::iterator it = _node_maps.begin();
48.1308 - it != _node_maps.end(); ++it) {
48.1309 - _writer_bits::writeToken(*_os, it->first) << '\t';
48.1310 + it != _node_maps.end(); ++it) {
48.1311 + _writer_bits::writeToken(*_os, it->first) << '\t';
48.1312 }
48.1313 *_os << std::endl;
48.1314
48.1315 std::vector<Node> nodes;
48.1316 for (NodeIt n(_graph); n != INVALID; ++n) {
48.1317 - nodes.push_back(n);
48.1318 + nodes.push_back(n);
48.1319 }
48.1320 -
48.1321 +
48.1322 if (label == 0) {
48.1323 - IdMap<Graph, Node> id_map(_graph);
48.1324 - _writer_bits::MapLess<IdMap<Graph, Node> > id_less(id_map);
48.1325 - std::sort(nodes.begin(), nodes.end(), id_less);
48.1326 + IdMap<Graph, Node> id_map(_graph);
48.1327 + _writer_bits::MapLess<IdMap<Graph, Node> > id_less(id_map);
48.1328 + std::sort(nodes.begin(), nodes.end(), id_less);
48.1329 } else {
48.1330 - label->sort(nodes);
48.1331 + label->sort(nodes);
48.1332 }
48.1333
48.1334 for (int i = 0; i < static_cast<int>(nodes.size()); ++i) {
48.1335 - Node n = nodes[i];
48.1336 - if (label == 0) {
48.1337 - std::ostringstream os;
48.1338 - os << _graph.id(n);
48.1339 - _writer_bits::writeToken(*_os, os.str());
48.1340 - *_os << '\t';
48.1341 - _node_index.insert(std::make_pair(n, os.str()));
48.1342 - }
48.1343 - for (typename NodeMaps::iterator it = _node_maps.begin();
48.1344 - it != _node_maps.end(); ++it) {
48.1345 - std::string value = it->second->get(n);
48.1346 - _writer_bits::writeToken(*_os, value);
48.1347 - if (it->first == "label") {
48.1348 - _node_index.insert(std::make_pair(n, value));
48.1349 - }
48.1350 - *_os << '\t';
48.1351 - }
48.1352 - *_os << std::endl;
48.1353 + Node n = nodes[i];
48.1354 + if (label == 0) {
48.1355 + std::ostringstream os;
48.1356 + os << _graph.id(n);
48.1357 + _writer_bits::writeToken(*_os, os.str());
48.1358 + *_os << '\t';
48.1359 + _node_index.insert(std::make_pair(n, os.str()));
48.1360 + }
48.1361 + for (typename NodeMaps::iterator it = _node_maps.begin();
48.1362 + it != _node_maps.end(); ++it) {
48.1363 + std::string value = it->second->get(n);
48.1364 + _writer_bits::writeToken(*_os, value);
48.1365 + if (it->first == "label") {
48.1366 + _node_index.insert(std::make_pair(n, value));
48.1367 + }
48.1368 + *_os << '\t';
48.1369 + }
48.1370 + *_os << std::endl;
48.1371 }
48.1372 }
48.1373
48.1374 void createNodeIndex() {
48.1375 _writer_bits::MapStorageBase<Node>* label = 0;
48.1376 for (typename NodeMaps::iterator it = _node_maps.begin();
48.1377 - it != _node_maps.end(); ++it) {
48.1378 + it != _node_maps.end(); ++it) {
48.1379 if (it->first == "label") {
48.1380 - label = it->second;
48.1381 - break;
48.1382 - }
48.1383 + label = it->second;
48.1384 + break;
48.1385 + }
48.1386 }
48.1387
48.1388 if (label == 0) {
48.1389 - for (NodeIt n(_graph); n != INVALID; ++n) {
48.1390 - std::ostringstream os;
48.1391 - os << _graph.id(n);
48.1392 - _node_index.insert(std::make_pair(n, os.str()));
48.1393 - }
48.1394 + for (NodeIt n(_graph); n != INVALID; ++n) {
48.1395 + std::ostringstream os;
48.1396 + os << _graph.id(n);
48.1397 + _node_index.insert(std::make_pair(n, os.str()));
48.1398 + }
48.1399 } else {
48.1400 - for (NodeIt n(_graph); n != INVALID; ++n) {
48.1401 - std::string value = label->get(n);
48.1402 - _node_index.insert(std::make_pair(n, value));
48.1403 - }
48.1404 + for (NodeIt n(_graph); n != INVALID; ++n) {
48.1405 + std::string value = label->get(n);
48.1406 + _node_index.insert(std::make_pair(n, value));
48.1407 + }
48.1408 }
48.1409 }
48.1410
48.1411 void writeEdges() {
48.1412 _writer_bits::MapStorageBase<Edge>* label = 0;
48.1413 for (typename EdgeMaps::iterator it = _edge_maps.begin();
48.1414 - it != _edge_maps.end(); ++it) {
48.1415 + it != _edge_maps.end(); ++it) {
48.1416 if (it->first == "label") {
48.1417 - label = it->second;
48.1418 - break;
48.1419 - }
48.1420 + label = it->second;
48.1421 + break;
48.1422 + }
48.1423 }
48.1424
48.1425 *_os << "@edges";
48.1426 if (!_edges_caption.empty()) {
48.1427 - _writer_bits::writeToken(*_os << ' ', _edges_caption);
48.1428 + _writer_bits::writeToken(*_os << ' ', _edges_caption);
48.1429 }
48.1430 *_os << std::endl;
48.1431
48.1432 *_os << '\t' << '\t';
48.1433 if (label == 0) {
48.1434 - *_os << "label" << '\t';
48.1435 + *_os << "label" << '\t';
48.1436 }
48.1437 for (typename EdgeMaps::iterator it = _edge_maps.begin();
48.1438 - it != _edge_maps.end(); ++it) {
48.1439 - _writer_bits::writeToken(*_os, it->first) << '\t';
48.1440 + it != _edge_maps.end(); ++it) {
48.1441 + _writer_bits::writeToken(*_os, it->first) << '\t';
48.1442 }
48.1443 *_os << std::endl;
48.1444
48.1445 std::vector<Edge> edges;
48.1446 for (EdgeIt n(_graph); n != INVALID; ++n) {
48.1447 - edges.push_back(n);
48.1448 + edges.push_back(n);
48.1449 }
48.1450 -
48.1451 +
48.1452 if (label == 0) {
48.1453 - IdMap<Graph, Edge> id_map(_graph);
48.1454 - _writer_bits::MapLess<IdMap<Graph, Edge> > id_less(id_map);
48.1455 - std::sort(edges.begin(), edges.end(), id_less);
48.1456 + IdMap<Graph, Edge> id_map(_graph);
48.1457 + _writer_bits::MapLess<IdMap<Graph, Edge> > id_less(id_map);
48.1458 + std::sort(edges.begin(), edges.end(), id_less);
48.1459 } else {
48.1460 - label->sort(edges);
48.1461 + label->sort(edges);
48.1462 }
48.1463
48.1464 for (int i = 0; i < static_cast<int>(edges.size()); ++i) {
48.1465 - Edge e = edges[i];
48.1466 - _writer_bits::writeToken(*_os, _node_index.
48.1467 - find(_graph.u(e))->second);
48.1468 - *_os << '\t';
48.1469 - _writer_bits::writeToken(*_os, _node_index.
48.1470 - find(_graph.v(e))->second);
48.1471 - *_os << '\t';
48.1472 - if (label == 0) {
48.1473 - std::ostringstream os;
48.1474 - os << _graph.id(e);
48.1475 - _writer_bits::writeToken(*_os, os.str());
48.1476 - *_os << '\t';
48.1477 - _edge_index.insert(std::make_pair(e, os.str()));
48.1478 - }
48.1479 - for (typename EdgeMaps::iterator it = _edge_maps.begin();
48.1480 - it != _edge_maps.end(); ++it) {
48.1481 - std::string value = it->second->get(e);
48.1482 - _writer_bits::writeToken(*_os, value);
48.1483 - if (it->first == "label") {
48.1484 - _edge_index.insert(std::make_pair(e, value));
48.1485 - }
48.1486 - *_os << '\t';
48.1487 - }
48.1488 - *_os << std::endl;
48.1489 + Edge e = edges[i];
48.1490 + _writer_bits::writeToken(*_os, _node_index.
48.1491 + find(_graph.u(e))->second);
48.1492 + *_os << '\t';
48.1493 + _writer_bits::writeToken(*_os, _node_index.
48.1494 + find(_graph.v(e))->second);
48.1495 + *_os << '\t';
48.1496 + if (label == 0) {
48.1497 + std::ostringstream os;
48.1498 + os << _graph.id(e);
48.1499 + _writer_bits::writeToken(*_os, os.str());
48.1500 + *_os << '\t';
48.1501 + _edge_index.insert(std::make_pair(e, os.str()));
48.1502 + }
48.1503 + for (typename EdgeMaps::iterator it = _edge_maps.begin();
48.1504 + it != _edge_maps.end(); ++it) {
48.1505 + std::string value = it->second->get(e);
48.1506 + _writer_bits::writeToken(*_os, value);
48.1507 + if (it->first == "label") {
48.1508 + _edge_index.insert(std::make_pair(e, value));
48.1509 + }
48.1510 + *_os << '\t';
48.1511 + }
48.1512 + *_os << std::endl;
48.1513 }
48.1514 }
48.1515
48.1516 void createEdgeIndex() {
48.1517 _writer_bits::MapStorageBase<Edge>* label = 0;
48.1518 for (typename EdgeMaps::iterator it = _edge_maps.begin();
48.1519 - it != _edge_maps.end(); ++it) {
48.1520 + it != _edge_maps.end(); ++it) {
48.1521 if (it->first == "label") {
48.1522 - label = it->second;
48.1523 - break;
48.1524 - }
48.1525 + label = it->second;
48.1526 + break;
48.1527 + }
48.1528 }
48.1529
48.1530 if (label == 0) {
48.1531 - for (EdgeIt e(_graph); e != INVALID; ++e) {
48.1532 - std::ostringstream os;
48.1533 - os << _graph.id(e);
48.1534 - _edge_index.insert(std::make_pair(e, os.str()));
48.1535 - }
48.1536 + for (EdgeIt e(_graph); e != INVALID; ++e) {
48.1537 + std::ostringstream os;
48.1538 + os << _graph.id(e);
48.1539 + _edge_index.insert(std::make_pair(e, os.str()));
48.1540 + }
48.1541 } else {
48.1542 - for (EdgeIt e(_graph); e != INVALID; ++e) {
48.1543 - std::string value = label->get(e);
48.1544 - _edge_index.insert(std::make_pair(e, value));
48.1545 - }
48.1546 + for (EdgeIt e(_graph); e != INVALID; ++e) {
48.1547 + std::string value = label->get(e);
48.1548 + _edge_index.insert(std::make_pair(e, value));
48.1549 + }
48.1550 }
48.1551 }
48.1552
48.1553 @@ -1419,20 +1419,20 @@
48.1554 if (_attributes.empty()) return;
48.1555 *_os << "@attributes";
48.1556 if (!_attributes_caption.empty()) {
48.1557 - _writer_bits::writeToken(*_os << ' ', _attributes_caption);
48.1558 + _writer_bits::writeToken(*_os << ' ', _attributes_caption);
48.1559 }
48.1560 *_os << std::endl;
48.1561 for (typename Attributes::iterator it = _attributes.begin();
48.1562 - it != _attributes.end(); ++it) {
48.1563 - _writer_bits::writeToken(*_os, it->first) << ' ';
48.1564 - _writer_bits::writeToken(*_os, it->second->get());
48.1565 - *_os << std::endl;
48.1566 + it != _attributes.end(); ++it) {
48.1567 + _writer_bits::writeToken(*_os, it->first) << ' ';
48.1568 + _writer_bits::writeToken(*_os, it->second->get());
48.1569 + *_os << std::endl;
48.1570 }
48.1571 }
48.1572 -
48.1573 +
48.1574 public:
48.1575 -
48.1576 - /// \name Execution of the writer
48.1577 +
48.1578 + /// \name Execution of the writer
48.1579 /// @{
48.1580
48.1581 /// \brief Start the batch processing
48.1582 @@ -1440,14 +1440,14 @@
48.1583 /// This function starts the batch processing.
48.1584 void run() {
48.1585 if (!_skip_nodes) {
48.1586 - writeNodes();
48.1587 + writeNodes();
48.1588 } else {
48.1589 - createNodeIndex();
48.1590 + createNodeIndex();
48.1591 }
48.1592 - if (!_skip_edges) {
48.1593 - writeEdges();
48.1594 + if (!_skip_edges) {
48.1595 + writeEdges();
48.1596 } else {
48.1597 - createEdgeIndex();
48.1598 + createEdgeIndex();
48.1599 }
48.1600 writeAttributes();
48.1601 }
48.1602 @@ -1463,7 +1463,7 @@
48.1603 };
48.1604
48.1605 /// \brief Return a \ref GraphWriter class
48.1606 - ///
48.1607 + ///
48.1608 /// This function just returns a \ref GraphWriter class.
48.1609 /// \relates GraphWriter
48.1610 template <typename Graph>
48.1611 @@ -1473,7 +1473,7 @@
48.1612 }
48.1613
48.1614 /// \brief Return a \ref GraphWriter class
48.1615 - ///
48.1616 + ///
48.1617 /// This function just returns a \ref GraphWriter class.
48.1618 /// \relates GraphWriter
48.1619 template <typename Graph>
48.1620 @@ -1483,7 +1483,7 @@
48.1621 }
48.1622
48.1623 /// \brief Return a \ref GraphWriter class
48.1624 - ///
48.1625 + ///
48.1626 /// This function just returns a \ref GraphWriter class.
48.1627 /// \relates GraphWriter
48.1628 template <typename Graph>
49.1 --- a/lemon/list_graph.h Sun Jul 13 16:46:56 2008 +0100
49.2 +++ b/lemon/list_graph.h Sun Jul 13 19:51:02 2008 +0100
49.3 @@ -1,6 +1,6 @@
49.4 -/* -*- C++ -*-
49.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
49.6 *
49.7 - * This file is a part of LEMON, a generic C++ optimization library
49.8 + * This file is a part of LEMON, a generic C++ optimization library.
49.9 *
49.10 * Copyright (C) 2003-2008
49.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
49.12 @@ -37,7 +37,7 @@
49.13 int first_in, first_out;
49.14 int prev, next;
49.15 };
49.16 -
49.17 +
49.18 struct ArcT {
49.19 int target, source;
49.20 int prev_in, prev_out;
49.21 @@ -53,11 +53,11 @@
49.22 std::vector<ArcT> arcs;
49.23
49.24 int first_free_arc;
49.25 -
49.26 +
49.27 public:
49.28 -
49.29 +
49.30 typedef ListDigraphBase Digraph;
49.31 -
49.32 +
49.33 class Node {
49.34 friend class ListDigraphBase;
49.35 protected:
49.36 @@ -92,17 +92,17 @@
49.37
49.38 ListDigraphBase()
49.39 : nodes(), first_node(-1),
49.40 - first_free_node(-1), arcs(), first_free_arc(-1) {}
49.41 + first_free_node(-1), arcs(), first_free_arc(-1) {}
49.42
49.43 -
49.44 - int maxNodeId() const { return nodes.size()-1; }
49.45 +
49.46 + int maxNodeId() const { return nodes.size()-1; }
49.47 int maxArcId() const { return arcs.size()-1; }
49.48
49.49 Node source(Arc e) const { return Node(arcs[e.id].source); }
49.50 Node target(Arc e) const { return Node(arcs[e.id].target); }
49.51
49.52
49.53 - void first(Node& node) const {
49.54 + void first(Node& node) const {
49.55 node.id = first_node;
49.56 }
49.57
49.58 @@ -111,24 +111,24 @@
49.59 }
49.60
49.61
49.62 - void first(Arc& arc) const {
49.63 + void first(Arc& arc) const {
49.64 int n;
49.65 - for(n = first_node;
49.66 - n!=-1 && nodes[n].first_in == -1;
49.67 - n = nodes[n].next) {}
49.68 + for(n = first_node;
49.69 + n!=-1 && nodes[n].first_in == -1;
49.70 + n = nodes[n].next) {}
49.71 arc.id = (n == -1) ? -1 : nodes[n].first_in;
49.72 }
49.73
49.74 void next(Arc& arc) const {
49.75 if (arcs[arc.id].next_in != -1) {
49.76 - arc.id = arcs[arc.id].next_in;
49.77 + arc.id = arcs[arc.id].next_in;
49.78 } else {
49.79 - int n;
49.80 - for(n = nodes[arcs[arc.id].target].next;
49.81 - n!=-1 && nodes[n].first_in == -1;
49.82 - n = nodes[n].next) {}
49.83 - arc.id = (n == -1) ? -1 : nodes[n].first_in;
49.84 - }
49.85 + int n;
49.86 + for(n = nodes[arcs[arc.id].target].next;
49.87 + n!=-1 && nodes[n].first_in == -1;
49.88 + n = nodes[n].next) {}
49.89 + arc.id = (n == -1) ? -1 : nodes[n].first_in;
49.90 + }
49.91 }
49.92
49.93 void firstOut(Arc &e, const Node& v) const {
49.94 @@ -145,118 +145,118 @@
49.95 e.id=arcs[e.id].next_in;
49.96 }
49.97
49.98 -
49.99 +
49.100 static int id(Node v) { return v.id; }
49.101 static int id(Arc e) { return e.id; }
49.102
49.103 static Node nodeFromId(int id) { return Node(id);}
49.104 static Arc arcFromId(int id) { return Arc(id);}
49.105
49.106 - bool valid(Node n) const {
49.107 - return n.id >= 0 && n.id < static_cast<int>(nodes.size()) &&
49.108 - nodes[n.id].prev != -2;
49.109 + bool valid(Node n) const {
49.110 + return n.id >= 0 && n.id < static_cast<int>(nodes.size()) &&
49.111 + nodes[n.id].prev != -2;
49.112 }
49.113
49.114 - bool valid(Arc a) const {
49.115 - return a.id >= 0 && a.id < static_cast<int>(arcs.size()) &&
49.116 - arcs[a.id].prev_in != -2;
49.117 + bool valid(Arc a) const {
49.118 + return a.id >= 0 && a.id < static_cast<int>(arcs.size()) &&
49.119 + arcs[a.id].prev_in != -2;
49.120 }
49.121
49.122 - Node addNode() {
49.123 + Node addNode() {
49.124 int n;
49.125 -
49.126 +
49.127 if(first_free_node==-1) {
49.128 - n = nodes.size();
49.129 - nodes.push_back(NodeT());
49.130 + n = nodes.size();
49.131 + nodes.push_back(NodeT());
49.132 } else {
49.133 - n = first_free_node;
49.134 - first_free_node = nodes[n].next;
49.135 + n = first_free_node;
49.136 + first_free_node = nodes[n].next;
49.137 }
49.138 -
49.139 +
49.140 nodes[n].next = first_node;
49.141 if(first_node != -1) nodes[first_node].prev = n;
49.142 first_node = n;
49.143 nodes[n].prev = -1;
49.144 -
49.145 +
49.146 nodes[n].first_in = nodes[n].first_out = -1;
49.147 -
49.148 +
49.149 return Node(n);
49.150 }
49.151 -
49.152 +
49.153 Arc addArc(Node u, Node v) {
49.154 - int n;
49.155 + int n;
49.156
49.157 if (first_free_arc == -1) {
49.158 - n = arcs.size();
49.159 - arcs.push_back(ArcT());
49.160 + n = arcs.size();
49.161 + arcs.push_back(ArcT());
49.162 } else {
49.163 - n = first_free_arc;
49.164 - first_free_arc = arcs[n].next_in;
49.165 + n = first_free_arc;
49.166 + first_free_arc = arcs[n].next_in;
49.167 }
49.168 -
49.169 - arcs[n].source = u.id;
49.170 +
49.171 + arcs[n].source = u.id;
49.172 arcs[n].target = v.id;
49.173
49.174 arcs[n].next_out = nodes[u.id].first_out;
49.175 if(nodes[u.id].first_out != -1) {
49.176 - arcs[nodes[u.id].first_out].prev_out = n;
49.177 + arcs[nodes[u.id].first_out].prev_out = n;
49.178 }
49.179 -
49.180 +
49.181 arcs[n].next_in = nodes[v.id].first_in;
49.182 if(nodes[v.id].first_in != -1) {
49.183 - arcs[nodes[v.id].first_in].prev_in = n;
49.184 + arcs[nodes[v.id].first_in].prev_in = n;
49.185 }
49.186 -
49.187 +
49.188 arcs[n].prev_in = arcs[n].prev_out = -1;
49.189 -
49.190 +
49.191 nodes[u.id].first_out = nodes[v.id].first_in = n;
49.192
49.193 return Arc(n);
49.194 }
49.195 -
49.196 +
49.197 void erase(const Node& node) {
49.198 int n = node.id;
49.199 -
49.200 +
49.201 if(nodes[n].next != -1) {
49.202 - nodes[nodes[n].next].prev = nodes[n].prev;
49.203 + nodes[nodes[n].next].prev = nodes[n].prev;
49.204 }
49.205 -
49.206 +
49.207 if(nodes[n].prev != -1) {
49.208 - nodes[nodes[n].prev].next = nodes[n].next;
49.209 + nodes[nodes[n].prev].next = nodes[n].next;
49.210 } else {
49.211 - first_node = nodes[n].next;
49.212 + first_node = nodes[n].next;
49.213 }
49.214 -
49.215 +
49.216 nodes[n].next = first_free_node;
49.217 first_free_node = n;
49.218 nodes[n].prev = -2;
49.219
49.220 }
49.221 -
49.222 +
49.223 void erase(const Arc& arc) {
49.224 int n = arc.id;
49.225 -
49.226 +
49.227 if(arcs[n].next_in!=-1) {
49.228 - arcs[arcs[n].next_in].prev_in = arcs[n].prev_in;
49.229 + arcs[arcs[n].next_in].prev_in = arcs[n].prev_in;
49.230 }
49.231
49.232 if(arcs[n].prev_in!=-1) {
49.233 - arcs[arcs[n].prev_in].next_in = arcs[n].next_in;
49.234 + arcs[arcs[n].prev_in].next_in = arcs[n].next_in;
49.235 } else {
49.236 - nodes[arcs[n].target].first_in = arcs[n].next_in;
49.237 + nodes[arcs[n].target].first_in = arcs[n].next_in;
49.238 }
49.239
49.240 -
49.241 +
49.242 if(arcs[n].next_out!=-1) {
49.243 - arcs[arcs[n].next_out].prev_out = arcs[n].prev_out;
49.244 - }
49.245 + arcs[arcs[n].next_out].prev_out = arcs[n].prev_out;
49.246 + }
49.247
49.248 if(arcs[n].prev_out!=-1) {
49.249 - arcs[arcs[n].prev_out].next_out = arcs[n].next_out;
49.250 + arcs[arcs[n].prev_out].next_out = arcs[n].next_out;
49.251 } else {
49.252 - nodes[arcs[n].source].first_out = arcs[n].next_out;
49.253 + nodes[arcs[n].source].first_out = arcs[n].next_out;
49.254 }
49.255 -
49.256 +
49.257 arcs[n].next_in = first_free_arc;
49.258 first_free_arc = n;
49.259 arcs[n].prev_in = -2;
49.260 @@ -269,30 +269,30 @@
49.261 }
49.262
49.263 protected:
49.264 - void changeTarget(Arc e, Node n)
49.265 + void changeTarget(Arc e, Node n)
49.266 {
49.267 if(arcs[e.id].next_in != -1)
49.268 - arcs[arcs[e.id].next_in].prev_in = arcs[e.id].prev_in;
49.269 + arcs[arcs[e.id].next_in].prev_in = arcs[e.id].prev_in;
49.270 if(arcs[e.id].prev_in != -1)
49.271 - arcs[arcs[e.id].prev_in].next_in = arcs[e.id].next_in;
49.272 + arcs[arcs[e.id].prev_in].next_in = arcs[e.id].next_in;
49.273 else nodes[arcs[e.id].target].first_in = arcs[e.id].next_in;
49.274 if (nodes[n.id].first_in != -1) {
49.275 - arcs[nodes[n.id].first_in].prev_in = e.id;
49.276 + arcs[nodes[n.id].first_in].prev_in = e.id;
49.277 }
49.278 arcs[e.id].target = n.id;
49.279 arcs[e.id].prev_in = -1;
49.280 arcs[e.id].next_in = nodes[n.id].first_in;
49.281 nodes[n.id].first_in = e.id;
49.282 }
49.283 - void changeSource(Arc e, Node n)
49.284 + void changeSource(Arc e, Node n)
49.285 {
49.286 if(arcs[e.id].next_out != -1)
49.287 - arcs[arcs[e.id].next_out].prev_out = arcs[e.id].prev_out;
49.288 + arcs[arcs[e.id].next_out].prev_out = arcs[e.id].prev_out;
49.289 if(arcs[e.id].prev_out != -1)
49.290 - arcs[arcs[e.id].prev_out].next_out = arcs[e.id].next_out;
49.291 + arcs[arcs[e.id].prev_out].next_out = arcs[e.id].next_out;
49.292 else nodes[arcs[e.id].source].first_out = arcs[e.id].next_out;
49.293 if (nodes[n.id].first_out != -1) {
49.294 - arcs[nodes[n.id].first_out].prev_out = e.id;
49.295 + arcs[nodes[n.id].first_out].prev_out = e.id;
49.296 }
49.297 arcs[e.id].source = n.id;
49.298 arcs[e.id].prev_out = -1;
49.299 @@ -307,11 +307,11 @@
49.300 /// \addtogroup graphs
49.301 /// @{
49.302
49.303 - ///A general directed graph structure.
49.304 + ///A general directed graph structure.
49.305
49.306 - ///\ref ListDigraph is a simple and fast <em>directed graph</em>
49.307 - ///implementation based on static linked lists that are stored in
49.308 - ///\c std::vector structures.
49.309 + ///\ref ListDigraph is a simple and fast <em>directed graph</em>
49.310 + ///implementation based on static linked lists that are stored in
49.311 + ///\c std::vector structures.
49.312 ///
49.313 ///It conforms to the \ref concepts::Digraph "Digraph concept" and it
49.314 ///also provides several useful additional functionalities.
49.315 @@ -326,7 +326,7 @@
49.316 class ListDigraph : public ExtendedListDigraphBase {
49.317 private:
49.318 ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
49.319 -
49.320 +
49.321 ///ListDigraph is \e not copy constructible. Use copyDigraph() instead.
49.322 ///
49.323 ListDigraph(const ListDigraph &) :ExtendedListDigraphBase() {};
49.324 @@ -341,30 +341,30 @@
49.325 typedef ExtendedListDigraphBase Parent;
49.326
49.327 /// Constructor
49.328 -
49.329 +
49.330 /// Constructor.
49.331 ///
49.332 ListDigraph() {}
49.333
49.334 ///Add a new node to the digraph.
49.335 -
49.336 +
49.337 ///Add a new node to the digraph.
49.338 ///\return the new node.
49.339 Node addNode() { return Parent::addNode(); }
49.340
49.341 ///Add a new arc to the digraph.
49.342 -
49.343 +
49.344 ///Add a new arc to the digraph with source node \c s
49.345 ///and target node \c t.
49.346 ///\return the new arc.
49.347 - Arc addArc(const Node& s, const Node& t) {
49.348 - return Parent::addArc(s, t);
49.349 + Arc addArc(const Node& s, const Node& t) {
49.350 + return Parent::addArc(s, t);
49.351 }
49.352
49.353 /// Node validity check
49.354
49.355 /// This function gives back true if the given node is valid,
49.356 - /// ie. it is a real node of the graph.
49.357 + /// ie. it is a real node of the graph.
49.358 ///
49.359 /// \warning A Node pointing to a removed item
49.360 /// could become valid again later if new nodes are
49.361 @@ -374,7 +374,7 @@
49.362 /// Arc validity check
49.363
49.364 /// This function gives back true if the given arc is valid,
49.365 - /// ie. it is a real arc of the graph.
49.366 + /// ie. it is a real arc of the graph.
49.367 ///
49.368 /// \warning An Arc pointing to a removed item
49.369 /// could become valid again later if new nodes are
49.370 @@ -391,8 +391,8 @@
49.371 ///
49.372 ///\warning This functionality cannot be used together with the Snapshot
49.373 ///feature.
49.374 - void changeTarget(Arc e, Node n) {
49.375 - Parent::changeTarget(e,n);
49.376 + void changeTarget(Arc e, Node n) {
49.377 + Parent::changeTarget(e,n);
49.378 }
49.379 /// Change the source of \c e to \c n
49.380
49.381 @@ -404,7 +404,7 @@
49.382 ///
49.383 ///\warning This functionality cannot be used together with the Snapshot
49.384 ///feature.
49.385 - void changeSource(Arc e, Node n) {
49.386 + void changeSource(Arc e, Node n) {
49.387 Parent::changeSource(e,n);
49.388 }
49.389
49.390 @@ -456,21 +456,21 @@
49.391 ///
49.392 ///\warning This functionality cannot be used together with the Snapshot
49.393 ///feature.
49.394 - void contract(Node a, Node b, bool r = true)
49.395 + void contract(Node a, Node b, bool r = true)
49.396 {
49.397 for(OutArcIt e(*this,b);e!=INVALID;) {
49.398 - OutArcIt f=e;
49.399 - ++f;
49.400 - if(r && target(e)==a) erase(e);
49.401 - else changeSource(e,a);
49.402 - e=f;
49.403 + OutArcIt f=e;
49.404 + ++f;
49.405 + if(r && target(e)==a) erase(e);
49.406 + else changeSource(e,a);
49.407 + e=f;
49.408 }
49.409 for(InArcIt e(*this,b);e!=INVALID;) {
49.410 - InArcIt f=e;
49.411 - ++f;
49.412 - if(r && source(e)==a) erase(e);
49.413 - else changeTarget(e,a);
49.414 - e=f;
49.415 + InArcIt f=e;
49.416 + ++f;
49.417 + if(r && source(e)==a) erase(e);
49.418 + else changeTarget(e,a);
49.419 + e=f;
49.420 }
49.421 erase(b);
49.422 }
49.423 @@ -485,7 +485,7 @@
49.424 ///
49.425 ///\note The <tt>ArcIt</tt>s referencing a moved arc remain
49.426 ///valid. However <tt>InArcIt</tt>s and <tt>OutArcIt</tt>s may
49.427 - ///be invalidated.
49.428 + ///be invalidated.
49.429 ///
49.430 ///\warning This functionality cannot be used together with the
49.431 ///Snapshot feature.
49.432 @@ -494,15 +494,15 @@
49.433 Node split(Node n, bool connect = true) {
49.434 Node b = addNode();
49.435 for(OutArcIt e(*this,n);e!=INVALID;) {
49.436 - OutArcIt f=e;
49.437 - ++f;
49.438 - changeSource(e,b);
49.439 - e=f;
49.440 + OutArcIt f=e;
49.441 + ++f;
49.442 + changeSource(e,b);
49.443 + e=f;
49.444 }
49.445 if (connect) addArc(n,b);
49.446 return b;
49.447 }
49.448 -
49.449 +
49.450 ///Split an arc.
49.451
49.452 ///This function splits an arc. First a new node \c b is added to
49.453 @@ -519,7 +519,7 @@
49.454 changeTarget(e,b);
49.455 return b;
49.456 }
49.457 -
49.458 +
49.459 /// \brief Class to make a snapshot of the digraph and restore
49.460 /// it later.
49.461 ///
49.462 @@ -529,8 +529,8 @@
49.463 /// restore() function.
49.464 ///
49.465 /// \warning Arc and node deletions and other modifications (e.g.
49.466 - /// contracting, splitting, reversing arcs or nodes) cannot be
49.467 - /// restored. These events invalidate the snapshot.
49.468 + /// contracting, splitting, reversing arcs or nodes) cannot be
49.469 + /// restored. These events invalidate the snapshot.
49.470 class Snapshot {
49.471 protected:
49.472
49.473 @@ -545,9 +545,9 @@
49.474 using NodeNotifier::ObserverBase::attach;
49.475 using NodeNotifier::ObserverBase::detach;
49.476 using NodeNotifier::ObserverBase::attached;
49.477 -
49.478 +
49.479 protected:
49.480 -
49.481 +
49.482 virtual void add(const Node& node) {
49.483 snapshot.addNode(node);
49.484 }
49.485 @@ -567,7 +567,7 @@
49.486 virtual void build() {
49.487 Node node;
49.488 std::vector<Node> nodes;
49.489 - for (notifier()->first(node); node != INVALID;
49.490 + for (notifier()->first(node); node != INVALID;
49.491 notifier()->next(node)) {
49.492 nodes.push_back(node);
49.493 }
49.494 @@ -577,7 +577,7 @@
49.495 }
49.496 virtual void clear() {
49.497 Node node;
49.498 - for (notifier()->first(node); node != INVALID;
49.499 + for (notifier()->first(node); node != INVALID;
49.500 notifier()->next(node)) {
49.501 snapshot.eraseNode(node);
49.502 }
49.503 @@ -595,7 +595,7 @@
49.504 using ArcNotifier::ObserverBase::attach;
49.505 using ArcNotifier::ObserverBase::detach;
49.506 using ArcNotifier::ObserverBase::attached;
49.507 -
49.508 +
49.509 protected:
49.510
49.511 virtual void add(const Arc& arc) {
49.512 @@ -617,7 +617,7 @@
49.513 virtual void build() {
49.514 Arc arc;
49.515 std::vector<Arc> arcs;
49.516 - for (notifier()->first(arc); arc != INVALID;
49.517 + for (notifier()->first(arc); arc != INVALID;
49.518 notifier()->next(arc)) {
49.519 arcs.push_back(arc);
49.520 }
49.521 @@ -627,7 +627,7 @@
49.522 }
49.523 virtual void clear() {
49.524 Arc arc;
49.525 - for (notifier()->first(arc); arc != INVALID;
49.526 + for (notifier()->first(arc); arc != INVALID;
49.527 notifier()->next(arc)) {
49.528 snapshot.eraseArc(arc);
49.529 }
49.530 @@ -635,7 +635,7 @@
49.531
49.532 Snapshot& snapshot;
49.533 };
49.534 -
49.535 +
49.536 ListDigraph *digraph;
49.537
49.538 NodeObserverProxy node_observer_proxy;
49.539 @@ -646,10 +646,10 @@
49.540
49.541
49.542 void addNode(const Node& node) {
49.543 - added_nodes.push_front(node);
49.544 + added_nodes.push_front(node);
49.545 }
49.546 void eraseNode(const Node& node) {
49.547 - std::list<Node>::iterator it =
49.548 + std::list<Node>::iterator it =
49.549 std::find(added_nodes.begin(), added_nodes.end(), node);
49.550 if (it == added_nodes.end()) {
49.551 clear();
49.552 @@ -661,29 +661,29 @@
49.553 }
49.554
49.555 void addArc(const Arc& arc) {
49.556 - added_arcs.push_front(arc);
49.557 + added_arcs.push_front(arc);
49.558 }
49.559 void eraseArc(const Arc& arc) {
49.560 - std::list<Arc>::iterator it =
49.561 + std::list<Arc>::iterator it =
49.562 std::find(added_arcs.begin(), added_arcs.end(), arc);
49.563 if (it == added_arcs.end()) {
49.564 clear();
49.565 - node_observer_proxy.detach();
49.566 + node_observer_proxy.detach();
49.567 throw ArcNotifier::ImmediateDetach();
49.568 } else {
49.569 added_arcs.erase(it);
49.570 - }
49.571 + }
49.572 }
49.573
49.574 void attach(ListDigraph &_digraph) {
49.575 - digraph = &_digraph;
49.576 - node_observer_proxy.attach(digraph->notifier(Node()));
49.577 + digraph = &_digraph;
49.578 + node_observer_proxy.attach(digraph->notifier(Node()));
49.579 arc_observer_proxy.attach(digraph->notifier(Arc()));
49.580 }
49.581 -
49.582 +
49.583 void detach() {
49.584 - node_observer_proxy.detach();
49.585 - arc_observer_proxy.detach();
49.586 + node_observer_proxy.detach();
49.587 + arc_observer_proxy.detach();
49.588 }
49.589
49.590 bool attached() const {
49.591 @@ -692,7 +692,7 @@
49.592
49.593 void clear() {
49.594 added_nodes.clear();
49.595 - added_arcs.clear();
49.596 + added_arcs.clear();
49.597 }
49.598
49.599 public:
49.600 @@ -701,20 +701,20 @@
49.601 ///
49.602 /// Default constructor.
49.603 /// To actually make a snapshot you must call save().
49.604 - Snapshot()
49.605 - : digraph(0), node_observer_proxy(*this),
49.606 + Snapshot()
49.607 + : digraph(0), node_observer_proxy(*this),
49.608 arc_observer_proxy(*this) {}
49.609 -
49.610 +
49.611 /// \brief Constructor that immediately makes a snapshot.
49.612 - ///
49.613 + ///
49.614 /// This constructor immediately makes a snapshot of the digraph.
49.615 /// \param _digraph The digraph we make a snapshot of.
49.616 - Snapshot(ListDigraph &_digraph)
49.617 - : node_observer_proxy(*this),
49.618 + Snapshot(ListDigraph &_digraph)
49.619 + : node_observer_proxy(*this),
49.620 arc_observer_proxy(*this) {
49.621 - attach(_digraph);
49.622 + attach(_digraph);
49.623 }
49.624 -
49.625 +
49.626 /// \brief Make a snapshot.
49.627 ///
49.628 /// Make a snapshot of the digraph.
49.629 @@ -729,20 +729,20 @@
49.630 }
49.631 attach(_digraph);
49.632 }
49.633 -
49.634 +
49.635 /// \brief Undo the changes until the last snapshot.
49.636 - //
49.637 + //
49.638 /// Undo the changes until the last snapshot created by save().
49.639 void restore() {
49.640 - detach();
49.641 - for(std::list<Arc>::iterator it = added_arcs.begin();
49.642 + detach();
49.643 + for(std::list<Arc>::iterator it = added_arcs.begin();
49.644 it != added_arcs.end(); ++it) {
49.645 - digraph->erase(*it);
49.646 - }
49.647 - for(std::list<Node>::iterator it = added_nodes.begin();
49.648 + digraph->erase(*it);
49.649 + }
49.650 + for(std::list<Node>::iterator it = added_nodes.begin();
49.651 it != added_nodes.end(); ++it) {
49.652 - digraph->erase(*it);
49.653 - }
49.654 + digraph->erase(*it);
49.655 + }
49.656 clear();
49.657 }
49.658
49.659 @@ -753,7 +753,7 @@
49.660 return attached();
49.661 }
49.662 };
49.663 -
49.664 +
49.665 };
49.666
49.667 ///@}
49.668 @@ -766,7 +766,7 @@
49.669 int first_out;
49.670 int prev, next;
49.671 };
49.672 -
49.673 +
49.674 struct ArcT {
49.675 int target;
49.676 int prev_out, next_out;
49.677 @@ -781,15 +781,15 @@
49.678 std::vector<ArcT> arcs;
49.679
49.680 int first_free_arc;
49.681 -
49.682 +
49.683 public:
49.684 -
49.685 +
49.686 typedef ListGraphBase Digraph;
49.687
49.688 class Node;
49.689 class Arc;
49.690 class Edge;
49.691 -
49.692 +
49.693 class Node {
49.694 friend class ListGraphBase;
49.695 protected:
49.696 @@ -841,10 +841,10 @@
49.697
49.698 ListGraphBase()
49.699 : nodes(), first_node(-1),
49.700 - first_free_node(-1), arcs(), first_free_arc(-1) {}
49.701 + first_free_node(-1), arcs(), first_free_arc(-1) {}
49.702
49.703 -
49.704 - int maxNodeId() const { return nodes.size()-1; }
49.705 +
49.706 + int maxNodeId() const { return nodes.size()-1; }
49.707 int maxEdgeId() const { return arcs.size() / 2 - 1; }
49.708 int maxArcId() const { return arcs.size()-1; }
49.709
49.710 @@ -862,7 +862,7 @@
49.711 return Arc(e.id * 2 + (d ? 1 : 0));
49.712 }
49.713
49.714 - void first(Node& node) const {
49.715 + void first(Node& node) const {
49.716 node.id = first_node;
49.717 }
49.718
49.719 @@ -870,7 +870,7 @@
49.720 node.id = nodes[node.id].next;
49.721 }
49.722
49.723 - void first(Arc& e) const {
49.724 + void first(Arc& e) const {
49.725 int n = first_node;
49.726 while (n != -1 && nodes[n].first_out == -1) {
49.727 n = nodes[n].next;
49.728 @@ -880,17 +880,17 @@
49.729
49.730 void next(Arc& e) const {
49.731 if (arcs[e.id].next_out != -1) {
49.732 - e.id = arcs[e.id].next_out;
49.733 + e.id = arcs[e.id].next_out;
49.734 } else {
49.735 - int n = nodes[arcs[e.id ^ 1].target].next;
49.736 + int n = nodes[arcs[e.id ^ 1].target].next;
49.737 while(n != -1 && nodes[n].first_out == -1) {
49.738 n = nodes[n].next;
49.739 }
49.740 - e.id = (n == -1) ? -1 : nodes[n].first_out;
49.741 - }
49.742 + e.id = (n == -1) ? -1 : nodes[n].first_out;
49.743 + }
49.744 }
49.745
49.746 - void first(Edge& e) const {
49.747 + void first(Edge& e) const {
49.748 int n = first_node;
49.749 while (n != -1) {
49.750 e.id = nodes[n].first_out;
49.751 @@ -900,7 +900,7 @@
49.752 if (e.id != -1) {
49.753 e.id /= 2;
49.754 return;
49.755 - }
49.756 + }
49.757 n = nodes[n].next;
49.758 }
49.759 e.id = -1;
49.760 @@ -915,7 +915,7 @@
49.761 if (e.id != -1) {
49.762 e.id /= 2;
49.763 return;
49.764 - }
49.765 + }
49.766 n = nodes[n].next;
49.767 while (n != -1) {
49.768 e.id = nodes[n].first_out;
49.769 @@ -925,7 +925,7 @@
49.770 if (e.id != -1) {
49.771 e.id /= 2;
49.772 return;
49.773 - }
49.774 + }
49.775 n = nodes[n].next;
49.776 }
49.777 e.id = -1;
49.778 @@ -967,7 +967,7 @@
49.779 d = true;
49.780 }
49.781 }
49.782 -
49.783 +
49.784 static int id(Node v) { return v.id; }
49.785 static int id(Arc e) { return e.id; }
49.786 static int id(Edge e) { return e.id; }
49.787 @@ -976,117 +976,117 @@
49.788 static Arc arcFromId(int id) { return Arc(id);}
49.789 static Edge edgeFromId(int id) { return Edge(id);}
49.790
49.791 - bool valid(Node n) const {
49.792 - return n.id >= 0 && n.id < static_cast<int>(nodes.size()) &&
49.793 - nodes[n.id].prev != -2;
49.794 + bool valid(Node n) const {
49.795 + return n.id >= 0 && n.id < static_cast<int>(nodes.size()) &&
49.796 + nodes[n.id].prev != -2;
49.797 }
49.798
49.799 - bool valid(Arc a) const {
49.800 - return a.id >= 0 && a.id < static_cast<int>(arcs.size()) &&
49.801 - arcs[a.id].prev_out != -2;
49.802 + bool valid(Arc a) const {
49.803 + return a.id >= 0 && a.id < static_cast<int>(arcs.size()) &&
49.804 + arcs[a.id].prev_out != -2;
49.805 }
49.806
49.807 - bool valid(Edge e) const {
49.808 - return e.id >= 0 && 2 * e.id < static_cast<int>(arcs.size()) &&
49.809 - arcs[2 * e.id].prev_out != -2;
49.810 + bool valid(Edge e) const {
49.811 + return e.id >= 0 && 2 * e.id < static_cast<int>(arcs.size()) &&
49.812 + arcs[2 * e.id].prev_out != -2;
49.813 }
49.814
49.815 - Node addNode() {
49.816 + Node addNode() {
49.817 int n;
49.818 -
49.819 +
49.820 if(first_free_node==-1) {
49.821 - n = nodes.size();
49.822 - nodes.push_back(NodeT());
49.823 + n = nodes.size();
49.824 + nodes.push_back(NodeT());
49.825 } else {
49.826 - n = first_free_node;
49.827 - first_free_node = nodes[n].next;
49.828 + n = first_free_node;
49.829 + first_free_node = nodes[n].next;
49.830 }
49.831 -
49.832 +
49.833 nodes[n].next = first_node;
49.834 if (first_node != -1) nodes[first_node].prev = n;
49.835 first_node = n;
49.836 nodes[n].prev = -1;
49.837 -
49.838 +
49.839 nodes[n].first_out = -1;
49.840 -
49.841 +
49.842 return Node(n);
49.843 }
49.844 -
49.845 +
49.846 Edge addEdge(Node u, Node v) {
49.847 - int n;
49.848 + int n;
49.849
49.850 if (first_free_arc == -1) {
49.851 - n = arcs.size();
49.852 - arcs.push_back(ArcT());
49.853 - arcs.push_back(ArcT());
49.854 + n = arcs.size();
49.855 + arcs.push_back(ArcT());
49.856 + arcs.push_back(ArcT());
49.857 } else {
49.858 - n = first_free_arc;
49.859 - first_free_arc = arcs[n].next_out;
49.860 + n = first_free_arc;
49.861 + first_free_arc = arcs[n].next_out;
49.862 }
49.863 -
49.864 +
49.865 arcs[n].target = u.id;
49.866 arcs[n | 1].target = v.id;
49.867
49.868 arcs[n].next_out = nodes[v.id].first_out;
49.869 if (nodes[v.id].first_out != -1) {
49.870 - arcs[nodes[v.id].first_out].prev_out = n;
49.871 - }
49.872 + arcs[nodes[v.id].first_out].prev_out = n;
49.873 + }
49.874 arcs[n].prev_out = -1;
49.875 nodes[v.id].first_out = n;
49.876 -
49.877 +
49.878 arcs[n | 1].next_out = nodes[u.id].first_out;
49.879 if (nodes[u.id].first_out != -1) {
49.880 - arcs[nodes[u.id].first_out].prev_out = (n | 1);
49.881 + arcs[nodes[u.id].first_out].prev_out = (n | 1);
49.882 }
49.883 - arcs[n | 1].prev_out = -1;
49.884 + arcs[n | 1].prev_out = -1;
49.885 nodes[u.id].first_out = (n | 1);
49.886
49.887 return Edge(n / 2);
49.888 }
49.889 -
49.890 +
49.891 void erase(const Node& node) {
49.892 int n = node.id;
49.893 -
49.894 +
49.895 if(nodes[n].next != -1) {
49.896 - nodes[nodes[n].next].prev = nodes[n].prev;
49.897 + nodes[nodes[n].next].prev = nodes[n].prev;
49.898 }
49.899 -
49.900 +
49.901 if(nodes[n].prev != -1) {
49.902 - nodes[nodes[n].prev].next = nodes[n].next;
49.903 + nodes[nodes[n].prev].next = nodes[n].next;
49.904 } else {
49.905 - first_node = nodes[n].next;
49.906 + first_node = nodes[n].next;
49.907 }
49.908 -
49.909 +
49.910 nodes[n].next = first_free_node;
49.911 first_free_node = n;
49.912 nodes[n].prev = -2;
49.913 }
49.914 -
49.915 +
49.916 void erase(const Edge& edge) {
49.917 int n = edge.id * 2;
49.918 -
49.919 +
49.920 if (arcs[n].next_out != -1) {
49.921 - arcs[arcs[n].next_out].prev_out = arcs[n].prev_out;
49.922 - }
49.923 + arcs[arcs[n].next_out].prev_out = arcs[n].prev_out;
49.924 + }
49.925
49.926 if (arcs[n].prev_out != -1) {
49.927 - arcs[arcs[n].prev_out].next_out = arcs[n].next_out;
49.928 + arcs[arcs[n].prev_out].next_out = arcs[n].next_out;
49.929 } else {
49.930 - nodes[arcs[n | 1].target].first_out = arcs[n].next_out;
49.931 + nodes[arcs[n | 1].target].first_out = arcs[n].next_out;
49.932 }
49.933
49.934 if (arcs[n | 1].next_out != -1) {
49.935 - arcs[arcs[n | 1].next_out].prev_out = arcs[n | 1].prev_out;
49.936 - }
49.937 + arcs[arcs[n | 1].next_out].prev_out = arcs[n | 1].prev_out;
49.938 + }
49.939
49.940 if (arcs[n | 1].prev_out != -1) {
49.941 - arcs[arcs[n | 1].prev_out].next_out = arcs[n | 1].next_out;
49.942 + arcs[arcs[n | 1].prev_out].next_out = arcs[n | 1].next_out;
49.943 } else {
49.944 - nodes[arcs[n].target].first_out = arcs[n | 1].next_out;
49.945 + nodes[arcs[n].target].first_out = arcs[n | 1].next_out;
49.946 }
49.947 -
49.948 +
49.949 arcs[n].next_out = first_free_arc;
49.950 - first_free_arc = n;
49.951 + first_free_arc = n;
49.952 arcs[n].prev_out = -2;
49.953 arcs[n | 1].prev_out = -2;
49.954
49.955 @@ -1102,18 +1102,18 @@
49.956
49.957 void changeTarget(Edge e, Node n) {
49.958 if(arcs[2 * e.id].next_out != -1) {
49.959 - arcs[arcs[2 * e.id].next_out].prev_out = arcs[2 * e.id].prev_out;
49.960 + arcs[arcs[2 * e.id].next_out].prev_out = arcs[2 * e.id].prev_out;
49.961 }
49.962 if(arcs[2 * e.id].prev_out != -1) {
49.963 - arcs[arcs[2 * e.id].prev_out].next_out =
49.964 + arcs[arcs[2 * e.id].prev_out].next_out =
49.965 arcs[2 * e.id].next_out;
49.966 } else {
49.967 - nodes[arcs[(2 * e.id) | 1].target].first_out =
49.968 + nodes[arcs[(2 * e.id) | 1].target].first_out =
49.969 arcs[2 * e.id].next_out;
49.970 }
49.971
49.972 if (nodes[n.id].first_out != -1) {
49.973 - arcs[nodes[n.id].first_out].prev_out = 2 * e.id;
49.974 + arcs[nodes[n.id].first_out].prev_out = 2 * e.id;
49.975 }
49.976 arcs[(2 * e.id) | 1].target = n.id;
49.977 arcs[2 * e.id].prev_out = -1;
49.978 @@ -1123,19 +1123,19 @@
49.979
49.980 void changeSource(Edge e, Node n) {
49.981 if(arcs[(2 * e.id) | 1].next_out != -1) {
49.982 - arcs[arcs[(2 * e.id) | 1].next_out].prev_out =
49.983 + arcs[arcs[(2 * e.id) | 1].next_out].prev_out =
49.984 arcs[(2 * e.id) | 1].prev_out;
49.985 }
49.986 if(arcs[(2 * e.id) | 1].prev_out != -1) {
49.987 - arcs[arcs[(2 * e.id) | 1].prev_out].next_out =
49.988 + arcs[arcs[(2 * e.id) | 1].prev_out].next_out =
49.989 arcs[(2 * e.id) | 1].next_out;
49.990 } else {
49.991 - nodes[arcs[2 * e.id].target].first_out =
49.992 + nodes[arcs[2 * e.id].target].first_out =
49.993 arcs[(2 * e.id) | 1].next_out;
49.994 }
49.995
49.996 if (nodes[n.id].first_out != -1) {
49.997 - arcs[nodes[n.id].first_out].prev_out = ((2 * e.id) | 1);
49.998 + arcs[nodes[n.id].first_out].prev_out = ((2 * e.id) | 1);
49.999 }
49.1000 arcs[2 * e.id].target = n.id;
49.1001 arcs[(2 * e.id) | 1].prev_out = -1;
49.1002 @@ -1153,9 +1153,9 @@
49.1003
49.1004 ///A general undirected graph structure.
49.1005
49.1006 - ///\ref ListGraph is a simple and fast <em>undirected graph</em>
49.1007 - ///implementation based on static linked lists that are stored in
49.1008 - ///\c std::vector structures.
49.1009 + ///\ref ListGraph is a simple and fast <em>undirected graph</em>
49.1010 + ///implementation based on static linked lists that are stored in
49.1011 + ///\c std::vector structures.
49.1012 ///
49.1013 ///It conforms to the \ref concepts::Graph "Graph concept" and it
49.1014 ///also provides several useful additional functionalities.
49.1015 @@ -1182,7 +1182,7 @@
49.1016 void operator=(const ListGraph &) {}
49.1017 public:
49.1018 /// Constructor
49.1019 -
49.1020 +
49.1021 /// Constructor.
49.1022 ///
49.1023 ListGraph() {}
49.1024 @@ -1202,13 +1202,13 @@
49.1025 /// Add a new edge to the graph with source node \c s
49.1026 /// and target node \c t.
49.1027 /// \return the new edge.
49.1028 - Edge addEdge(const Node& s, const Node& t) {
49.1029 - return Parent::addEdge(s, t);
49.1030 + Edge addEdge(const Node& s, const Node& t) {
49.1031 + return Parent::addEdge(s, t);
49.1032 }
49.1033 /// Node validity check
49.1034
49.1035 /// This function gives back true if the given node is valid,
49.1036 - /// ie. it is a real node of the graph.
49.1037 + /// ie. it is a real node of the graph.
49.1038 ///
49.1039 /// \warning A Node pointing to a removed item
49.1040 /// could become valid again later if new nodes are
49.1041 @@ -1217,7 +1217,7 @@
49.1042 /// Arc validity check
49.1043
49.1044 /// This function gives back true if the given arc is valid,
49.1045 - /// ie. it is a real arc of the graph.
49.1046 + /// ie. it is a real arc of the graph.
49.1047 ///
49.1048 /// \warning An Arc pointing to a removed item
49.1049 /// could become valid again later if new edges are
49.1050 @@ -1226,7 +1226,7 @@
49.1051 /// Edge validity check
49.1052
49.1053 /// This function gives back true if the given edge is valid,
49.1054 - /// ie. it is a real arc of the graph.
49.1055 + /// ie. it is a real arc of the graph.
49.1056 ///
49.1057 /// \warning A Edge pointing to a removed item
49.1058 /// could become valid again later if new edges are
49.1059 @@ -1242,9 +1242,9 @@
49.1060 ///
49.1061 ///\warning This functionality cannot be used together with the
49.1062 ///Snapshot feature.
49.1063 - void changeSource(Edge e, Node n) {
49.1064 - Parent::changeSource(e,n);
49.1065 - }
49.1066 + void changeSource(Edge e, Node n) {
49.1067 + Parent::changeSource(e,n);
49.1068 + }
49.1069 /// \brief Change the target of \c e to \c n
49.1070 ///
49.1071 /// This function changes the target of \c e to \c n.
49.1072 @@ -1254,12 +1254,12 @@
49.1073 ///
49.1074 ///\warning This functionality cannot be used together with the
49.1075 ///Snapshot feature.
49.1076 - void changeTarget(Edge e, Node n) {
49.1077 - Parent::changeTarget(e,n);
49.1078 + void changeTarget(Edge e, Node n) {
49.1079 + Parent::changeTarget(e,n);
49.1080 }
49.1081 /// \brief Change the source of \c e to \c n
49.1082 ///
49.1083 - /// This function changes the source of \c e to \c n.
49.1084 + /// This function changes the source of \c e to \c n.
49.1085 /// It also changes the proper node of the represented edge.
49.1086 ///
49.1087 ///\note The <tt>ArcIt</tt>s and <tt>InArcIt</tt>s
49.1088 @@ -1268,16 +1268,16 @@
49.1089 ///
49.1090 ///\warning This functionality cannot be used together with the
49.1091 ///Snapshot feature.
49.1092 - void changeSource(Arc e, Node n) {
49.1093 + void changeSource(Arc e, Node n) {
49.1094 if (Parent::direction(e)) {
49.1095 Parent::changeSource(e,n);
49.1096 } else {
49.1097 Parent::changeTarget(e,n);
49.1098 - }
49.1099 + }
49.1100 }
49.1101 /// \brief Change the target of \c e to \c n
49.1102 ///
49.1103 - /// This function changes the target of \c e to \c n.
49.1104 + /// This function changes the target of \c e to \c n.
49.1105 /// It also changes the proper node of the represented edge.
49.1106 ///
49.1107 ///\note The <tt>ArcIt</tt>s and <tt>OutArcIt</tt>s
49.1108 @@ -1286,12 +1286,12 @@
49.1109 ///
49.1110 ///\warning This functionality cannot be used together with the
49.1111 ///Snapshot feature.
49.1112 - void changeTarget(Arc e, Node n) {
49.1113 + void changeTarget(Arc e, Node n) {
49.1114 if (Parent::direction(e)) {
49.1115 Parent::changeTarget(e,n);
49.1116 } else {
49.1117 Parent::changeSource(e,n);
49.1118 - }
49.1119 + }
49.1120 }
49.1121 /// \brief Contract two nodes.
49.1122 ///
49.1123 @@ -1308,15 +1308,15 @@
49.1124 ///Snapshot feature.
49.1125 void contract(Node a, Node b, bool r = true) {
49.1126 for(IncEdgeIt e(*this, b); e!=INVALID;) {
49.1127 - IncEdgeIt f = e; ++f;
49.1128 - if (r && runningNode(e) == a) {
49.1129 - erase(e);
49.1130 - } else if (source(e) == b) {
49.1131 - changeSource(e, a);
49.1132 - } else {
49.1133 - changeTarget(e, a);
49.1134 - }
49.1135 - e = f;
49.1136 + IncEdgeIt f = e; ++f;
49.1137 + if (r && runningNode(e) == a) {
49.1138 + erase(e);
49.1139 + } else if (source(e) == b) {
49.1140 + changeSource(e, a);
49.1141 + } else {
49.1142 + changeTarget(e, a);
49.1143 + }
49.1144 + e = f;
49.1145 }
49.1146 erase(b);
49.1147 }
49.1148 @@ -1331,7 +1331,7 @@
49.1149 /// using the restore() function.
49.1150 ///
49.1151 /// \warning Edge and node deletions and other modifications
49.1152 - /// (e.g. changing nodes of edges, contracting nodes) cannot be
49.1153 + /// (e.g. changing nodes of edges, contracting nodes) cannot be
49.1154 /// restored. These events invalidate the snapshot.
49.1155 class Snapshot {
49.1156 protected:
49.1157 @@ -1347,9 +1347,9 @@
49.1158 using NodeNotifier::ObserverBase::attach;
49.1159 using NodeNotifier::ObserverBase::detach;
49.1160 using NodeNotifier::ObserverBase::attached;
49.1161 -
49.1162 +
49.1163 protected:
49.1164 -
49.1165 +
49.1166 virtual void add(const Node& node) {
49.1167 snapshot.addNode(node);
49.1168 }
49.1169 @@ -1369,7 +1369,7 @@
49.1170 virtual void build() {
49.1171 Node node;
49.1172 std::vector<Node> nodes;
49.1173 - for (notifier()->first(node); node != INVALID;
49.1174 + for (notifier()->first(node); node != INVALID;
49.1175 notifier()->next(node)) {
49.1176 nodes.push_back(node);
49.1177 }
49.1178 @@ -1379,7 +1379,7 @@
49.1179 }
49.1180 virtual void clear() {
49.1181 Node node;
49.1182 - for (notifier()->first(node); node != INVALID;
49.1183 + for (notifier()->first(node); node != INVALID;
49.1184 notifier()->next(node)) {
49.1185 snapshot.eraseNode(node);
49.1186 }
49.1187 @@ -1397,7 +1397,7 @@
49.1188 using EdgeNotifier::ObserverBase::attach;
49.1189 using EdgeNotifier::ObserverBase::detach;
49.1190 using EdgeNotifier::ObserverBase::attached;
49.1191 -
49.1192 +
49.1193 protected:
49.1194
49.1195 virtual void add(const Edge& edge) {
49.1196 @@ -1419,7 +1419,7 @@
49.1197 virtual void build() {
49.1198 Edge edge;
49.1199 std::vector<Edge> edges;
49.1200 - for (notifier()->first(edge); edge != INVALID;
49.1201 + for (notifier()->first(edge); edge != INVALID;
49.1202 notifier()->next(edge)) {
49.1203 edges.push_back(edge);
49.1204 }
49.1205 @@ -1429,7 +1429,7 @@
49.1206 }
49.1207 virtual void clear() {
49.1208 Edge edge;
49.1209 - for (notifier()->first(edge); edge != INVALID;
49.1210 + for (notifier()->first(edge); edge != INVALID;
49.1211 notifier()->next(edge)) {
49.1212 snapshot.eraseEdge(edge);
49.1213 }
49.1214 @@ -1448,10 +1448,10 @@
49.1215
49.1216
49.1217 void addNode(const Node& node) {
49.1218 - added_nodes.push_front(node);
49.1219 + added_nodes.push_front(node);
49.1220 }
49.1221 void eraseNode(const Node& node) {
49.1222 - std::list<Node>::iterator it =
49.1223 + std::list<Node>::iterator it =
49.1224 std::find(added_nodes.begin(), added_nodes.end(), node);
49.1225 if (it == added_nodes.end()) {
49.1226 clear();
49.1227 @@ -1463,10 +1463,10 @@
49.1228 }
49.1229
49.1230 void addEdge(const Edge& edge) {
49.1231 - added_edges.push_front(edge);
49.1232 + added_edges.push_front(edge);
49.1233 }
49.1234 void eraseEdge(const Edge& edge) {
49.1235 - std::list<Edge>::iterator it =
49.1236 + std::list<Edge>::iterator it =
49.1237 std::find(added_edges.begin(), added_edges.end(), edge);
49.1238 if (it == added_edges.end()) {
49.1239 clear();
49.1240 @@ -1478,14 +1478,14 @@
49.1241 }
49.1242
49.1243 void attach(ListGraph &_graph) {
49.1244 - graph = &_graph;
49.1245 - node_observer_proxy.attach(graph->notifier(Node()));
49.1246 + graph = &_graph;
49.1247 + node_observer_proxy.attach(graph->notifier(Node()));
49.1248 edge_observer_proxy.attach(graph->notifier(Edge()));
49.1249 }
49.1250 -
49.1251 +
49.1252 void detach() {
49.1253 - node_observer_proxy.detach();
49.1254 - edge_observer_proxy.detach();
49.1255 + node_observer_proxy.detach();
49.1256 + edge_observer_proxy.detach();
49.1257 }
49.1258
49.1259 bool attached() const {
49.1260 @@ -1494,7 +1494,7 @@
49.1261
49.1262 void clear() {
49.1263 added_nodes.clear();
49.1264 - added_edges.clear();
49.1265 + added_edges.clear();
49.1266 }
49.1267
49.1268 public:
49.1269 @@ -1503,20 +1503,20 @@
49.1270 ///
49.1271 /// Default constructor.
49.1272 /// To actually make a snapshot you must call save().
49.1273 - Snapshot()
49.1274 - : graph(0), node_observer_proxy(*this),
49.1275 + Snapshot()
49.1276 + : graph(0), node_observer_proxy(*this),
49.1277 edge_observer_proxy(*this) {}
49.1278 -
49.1279 +
49.1280 /// \brief Constructor that immediately makes a snapshot.
49.1281 - ///
49.1282 + ///
49.1283 /// This constructor immediately makes a snapshot of the graph.
49.1284 /// \param _graph The graph we make a snapshot of.
49.1285 - Snapshot(ListGraph &_graph)
49.1286 - : node_observer_proxy(*this),
49.1287 + Snapshot(ListGraph &_graph)
49.1288 + : node_observer_proxy(*this),
49.1289 edge_observer_proxy(*this) {
49.1290 - attach(_graph);
49.1291 + attach(_graph);
49.1292 }
49.1293 -
49.1294 +
49.1295 /// \brief Make a snapshot.
49.1296 ///
49.1297 /// Make a snapshot of the graph.
49.1298 @@ -1531,20 +1531,20 @@
49.1299 }
49.1300 attach(_graph);
49.1301 }
49.1302 -
49.1303 +
49.1304 /// \brief Undo the changes until the last snapshot.
49.1305 - //
49.1306 + //
49.1307 /// Undo the changes until the last snapshot created by save().
49.1308 void restore() {
49.1309 - detach();
49.1310 - for(std::list<Edge>::iterator it = added_edges.begin();
49.1311 + detach();
49.1312 + for(std::list<Edge>::iterator it = added_edges.begin();
49.1313 it != added_edges.end(); ++it) {
49.1314 - graph->erase(*it);
49.1315 - }
49.1316 - for(std::list<Node>::iterator it = added_nodes.begin();
49.1317 + graph->erase(*it);
49.1318 + }
49.1319 + for(std::list<Node>::iterator it = added_nodes.begin();
49.1320 it != added_nodes.end(); ++it) {
49.1321 - graph->erase(*it);
49.1322 - }
49.1323 + graph->erase(*it);
49.1324 + }
49.1325 clear();
49.1326 }
49.1327
49.1328 @@ -1556,9 +1556,9 @@
49.1329 }
49.1330 };
49.1331 };
49.1332 -
49.1333 - /// @}
49.1334 +
49.1335 + /// @}
49.1336 } //namespace lemon
49.1337 -
49.1338 +
49.1339
49.1340 #endif
50.1 --- a/lemon/maps.h Sun Jul 13 16:46:56 2008 +0100
50.2 +++ b/lemon/maps.h Sun Jul 13 19:51:02 2008 +0100
50.3 @@ -1,6 +1,6 @@
50.4 -/* -*- C++ -*-
50.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
50.6 *
50.7 - * This file is a part of LEMON, a generic C++ optimization library
50.8 + * This file is a part of LEMON, a generic C++ optimization library.
50.9 *
50.10 * Copyright (C) 2003-2008
50.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
50.12 @@ -404,27 +404,27 @@
50.13 Reference operator[](const Key &k) {
50.14 typename Map::iterator it = _map.lower_bound(k);
50.15 if (it != _map.end() && !_map.key_comp()(k, it->first))
50.16 - return it->second;
50.17 + return it->second;
50.18 else
50.19 - return _map.insert(it, std::make_pair(k, _value))->second;
50.20 + return _map.insert(it, std::make_pair(k, _value))->second;
50.21 }
50.22
50.23 ///\e
50.24 ConstReference operator[](const Key &k) const {
50.25 typename Map::const_iterator it = _map.find(k);
50.26 if (it != _map.end())
50.27 - return it->second;
50.28 + return it->second;
50.29 else
50.30 - return _value;
50.31 + return _value;
50.32 }
50.33
50.34 ///\e
50.35 void set(const Key &k, const Value &v) {
50.36 typename Map::iterator it = _map.lower_bound(k);
50.37 if (it != _map.end() && !_map.key_comp()(k, it->first))
50.38 - it->second = v;
50.39 + it->second = v;
50.40 else
50.41 - _map.insert(it, std::make_pair(k, v));
50.42 + _map.insert(it, std::make_pair(k, v));
50.43 }
50.44
50.45 ///\e
50.46 @@ -544,7 +544,7 @@
50.47 ///
50.48 /// \todo Check the requirements.
50.49 template<typename M1, typename M2, typename F,
50.50 - typename V = typename F::result_type>
50.51 + typename V = typename F::result_type>
50.52 class CombineMap : public MapBase<typename M1::Key, V> {
50.53 const M1 &_m1;
50.54 const M2 &_m2;
50.55 @@ -615,8 +615,8 @@
50.56 ///
50.57 /// \sa MapToFunctor
50.58 template<typename F,
50.59 - typename K = typename F::argument_type,
50.60 - typename V = typename F::result_type>
50.61 + typename K = typename F::argument_type,
50.62 + typename V = typename F::result_type>
50.63 class FunctorToMap : public MapBase<K, V> {
50.64 F _f;
50.65 public:
50.66 @@ -1317,7 +1317,7 @@
50.67 }
50.68
50.69 /// @}
50.70 -
50.71 +
50.72 // Logical maps and map adaptors:
50.73
50.74 /// \addtogroup maps
50.75 @@ -1715,7 +1715,7 @@
50.76 template <typename It, typename Ke>
50.77 #else
50.78 template <typename It,
50.79 - typename Ke=typename _maps_bits::IteratorTraits<It>::Value>
50.80 + typename Ke=typename _maps_bits::IteratorTraits<It>::Value>
50.81 #endif
50.82 class LoggerBoolMap {
50.83 public:
50.84 @@ -1741,7 +1741,7 @@
50.85 /// The set function of the map
50.86 void set(const Key& key, Value value) {
50.87 if (value) {
50.88 - *_end++ = key;
50.89 + *_end++ = key;
50.90 }
50.91 }
50.92
50.93 @@ -1749,7 +1749,7 @@
50.94 Iterator _begin;
50.95 Iterator _end;
50.96 };
50.97 -
50.98 +
50.99 /// Returns a \ref LoggerBoolMap class
50.100
50.101 /// This function just returns a \ref LoggerBoolMap class.
51.1 --- a/lemon/math.h Sun Jul 13 16:46:56 2008 +0100
51.2 +++ b/lemon/math.h Sun Jul 13 19:51:02 2008 +0100
51.3 @@ -1,6 +1,6 @@
51.4 -/* -*- C++ -*-
51.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
51.6 *
51.7 - * This file is a part of LEMON, a generic C++ optimization library
51.8 + * This file is a part of LEMON, a generic C++ optimization library.
51.9 *
51.10 * Copyright (C) 2003-2008
51.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
51.12 @@ -33,7 +33,7 @@
51.13
51.14 /// \addtogroup misc
51.15 /// @{
51.16 -
51.17 +
51.18 /// The Euler constant
51.19 const long double E = 2.7182818284590452353602874713526625L;
51.20 /// log_2(e)
51.21 @@ -54,7 +54,7 @@
51.22 const long double SQRT2 = 1.4142135623730950488016887242096981L;
51.23 /// 1/sqrt(2)
51.24 const long double SQRT1_2 = 0.7071067811865475244008443621048490L;
51.25 -
51.26 +
51.27
51.28 /// @}
51.29
52.1 --- a/lemon/path.h Sun Jul 13 16:46:56 2008 +0100
52.2 +++ b/lemon/path.h Sun Jul 13 19:51:02 2008 +0100
52.3 @@ -1,6 +1,6 @@
52.4 -/* -*- C++ -*-
52.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
52.6 *
52.7 - * This file is a part of LEMON, a generic C++ optimization library
52.8 + * This file is a part of LEMON, a generic C++ optimization library.
52.9 *
52.10 * Copyright (C) 2003-2008
52.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
52.12 @@ -93,12 +93,12 @@
52.13 /// \brief Invalid constructor
52.14 ArcIt(Invalid) : path(0), idx(-1) {}
52.15 /// \brief Initializate the iterator to the first arc of path
52.16 - ArcIt(const Path &_path)
52.17 + ArcIt(const Path &_path)
52.18 : path(&_path), idx(_path.empty() ? -1 : 0) {}
52.19
52.20 private:
52.21
52.22 - ArcIt(const Path &_path, int _idx)
52.23 + ArcIt(const Path &_path, int _idx)
52.24 : path(&_path), idx(_idx) {}
52.25
52.26 public:
52.27 @@ -109,10 +109,10 @@
52.28 }
52.29
52.30 /// \brief Next arc
52.31 - ArcIt& operator++() {
52.32 + ArcIt& operator++() {
52.33 ++idx;
52.34 - if (idx >= path->length()) idx = -1;
52.35 - return *this;
52.36 + if (idx >= path->length()) idx = -1;
52.37 + return *this;
52.38 }
52.39
52.40 /// \brief Comparison operator
52.41 @@ -284,13 +284,13 @@
52.42 /// Invalid constructor
52.43 ArcIt(Invalid) : path(0), idx(-1) {}
52.44 /// \brief Initializate the constructor to the first arc of path
52.45 - ArcIt(const SimplePath &_path)
52.46 + ArcIt(const SimplePath &_path)
52.47 : path(&_path), idx(_path.empty() ? -1 : 0) {}
52.48
52.49 private:
52.50
52.51 /// Constructor with starting point
52.52 - ArcIt(const SimplePath &_path, int _idx)
52.53 + ArcIt(const SimplePath &_path, int _idx)
52.54 : idx(_idx), path(&_path) {}
52.55
52.56 public:
52.57 @@ -301,10 +301,10 @@
52.58 }
52.59
52.60 /// Next arc
52.61 - ArcIt& operator++() {
52.62 + ArcIt& operator++() {
52.63 ++idx;
52.64 - if (idx >= path->length()) idx = -1;
52.65 - return *this;
52.66 + if (idx >= path->length()) idx = -1;
52.67 + return *this;
52.68 }
52.69
52.70 /// Comparison operator
52.71 @@ -413,7 +413,7 @@
52.72
52.73 protected:
52.74
52.75 - // the std::list<> is incompatible
52.76 + // the std::list<> is incompatible
52.77 // hard to create invalid iterator
52.78 struct Node {
52.79 Arc arc;
52.80 @@ -425,7 +425,7 @@
52.81 std::allocator<Node> alloc;
52.82
52.83 public:
52.84 -
52.85 +
52.86 /// \brief Default constructor
52.87 ///
52.88 /// Default constructor
52.89 @@ -470,12 +470,12 @@
52.90 /// Invalid constructor
52.91 ArcIt(Invalid) : path(0), node(0) {}
52.92 /// \brief Initializate the constructor to the first arc of path
52.93 - ArcIt(const ListPath &_path)
52.94 + ArcIt(const ListPath &_path)
52.95 : path(&_path), node(_path.first) {}
52.96
52.97 protected:
52.98
52.99 - ArcIt(const ListPath &_path, Node *_node)
52.100 + ArcIt(const ListPath &_path, Node *_node)
52.101 : path(&_path), node(_node) {}
52.102
52.103
52.104 @@ -487,9 +487,9 @@
52.105 }
52.106
52.107 /// Next arc
52.108 - ArcIt& operator++() {
52.109 + ArcIt& operator++() {
52.110 node = node->next;
52.111 - return *this;
52.112 + return *this;
52.113 }
52.114
52.115 /// Comparison operator
52.116 @@ -757,7 +757,7 @@
52.117 ///
52.118 /// Default constructor
52.119 StaticPath() : len(0), arcs(0) {}
52.120 -
52.121 +
52.122 /// \brief Template copy constructor
52.123 ///
52.124 /// This path can be initialized from any other path type.
52.125 @@ -796,13 +796,13 @@
52.126 /// Invalid constructor
52.127 ArcIt(Invalid) : path(0), idx(-1) {}
52.128 /// Initializate the constructor to the first arc of path
52.129 - ArcIt(const StaticPath &_path)
52.130 + ArcIt(const StaticPath &_path)
52.131 : path(&_path), idx(_path.empty() ? -1 : 0) {}
52.132
52.133 private:
52.134
52.135 /// Constructor with starting point
52.136 - ArcIt(const StaticPath &_path, int _idx)
52.137 + ArcIt(const StaticPath &_path, int _idx)
52.138 : idx(_idx), path(&_path) {}
52.139
52.140 public:
52.141 @@ -813,10 +813,10 @@
52.142 }
52.143
52.144 /// Next arc
52.145 - ArcIt& operator++() {
52.146 + ArcIt& operator++() {
52.147 ++idx;
52.148 - if (idx >= path->length()) idx = -1;
52.149 - return *this;
52.150 + if (idx >= path->length()) idx = -1;
52.151 + return *this;
52.152 }
52.153
52.154 /// Comparison operator
52.155 @@ -909,7 +909,7 @@
52.156
52.157 template <typename Path>
52.158 struct RevPathTagIndicator<
52.159 - Path,
52.160 + Path,
52.161 typename enable_if<typename Path::RevPathTag, void>::type
52.162 > {
52.163 static const bool value = true;
52.164 @@ -922,15 +922,15 @@
52.165
52.166 template <typename Path>
52.167 struct BuildTagIndicator<
52.168 - Path,
52.169 + Path,
52.170 typename enable_if<typename Path::BuildTag, void>::type
52.171 > {
52.172 static const bool value = true;
52.173 };
52.174
52.175 template <typename Target, typename Source,
52.176 - bool buildEnable = BuildTagIndicator<Target>::value,
52.177 - bool revEnable = RevPathTagIndicator<Source>::value>
52.178 + bool buildEnable = BuildTagIndicator<Target>::value,
52.179 + bool revEnable = RevPathTagIndicator<Source>::value>
52.180 struct PathCopySelector {
52.181 static void copy(Target& target, const Source& source) {
52.182 target.clear();
52.183 @@ -981,8 +981,8 @@
52.184 /// \brief Check the consistency of a path.
52.185 ///
52.186 /// This function checks that the target of each arc is the same
52.187 - /// as the source of the next one.
52.188 - ///
52.189 + /// as the source of the next one.
52.190 + ///
52.191 template <typename Digraph, typename Path>
52.192 bool checkPath(const Digraph& digraph, const Path& path) {
52.193 typename Path::ArcIt it(path);
52.194 @@ -1034,19 +1034,19 @@
52.195
52.196 typedef typename Path::Digraph Digraph;
52.197 typedef typename Digraph::Node Node;
52.198 -
52.199 +
52.200 /// Default constructor
52.201 PathNodeIt() {}
52.202 /// Invalid constructor
52.203 - PathNodeIt(Invalid)
52.204 + PathNodeIt(Invalid)
52.205 : _digraph(0), _it(INVALID), _nd(INVALID) {}
52.206 /// Constructor
52.207 - PathNodeIt(const Digraph& digraph, const Path& path)
52.208 + PathNodeIt(const Digraph& digraph, const Path& path)
52.209 : _digraph(&digraph), _it(path) {
52.210 _nd = (_it != INVALID ? _digraph->source(_it) : INVALID);
52.211 }
52.212 /// Constructor
52.213 - PathNodeIt(const Digraph& digraph, const Path& path, const Node& src)
52.214 + PathNodeIt(const Digraph& digraph, const Path& path, const Node& src)
52.215 : _digraph(&digraph), _it(path), _nd(src) {}
52.216
52.217 ///Conversion to Digraph::Node
52.218 @@ -1058,27 +1058,27 @@
52.219 PathNodeIt& operator++() {
52.220 if (_it == INVALID) _nd = INVALID;
52.221 else {
52.222 - _nd = _digraph->target(_it);
52.223 - ++_it;
52.224 + _nd = _digraph->target(_it);
52.225 + ++_it;
52.226 }
52.227 return *this;
52.228 }
52.229
52.230 /// Comparison operator
52.231 - bool operator==(const PathNodeIt& n) const {
52.232 - return _it == n._it && _nd == n._nd;
52.233 + bool operator==(const PathNodeIt& n) const {
52.234 + return _it == n._it && _nd == n._nd;
52.235 }
52.236 /// Comparison operator
52.237 - bool operator!=(const PathNodeIt& n) const {
52.238 - return _it != n._it || _nd != n._nd;
52.239 + bool operator!=(const PathNodeIt& n) const {
52.240 + return _it != n._it || _nd != n._nd;
52.241 }
52.242 /// Comparison operator
52.243 - bool operator<(const PathNodeIt& n) const {
52.244 + bool operator<(const PathNodeIt& n) const {
52.245 return (_it < n._it && _nd != INVALID);
52.246 }
52.247 -
52.248 +
52.249 };
52.250 -
52.251 +
52.252 ///@}
52.253
52.254 } // namespace lemon
53.1 --- a/lemon/random.cc Sun Jul 13 16:46:56 2008 +0100
53.2 +++ b/lemon/random.cc Sun Jul 13 19:51:02 2008 +0100
53.3 @@ -1,6 +1,6 @@
53.4 -/* -*- C++ -*-
53.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
53.6 *
53.7 - * This file is a part of LEMON, a generic C++ optimization library
53.8 + * This file is a part of LEMON, a generic C++ optimization library.
53.9 *
53.10 * Copyright (C) 2003-2008
53.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
54.1 --- a/lemon/random.h Sun Jul 13 16:46:56 2008 +0100
54.2 +++ b/lemon/random.h Sun Jul 13 19:51:02 2008 +0100
54.3 @@ -1,6 +1,6 @@
54.4 -/* -*- C++ -*-
54.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
54.6 *
54.7 - * This file is a part of LEMON, a generic C++ optimization library
54.8 + * This file is a part of LEMON, a generic C++ optimization library.
54.9 *
54.10 * Copyright (C) 2003-2008
54.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
54.12 @@ -21,9 +21,9 @@
54.13 * Generator of Matsumoto and Nishimura.
54.14 *
54.15 * See the appropriate copyright notice below.
54.16 - *
54.17 + *
54.18 * Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
54.19 - * All rights reserved.
54.20 + * All rights reserved.
54.21 *
54.22 * Redistribution and use in source and binary forms, with or without
54.23 * modification, are permitted provided that the following conditions
54.24 @@ -36,8 +36,8 @@
54.25 * notice, this list of conditions and the following disclaimer in the
54.26 * documentation and/or other materials provided with the distribution.
54.27 *
54.28 - * 3. The names of its contributors may not be used to endorse or promote
54.29 - * products derived from this software without specific prior written
54.30 + * 3. The names of its contributors may not be used to endorse or promote
54.31 + * products derived from this software without specific prior written
54.32 * permission.
54.33 *
54.34 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
54.35 @@ -87,7 +87,7 @@
54.36 namespace lemon {
54.37
54.38 namespace _random_bits {
54.39 -
54.40 +
54.41 template <typename _Word, int _bits = std::numeric_limits<_Word>::digits>
54.42 struct RandomTraits {};
54.43
54.44 @@ -99,7 +99,7 @@
54.45
54.46 static const int length = 624;
54.47 static const int shift = 397;
54.48 -
54.49 +
54.50 static const Word mul = 0x6c078965u;
54.51 static const Word arrayInit = 0x012BD6AAu;
54.52 static const Word arrayMul1 = 0x0019660Du;
54.53 @@ -167,7 +167,7 @@
54.54 static const Word seedArray[4] = {
54.55 0x12345u, 0x23456u, 0x34567u, 0x45678u
54.56 };
54.57 -
54.58 +
54.59 initState(seedArray, seedArray + 4);
54.60 }
54.61
54.62 @@ -175,7 +175,7 @@
54.63
54.64 static const Word mul = RandomTraits<Word>::mul;
54.65
54.66 - current = state;
54.67 + current = state;
54.68
54.69 Word *curr = state + length - 1;
54.70 curr[0] = seed; --curr;
54.71 @@ -201,7 +201,7 @@
54.72
54.73 num = length > end - begin ? length : end - begin;
54.74 while (num--) {
54.75 - curr[0] = (curr[0] ^ ((curr[1] ^ (curr[1] >> (bits - 2))) * mul1))
54.76 + curr[0] = (curr[0] ^ ((curr[1] ^ (curr[1] >> (bits - 2))) * mul1))
54.77 + *it + cnt;
54.78 ++it; ++cnt;
54.79 if (it == end) {
54.80 @@ -223,10 +223,10 @@
54.81 cnt = 1;
54.82 }
54.83 }
54.84 -
54.85 +
54.86 state[length - 1] = Word(1) << (bits - 1);
54.87 }
54.88 -
54.89 +
54.90 void copyState(const RandomCore& other) {
54.91 std::copy(other.state, other.state + length, state);
54.92 current = state + (other.current - other.state);
54.93 @@ -241,17 +241,17 @@
54.94
54.95 private:
54.96
54.97 -
54.98 +
54.99 void fillState() {
54.100 static const Word mask[2] = { 0x0ul, RandomTraits<Word>::mask };
54.101 static const Word loMask = RandomTraits<Word>::loMask;
54.102 static const Word hiMask = RandomTraits<Word>::hiMask;
54.103
54.104 - current = state + length;
54.105 + current = state + length;
54.106
54.107 register Word *curr = state + length - 1;
54.108 register long num;
54.109 -
54.110 +
54.111 num = length - shift;
54.112 while (num--) {
54.113 curr[0] = (((curr[0] & hiMask) | (curr[-1] & loMask)) >> 1) ^
54.114 @@ -269,14 +269,14 @@
54.115
54.116 }
54.117
54.118 -
54.119 +
54.120 Word *current;
54.121 Word state[length];
54.122 -
54.123 +
54.124 };
54.125
54.126
54.127 - template <typename Result,
54.128 + template <typename Result,
54.129 int shift = (std::numeric_limits<Result>::digits + 1) / 2>
54.130 struct Masker {
54.131 static Result mask(const Result& result) {
54.132 @@ -284,7 +284,7 @@
54.133 mask(static_cast<Result>(result | (result >> shift)));
54.134 }
54.135 };
54.136 -
54.137 +
54.138 template <typename Result>
54.139 struct Masker<Result, 1> {
54.140 static Result mask(const Result& result) {
54.141 @@ -292,39 +292,39 @@
54.142 }
54.143 };
54.144
54.145 - template <typename Result, typename Word,
54.146 - int rest = std::numeric_limits<Result>::digits, int shift = 0,
54.147 + template <typename Result, typename Word,
54.148 + int rest = std::numeric_limits<Result>::digits, int shift = 0,
54.149 bool last = rest <= std::numeric_limits<Word>::digits>
54.150 struct IntConversion {
54.151 static const int bits = std::numeric_limits<Word>::digits;
54.152 -
54.153 +
54.154 static Result convert(RandomCore<Word>& rnd) {
54.155 return static_cast<Result>(rnd() >> (bits - rest)) << shift;
54.156 }
54.157 -
54.158 - };
54.159
54.160 - template <typename Result, typename Word, int rest, int shift>
54.161 + };
54.162 +
54.163 + template <typename Result, typename Word, int rest, int shift>
54.164 struct IntConversion<Result, Word, rest, shift, false> {
54.165 static const int bits = std::numeric_limits<Word>::digits;
54.166
54.167 static Result convert(RandomCore<Word>& rnd) {
54.168 - return (static_cast<Result>(rnd()) << shift) |
54.169 + return (static_cast<Result>(rnd()) << shift) |
54.170 IntConversion<Result, Word, rest - bits, shift + bits>::convert(rnd);
54.171 }
54.172 };
54.173
54.174
54.175 template <typename Result, typename Word,
54.176 - bool one_word = (std::numeric_limits<Word>::digits <
54.177 - std::numeric_limits<Result>::digits) >
54.178 + bool one_word = (std::numeric_limits<Word>::digits <
54.179 + std::numeric_limits<Result>::digits) >
54.180 struct Mapping {
54.181 static Result map(RandomCore<Word>& rnd, const Result& bound) {
54.182 Word max = Word(bound - 1);
54.183 Result mask = Masker<Result>::mask(bound - 1);
54.184 Result num;
54.185 do {
54.186 - num = IntConversion<Result, Word>::convert(rnd) & mask;
54.187 + num = IntConversion<Result, Word>::convert(rnd) & mask;
54.188 } while (num > max);
54.189 return num;
54.190 }
54.191 @@ -350,7 +350,7 @@
54.192 Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
54.193 res *= res;
54.194 if ((exp & 1) == 1) res *= static_cast<Result>(2.0);
54.195 - return res;
54.196 + return res;
54.197 }
54.198 };
54.199
54.200 @@ -360,42 +360,42 @@
54.201 Result res = ShiftMultiplier<Result, exp / 2>::multiplier();
54.202 res *= res;
54.203 if ((exp & 1) == 1) res *= static_cast<Result>(0.5);
54.204 - return res;
54.205 + return res;
54.206 }
54.207 };
54.208
54.209 template <typename Result>
54.210 struct ShiftMultiplier<Result, 0, true> {
54.211 static const Result multiplier() {
54.212 - return static_cast<Result>(1.0);
54.213 + return static_cast<Result>(1.0);
54.214 }
54.215 };
54.216
54.217 template <typename Result>
54.218 struct ShiftMultiplier<Result, -20, true> {
54.219 static const Result multiplier() {
54.220 - return static_cast<Result>(1.0/1048576.0);
54.221 + return static_cast<Result>(1.0/1048576.0);
54.222 }
54.223 };
54.224 -
54.225 +
54.226 template <typename Result>
54.227 struct ShiftMultiplier<Result, -32, true> {
54.228 static const Result multiplier() {
54.229 - return static_cast<Result>(1.0/424967296.0);
54.230 + return static_cast<Result>(1.0/424967296.0);
54.231 }
54.232 };
54.233
54.234 template <typename Result>
54.235 struct ShiftMultiplier<Result, -53, true> {
54.236 static const Result multiplier() {
54.237 - return static_cast<Result>(1.0/9007199254740992.0);
54.238 + return static_cast<Result>(1.0/9007199254740992.0);
54.239 }
54.240 };
54.241
54.242 template <typename Result>
54.243 struct ShiftMultiplier<Result, -64, true> {
54.244 static const Result multiplier() {
54.245 - return static_cast<Result>(1.0/18446744073709551616.0);
54.246 + return static_cast<Result>(1.0/18446744073709551616.0);
54.247 }
54.248 };
54.249
54.250 @@ -407,9 +407,9 @@
54.251 };
54.252
54.253 template <typename Result, typename Word,
54.254 - int rest = std::numeric_limits<Result>::digits, int shift = 0,
54.255 + int rest = std::numeric_limits<Result>::digits, int shift = 0,
54.256 bool last = rest <= std::numeric_limits<Word>::digits>
54.257 - struct RealConversion{
54.258 + struct RealConversion{
54.259 static const int bits = std::numeric_limits<Word>::digits;
54.260
54.261 static Result convert(RandomCore<Word>& rnd) {
54.262 @@ -419,7 +419,7 @@
54.263 };
54.264
54.265 template <typename Result, typename Word, int rest, int shift>
54.266 - struct RealConversion<Result, Word, rest, shift, false> {
54.267 + struct RealConversion<Result, Word, rest, shift, false> {
54.268 static const int bits = std::numeric_limits<Word>::digits;
54.269
54.270 static Result convert(RandomCore<Word>& rnd) {
54.271 @@ -458,7 +458,7 @@
54.272 struct BoolProducer {
54.273 Word buffer;
54.274 int num;
54.275 -
54.276 +
54.277 BoolProducer() : num(0) {}
54.278
54.279 bool convert(RandomCore<Word>& rnd) {
54.280 @@ -529,10 +529,10 @@
54.281
54.282 // Architecture word
54.283 typedef unsigned long Word;
54.284 -
54.285 +
54.286 _random_bits::RandomCore<Word> core;
54.287 _random_bits::BoolProducer<Word> bool_producer;
54.288 -
54.289 +
54.290
54.291 public:
54.292
54.293 @@ -554,7 +554,7 @@
54.294 /// Constructor with seed. The current number type will be converted
54.295 /// to the architecture word type.
54.296 template <typename Number>
54.297 - Random(Number seed) {
54.298 + Random(Number seed) {
54.299 _random_bits::Initializer<Number, Word>::init(core, seed);
54.300 }
54.301
54.302 @@ -564,7 +564,7 @@
54.303 /// any number type and the numbers will be converted to the
54.304 /// architecture word type.
54.305 template <typename Iterator>
54.306 - Random(Iterator begin, Iterator end) {
54.307 + Random(Iterator begin, Iterator end) {
54.308 typedef typename std::iterator_traits<Iterator>::value_type Number;
54.309 _random_bits::Initializer<Number, Word>::init(core, begin, end);
54.310 }
54.311 @@ -597,7 +597,7 @@
54.312 /// Seeding the random sequence. The current number type will be
54.313 /// converted to the architecture word type.
54.314 template <typename Number>
54.315 - void seed(Number seed) {
54.316 + void seed(Number seed) {
54.317 _random_bits::Initializer<Number, Word>::init(core, seed);
54.318 }
54.319
54.320 @@ -607,7 +607,7 @@
54.321 /// any number type and the numbers will be converted to the
54.322 /// architecture word type.
54.323 template <typename Iterator>
54.324 - void seed(Iterator begin, Iterator end) {
54.325 + void seed(Iterator begin, Iterator end) {
54.326 typedef typename std::iterator_traits<Iterator>::value_type Number;
54.327 _random_bits::Initializer<Number, Word>::init(core, begin, end);
54.328 }
54.329 @@ -625,7 +625,7 @@
54.330 if (seedFromTime()) return true;
54.331 return false;
54.332 }
54.333 -
54.334 +
54.335 /// \brief Seeding from file
54.336 ///
54.337 /// Seeding the random sequence from file. The linux kernel has two
54.338 @@ -640,9 +640,9 @@
54.339 /// \param offset The offset, from the file read.
54.340 /// \return True when the seeding successes.
54.341 #ifndef WIN32
54.342 - bool seedFromFile(const std::string& file = "/dev/urandom", int offset = 0)
54.343 + bool seedFromFile(const std::string& file = "/dev/urandom", int offset = 0)
54.344 #else
54.345 - bool seedFromFile(const std::string& file = "", int offset = 0)
54.346 + bool seedFromFile(const std::string& file = "", int offset = 0)
54.347 #endif
54.348 {
54.349 std::ifstream rs(file.c_str());
54.350 @@ -660,7 +660,7 @@
54.351 /// current process id and the current time for initialize the
54.352 /// random sequence.
54.353 /// \return Currently always true.
54.354 - bool seedFromTime() {
54.355 + bool seedFromTime() {
54.356 #ifndef WIN32
54.357 timeval tv;
54.358 gettimeofday(&tv, 0);
54.359 @@ -696,16 +696,16 @@
54.360 ///
54.361 /// It returns a random real number from the range [0, b).
54.362 template <typename Number>
54.363 - Number real(Number b) {
54.364 - return real<Number>() * b;
54.365 + Number real(Number b) {
54.366 + return real<Number>() * b;
54.367 }
54.368
54.369 /// \brief Returns a random real number from the range [a, b)
54.370 ///
54.371 /// It returns a random real number from the range [a, b).
54.372 template <typename Number>
54.373 - Number real(Number a, Number b) {
54.374 - return real<Number>() * (b - a) + a;
54.375 + Number real(Number a, Number b) {
54.376 + return real<Number>() * (b - a) + a;
54.377 }
54.378
54.379 /// @}
54.380 @@ -725,16 +725,16 @@
54.381 ///
54.382 /// It returns a random real number from the range [0, b).
54.383 template <typename Number>
54.384 - Number operator()(Number b) {
54.385 - return real<Number>() * b;
54.386 + Number operator()(Number b) {
54.387 + return real<Number>() * b;
54.388 }
54.389
54.390 /// \brief Returns a random real number from the range [a, b)
54.391 ///
54.392 /// It returns a random real number from the range [a, b).
54.393 template <typename Number>
54.394 - Number operator()(Number a, Number b) {
54.395 - return real<Number>() * (b - a) + a;
54.396 + Number operator()(Number a, Number b) {
54.397 + return real<Number>() * (b - a) + a;
54.398 }
54.399
54.400 /// \brief Returns a random integer from a range
54.401 @@ -784,7 +784,7 @@
54.402 /// function is \c int.
54.403 template <typename Number>
54.404 Number integer() {
54.405 - static const int nb = std::numeric_limits<Number>::digits +
54.406 + static const int nb = std::numeric_limits<Number>::digits +
54.407 (std::numeric_limits<Number>::is_signed ? 1 : 0);
54.408 return _random_bits::IntConversion<Number, Word, nb>::convert(core);
54.409 }
54.410 @@ -792,7 +792,7 @@
54.411 int integer() {
54.412 return integer<int>();
54.413 }
54.414 -
54.415 +
54.416 /// \brief Returns a random bool
54.417 ///
54.418 /// It returns a random bool. The generator holds a buffer for
54.419 @@ -806,9 +806,9 @@
54.420
54.421 ///\name Non-uniform distributions
54.422 ///
54.423 -
54.424 +
54.425 ///@{
54.426 -
54.427 +
54.428 /// \brief Returns a random bool
54.429 ///
54.430 /// It returns a random bool with given probability of true result.
54.431 @@ -822,13 +822,13 @@
54.432 /// \note The Cartesian form of the Box-Muller
54.433 /// transformation is used to generate a random normal distribution.
54.434 /// \todo Consider using the "ziggurat" method instead.
54.435 - double gauss()
54.436 + double gauss()
54.437 {
54.438 double V1,V2,S;
54.439 do {
54.440 - V1=2*real<double>()-1;
54.441 - V2=2*real<double>()-1;
54.442 - S=V1*V1+V2*V2;
54.443 + V1=2*real<double>()-1;
54.444 + V2=2*real<double>()-1;
54.445 + S=V1*V1+V2*V2;
54.446 } while(S>=1);
54.447 return std::sqrt(-2*std::log(S)/S)*V1;
54.448 }
54.449 @@ -854,19 +854,19 @@
54.450 /// Gamma distribution with given integer shape
54.451
54.452 /// This function generates a gamma distribution random number.
54.453 - ///
54.454 + ///
54.455 ///\param k shape parameter (<tt>k>0</tt> integer)
54.456 - double gamma(int k)
54.457 + double gamma(int k)
54.458 {
54.459 double s = 0;
54.460 for(int i=0;i<k;i++) s-=std::log(1.0-real<double>());
54.461 return s;
54.462 }
54.463 -
54.464 +
54.465 /// Gamma distribution with given shape and scale parameter
54.466
54.467 /// This function generates a gamma distribution random number.
54.468 - ///
54.469 + ///
54.470 ///\param k shape parameter (<tt>k>0</tt>)
54.471 ///\param theta scale parameter
54.472 ///
54.473 @@ -876,88 +876,88 @@
54.474 const double delta = k-std::floor(k);
54.475 const double v0=E/(E-delta);
54.476 do {
54.477 - double V0=1.0-real<double>();
54.478 - double V1=1.0-real<double>();
54.479 - double V2=1.0-real<double>();
54.480 - if(V2<=v0)
54.481 - {
54.482 - xi=std::pow(V1,1.0/delta);
54.483 - nu=V0*std::pow(xi,delta-1.0);
54.484 - }
54.485 - else
54.486 - {
54.487 - xi=1.0-std::log(V1);
54.488 - nu=V0*std::exp(-xi);
54.489 - }
54.490 + double V0=1.0-real<double>();
54.491 + double V1=1.0-real<double>();
54.492 + double V2=1.0-real<double>();
54.493 + if(V2<=v0)
54.494 + {
54.495 + xi=std::pow(V1,1.0/delta);
54.496 + nu=V0*std::pow(xi,delta-1.0);
54.497 + }
54.498 + else
54.499 + {
54.500 + xi=1.0-std::log(V1);
54.501 + nu=V0*std::exp(-xi);
54.502 + }
54.503 } while(nu>std::pow(xi,delta-1.0)*std::exp(-xi));
54.504 return theta*(xi+gamma(int(std::floor(k))));
54.505 }
54.506 -
54.507 +
54.508 /// Weibull distribution
54.509
54.510 /// This function generates a Weibull distribution random number.
54.511 - ///
54.512 + ///
54.513 ///\param k shape parameter (<tt>k>0</tt>)
54.514 ///\param lambda scale parameter (<tt>lambda>0</tt>)
54.515 ///
54.516 double weibull(double k,double lambda)
54.517 {
54.518 return lambda*pow(-std::log(1.0-real<double>()),1.0/k);
54.519 - }
54.520 -
54.521 + }
54.522 +
54.523 /// Pareto distribution
54.524
54.525 /// This function generates a Pareto distribution random number.
54.526 - ///
54.527 + ///
54.528 ///\param k shape parameter (<tt>k>0</tt>)
54.529 ///\param x_min location parameter (<tt>x_min>0</tt>)
54.530 ///
54.531 double pareto(double k,double x_min)
54.532 {
54.533 return exponential(gamma(k,1.0/x_min))+x_min;
54.534 - }
54.535 -
54.536 + }
54.537 +
54.538 /// Poisson distribution
54.539
54.540 /// This function generates a Poisson distribution random number with
54.541 /// parameter \c lambda.
54.542 - ///
54.543 + ///
54.544 /// The probability mass function of this distribusion is
54.545 /// \f[ \frac{e^{-\lambda}\lambda^k}{k!} \f]
54.546 /// \note The algorithm is taken from the book of Donald E. Knuth titled
54.547 /// ''Seminumerical Algorithms'' (1969). Its running time is linear in the
54.548 /// return value.
54.549 -
54.550 +
54.551 int poisson(double lambda)
54.552 {
54.553 const double l = std::exp(-lambda);
54.554 int k=0;
54.555 double p = 1.0;
54.556 do {
54.557 - k++;
54.558 - p*=real<double>();
54.559 + k++;
54.560 + p*=real<double>();
54.561 } while (p>=l);
54.562 return k-1;
54.563 - }
54.564 -
54.565 + }
54.566 +
54.567 ///@}
54.568 -
54.569 +
54.570 ///\name Two dimensional distributions
54.571 ///
54.572
54.573 ///@{
54.574 -
54.575 +
54.576 /// Uniform distribution on the full unit circle
54.577
54.578 /// Uniform distribution on the full unit circle.
54.579 ///
54.580 - dim2::Point<double> disc()
54.581 + dim2::Point<double> disc()
54.582 {
54.583 double V1,V2;
54.584 do {
54.585 - V1=2*real<double>()-1;
54.586 - V2=2*real<double>()-1;
54.587 -
54.588 + V1=2*real<double>()-1;
54.589 + V2=2*real<double>()-1;
54.590 +
54.591 } while(V1*V1+V2*V2>=1);
54.592 return dim2::Point<double>(V1,V2);
54.593 }
54.594 @@ -973,9 +973,9 @@
54.595 {
54.596 double V1,V2,S;
54.597 do {
54.598 - V1=2*real<double>()-1;
54.599 - V2=2*real<double>()-1;
54.600 - S=V1*V1+V2*V2;
54.601 + V1=2*real<double>()-1;
54.602 + V2=2*real<double>()-1;
54.603 + S=V1*V1+V2*V2;
54.604 } while(S>=1);
54.605 double W=std::sqrt(-2*std::log(S)/S);
54.606 return dim2::Point<double>(W*V1,W*V2);
54.607 @@ -984,22 +984,22 @@
54.608
54.609 /// This function provides a turning symmetric two-dimensional distribution.
54.610 /// The x-coordinate is of conditionally exponential distribution
54.611 - /// with the condition that x is positive and y=0. If x is negative and
54.612 + /// with the condition that x is positive and y=0. If x is negative and
54.613 /// y=0 then, -x is of exponential distribution. The same is true for the
54.614 /// y-coordinate.
54.615 - dim2::Point<double> exponential2()
54.616 + dim2::Point<double> exponential2()
54.617 {
54.618 double V1,V2,S;
54.619 do {
54.620 - V1=2*real<double>()-1;
54.621 - V2=2*real<double>()-1;
54.622 - S=V1*V1+V2*V2;
54.623 + V1=2*real<double>()-1;
54.624 + V2=2*real<double>()-1;
54.625 + S=V1*V1+V2*V2;
54.626 } while(S>=1);
54.627 double W=-std::log(S)/S;
54.628 return dim2::Point<double>(W*V1,W*V2);
54.629 }
54.630
54.631 - ///@}
54.632 + ///@}
54.633 };
54.634
54.635
55.1 --- a/lemon/smart_graph.h Sun Jul 13 16:46:56 2008 +0100
55.2 +++ b/lemon/smart_graph.h Sun Jul 13 19:51:02 2008 +0100
55.3 @@ -1,6 +1,6 @@
55.4 -/* -*- C++ -*-
55.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
55.6 *
55.7 - * This file is a part of LEMON, a generic C++ optimization library
55.8 + * This file is a part of LEMON, a generic C++ optimization library.
55.9 *
55.10 * Copyright (C) 2003-2008
55.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
55.12 @@ -45,20 +45,20 @@
55.13 class SmartDigraphBase {
55.14 protected:
55.15
55.16 - struct NodeT
55.17 + struct NodeT
55.18 {
55.19 - int first_in, first_out;
55.20 + int first_in, first_out;
55.21 NodeT() {}
55.22 };
55.23 - struct ArcT
55.24 + struct ArcT
55.25 {
55.26 - int target, source, next_in, next_out;
55.27 - ArcT() {}
55.28 + int target, source, next_in, next_out;
55.29 + ArcT() {}
55.30 };
55.31
55.32 std::vector<NodeT> nodes;
55.33 std::vector<ArcT> arcs;
55.34 -
55.35 +
55.36 public:
55.37
55.38 typedef SmartDigraphBase Graph;
55.39 @@ -69,9 +69,9 @@
55.40 public:
55.41
55.42 SmartDigraphBase() : nodes(), arcs() { }
55.43 - SmartDigraphBase(const SmartDigraphBase &_g)
55.44 + SmartDigraphBase(const SmartDigraphBase &_g)
55.45 : nodes(_g.nodes), arcs(_g.arcs) { }
55.46 -
55.47 +
55.48 typedef True NodeNumTag;
55.49 typedef True EdgeNumTag;
55.50
55.51 @@ -82,17 +82,17 @@
55.52 int maxArcId() const { return arcs.size()-1; }
55.53
55.54 Node addNode() {
55.55 - int n = nodes.size();
55.56 + int n = nodes.size();
55.57 nodes.push_back(NodeT());
55.58 nodes[n].first_in = -1;
55.59 nodes[n].first_out = -1;
55.60 return Node(n);
55.61 }
55.62 -
55.63 +
55.64 Arc addArc(Node u, Node v) {
55.65 - int n = arcs.size();
55.66 + int n = arcs.size();
55.67 arcs.push_back(ArcT());
55.68 - arcs[n].source = u._id;
55.69 + arcs[n].source = u._id;
55.70 arcs[n].target = v._id;
55.71 arcs[n].next_out = nodes[u._id].first_out;
55.72 arcs[n].next_in = nodes[v._id].first_in;
55.73 @@ -115,11 +115,11 @@
55.74 static Node nodeFromId(int id) { return Node(id);}
55.75 static Arc arcFromId(int id) { return Arc(id);}
55.76
55.77 - bool valid(Node n) const {
55.78 - return n._id >= 0 && n._id < static_cast<int>(nodes.size());
55.79 + bool valid(Node n) const {
55.80 + return n._id >= 0 && n._id < static_cast<int>(nodes.size());
55.81 }
55.82 - bool valid(Arc a) const {
55.83 - return a._id >= 0 && a._id < static_cast<int>(arcs.size());
55.84 + bool valid(Arc a) const {
55.85 + return a._id >= 0 && a._id < static_cast<int>(arcs.size());
55.86 }
55.87
55.88 class Node {
55.89 @@ -136,7 +136,7 @@
55.90 bool operator!=(const Node i) const {return _id != i._id;}
55.91 bool operator<(const Node i) const {return _id < i._id;}
55.92 };
55.93 -
55.94 +
55.95
55.96 class Arc {
55.97 friend class SmartDigraphBase;
55.98 @@ -180,7 +180,7 @@
55.99 void firstIn(Arc& arc, const Node& node) const {
55.100 arc._id = nodes[node._id].first_in;
55.101 }
55.102 -
55.103 +
55.104 void nextIn(Arc& arc) const {
55.105 arc._id = arcs[arc._id].next_in;
55.106 }
55.107 @@ -222,26 +222,26 @@
55.108 void operator=(const SmartDigraph &) {}
55.109
55.110 public:
55.111 -
55.112 +
55.113 /// Constructor
55.114 -
55.115 +
55.116 /// Constructor.
55.117 ///
55.118 SmartDigraph() {};
55.119 -
55.120 +
55.121 ///Add a new node to the digraph.
55.122 -
55.123 +
55.124 /// \return the new node.
55.125 ///
55.126 Node addNode() { return Parent::addNode(); }
55.127 -
55.128 +
55.129 ///Add a new arc to the digraph.
55.130 -
55.131 +
55.132 ///Add a new arc to the digraph with source node \c s
55.133 ///and target node \c t.
55.134 ///\return the new arc.
55.135 - Arc addArc(const Node& s, const Node& t) {
55.136 - return Parent::addArc(s, t);
55.137 + Arc addArc(const Node& s, const Node& t) {
55.138 + return Parent::addArc(s, t);
55.139 }
55.140
55.141 /// \brief Using this it is possible to avoid the superfluous memory
55.142 @@ -269,7 +269,7 @@
55.143 /// \brief Node validity check
55.144 ///
55.145 /// This function gives back true if the given node is valid,
55.146 - /// ie. it is a real node of the graph.
55.147 + /// ie. it is a real node of the graph.
55.148 ///
55.149 /// \warning A removed node (using Snapshot) could become valid again
55.150 /// when new nodes are added to the graph.
55.151 @@ -278,14 +278,14 @@
55.152 /// \brief Arc validity check
55.153 ///
55.154 /// This function gives back true if the given arc is valid,
55.155 - /// ie. it is a real arc of the graph.
55.156 + /// ie. it is a real arc of the graph.
55.157 ///
55.158 /// \warning A removed arc (using Snapshot) could become valid again
55.159 /// when new arcs are added to the graph.
55.160 bool valid(Arc a) const { return Parent::valid(a); }
55.161
55.162 ///Clear the digraph.
55.163 -
55.164 +
55.165 ///Erase all the nodes and arcs from the digraph.
55.166 ///
55.167 void clear() {
55.168 @@ -293,7 +293,7 @@
55.169 }
55.170
55.171 ///Split a node.
55.172 -
55.173 +
55.174 ///This function splits a node. First a new node is added to the digraph,
55.175 ///then the source of each outgoing arc of \c n is moved to this new node.
55.176 ///If \c connect is \c true (this is the default value), then a new arc
55.177 @@ -318,7 +318,7 @@
55.178 }
55.179
55.180 public:
55.181 -
55.182 +
55.183 class Snapshot;
55.184
55.185 protected:
55.186 @@ -327,17 +327,17 @@
55.187 {
55.188 while(s.arc_num<arcs.size()) {
55.189 Arc arc = arcFromId(arcs.size()-1);
55.190 - Parent::notifier(Arc()).erase(arc);
55.191 - nodes[arcs.back().source].first_out=arcs.back().next_out;
55.192 - nodes[arcs.back().target].first_in=arcs.back().next_in;
55.193 - arcs.pop_back();
55.194 + Parent::notifier(Arc()).erase(arc);
55.195 + nodes[arcs.back().source].first_out=arcs.back().next_out;
55.196 + nodes[arcs.back().target].first_in=arcs.back().next_in;
55.197 + arcs.pop_back();
55.198 }
55.199 while(s.node_num<nodes.size()) {
55.200 Node node = nodeFromId(nodes.size()-1);
55.201 - Parent::notifier(Node()).erase(node);
55.202 - nodes.pop_back();
55.203 + Parent::notifier(Node()).erase(node);
55.204 + nodes.pop_back();
55.205 }
55.206 - }
55.207 + }
55.208
55.209 public:
55.210
55.211 @@ -355,7 +355,7 @@
55.212 ///either broken program, invalid state of the digraph, valid but
55.213 ///not the restored digraph or no change. Because the runtime performance
55.214 ///the validity of the snapshot is not stored.
55.215 - class Snapshot
55.216 + class Snapshot
55.217 {
55.218 SmartDigraph *_graph;
55.219 protected:
55.220 @@ -364,18 +364,18 @@
55.221 unsigned int arc_num;
55.222 public:
55.223 ///Default constructor.
55.224 -
55.225 +
55.226 ///Default constructor.
55.227 ///To actually make a snapshot you must call save().
55.228 ///
55.229 Snapshot() : _graph(0) {}
55.230 ///Constructor that immediately makes a snapshot
55.231 -
55.232 +
55.233 ///This constructor immediately makes a snapshot of the digraph.
55.234 ///\param _g The digraph we make a snapshot of.
55.235 Snapshot(SmartDigraph &graph) : _graph(&graph) {
55.236 - node_num=_graph->nodes.size();
55.237 - arc_num=_graph->arcs.size();
55.238 + node_num=_graph->nodes.size();
55.239 + arc_num=_graph->arcs.size();
55.240 }
55.241
55.242 ///Make a snapshot.
55.243 @@ -385,15 +385,15 @@
55.244 ///This function can be called more than once. In case of a repeated
55.245 ///call, the previous snapshot gets lost.
55.246 ///\param _g The digraph we make the snapshot of.
55.247 - void save(SmartDigraph &graph)
55.248 + void save(SmartDigraph &graph)
55.249 {
55.250 - _graph=&graph;
55.251 - node_num=_graph->nodes.size();
55.252 - arc_num=_graph->arcs.size();
55.253 + _graph=&graph;
55.254 + node_num=_graph->nodes.size();
55.255 + arc_num=_graph->arcs.size();
55.256 }
55.257
55.258 ///Undo the changes until a snapshot.
55.259 -
55.260 +
55.261 ///Undo the changes until a snapshot created by save().
55.262 ///
55.263 ///\note After you restored a state, you cannot restore
55.264 @@ -401,7 +401,7 @@
55.265 ///by restore().
55.266 void restore()
55.267 {
55.268 - _graph->restoreSnapshot(*this);
55.269 + _graph->restoreSnapshot(*this);
55.270 }
55.271 };
55.272 };
55.273 @@ -414,7 +414,7 @@
55.274 struct NodeT {
55.275 int first_out;
55.276 };
55.277 -
55.278 +
55.279 struct ArcT {
55.280 int target;
55.281 int next_out;
55.282 @@ -424,15 +424,15 @@
55.283 std::vector<ArcT> arcs;
55.284
55.285 int first_free_arc;
55.286 -
55.287 +
55.288 public:
55.289 -
55.290 +
55.291 typedef SmartGraphBase Digraph;
55.292
55.293 class Node;
55.294 class Arc;
55.295 class Edge;
55.296 -
55.297 +
55.298 class Node {
55.299 friend class SmartGraphBase;
55.300 protected:
55.301 @@ -485,8 +485,8 @@
55.302 SmartGraphBase()
55.303 : nodes(), arcs() {}
55.304
55.305 -
55.306 - int maxNodeId() const { return nodes.size()-1; }
55.307 +
55.308 + int maxNodeId() const { return nodes.size()-1; }
55.309 int maxEdgeId() const { return arcs.size() / 2 - 1; }
55.310 int maxArcId() const { return arcs.size()-1; }
55.311
55.312 @@ -504,7 +504,7 @@
55.313 return Arc(e._id * 2 + (d ? 1 : 0));
55.314 }
55.315
55.316 - void first(Node& node) const {
55.317 + void first(Node& node) const {
55.318 node._id = nodes.size() - 1;
55.319 }
55.320
55.321 @@ -512,7 +512,7 @@
55.322 --node._id;
55.323 }
55.324
55.325 - void first(Arc& arc) const {
55.326 + void first(Arc& arc) const {
55.327 arc._id = arcs.size() - 1;
55.328 }
55.329
55.330 @@ -520,7 +520,7 @@
55.331 --arc._id;
55.332 }
55.333
55.334 - void first(Edge& arc) const {
55.335 + void first(Edge& arc) const {
55.336 arc._id = arcs.size() / 2 - 1;
55.337 }
55.338
55.339 @@ -561,10 +561,10 @@
55.340 d = ((de & 1) == 1);
55.341 } else {
55.342 arc._id = -1;
55.343 - d = true;
55.344 + d = true;
55.345 }
55.346 }
55.347 -
55.348 +
55.349 static int id(Node v) { return v._id; }
55.350 static int id(Arc e) { return e._id; }
55.351 static int id(Edge e) { return e._id; }
55.352 @@ -573,41 +573,41 @@
55.353 static Arc arcFromId(int id) { return Arc(id);}
55.354 static Edge edgeFromId(int id) { return Edge(id);}
55.355
55.356 - bool valid(Node n) const {
55.357 - return n._id >= 0 && n._id < static_cast<int>(nodes.size());
55.358 + bool valid(Node n) const {
55.359 + return n._id >= 0 && n._id < static_cast<int>(nodes.size());
55.360 }
55.361 - bool valid(Arc a) const {
55.362 + bool valid(Arc a) const {
55.363 return a._id >= 0 && a._id < static_cast<int>(arcs.size());
55.364 }
55.365 - bool valid(Edge e) const {
55.366 - return e._id >= 0 && 2 * e._id < static_cast<int>(arcs.size());
55.367 + bool valid(Edge e) const {
55.368 + return e._id >= 0 && 2 * e._id < static_cast<int>(arcs.size());
55.369 }
55.370
55.371 - Node addNode() {
55.372 + Node addNode() {
55.373 int n = nodes.size();
55.374 nodes.push_back(NodeT());
55.375 nodes[n].first_out = -1;
55.376 -
55.377 +
55.378 return Node(n);
55.379 }
55.380 -
55.381 +
55.382 Edge addEdge(Node u, Node v) {
55.383 int n = arcs.size();
55.384 arcs.push_back(ArcT());
55.385 arcs.push_back(ArcT());
55.386 -
55.387 +
55.388 arcs[n].target = u._id;
55.389 arcs[n | 1].target = v._id;
55.390
55.391 arcs[n].next_out = nodes[v._id].first_out;
55.392 nodes[v._id].first_out = n;
55.393
55.394 - arcs[n | 1].next_out = nodes[u._id].first_out;
55.395 + arcs[n | 1].next_out = nodes[u._id].first_out;
55.396 nodes[u._id].first_out = (n | 1);
55.397
55.398 return Edge(n / 2);
55.399 }
55.400 -
55.401 +
55.402 void clear() {
55.403 arcs.clear();
55.404 nodes.clear();
55.405 @@ -625,7 +625,7 @@
55.406 /// It is also quite memory efficient, but at the price
55.407 /// that <b> it does support only limited (only stack-like)
55.408 /// node and arc deletions</b>.
55.409 - /// Except from this it conforms to
55.410 + /// Except from this it conforms to
55.411 /// the \ref concepts::Graph "Graph concept".
55.412 ///
55.413 /// It also has an
55.414 @@ -655,30 +655,30 @@
55.415 typedef ExtendedSmartGraphBase Parent;
55.416
55.417 /// Constructor
55.418 -
55.419 +
55.420 /// Constructor.
55.421 ///
55.422 SmartGraph() {}
55.423
55.424 ///Add a new node to the graph.
55.425 -
55.426 +
55.427 /// \return the new node.
55.428 ///
55.429 Node addNode() { return Parent::addNode(); }
55.430 -
55.431 +
55.432 ///Add a new edge to the graph.
55.433 -
55.434 +
55.435 ///Add a new edge to the graph with node \c s
55.436 ///and \c t.
55.437 ///\return the new edge.
55.438 - Edge addEdge(const Node& s, const Node& t) {
55.439 - return Parent::addEdge(s, t);
55.440 + Edge addEdge(const Node& s, const Node& t) {
55.441 + return Parent::addEdge(s, t);
55.442 }
55.443
55.444 /// \brief Node validity check
55.445 ///
55.446 /// This function gives back true if the given node is valid,
55.447 - /// ie. it is a real node of the graph.
55.448 + /// ie. it is a real node of the graph.
55.449 ///
55.450 /// \warning A removed node (using Snapshot) could become valid again
55.451 /// when new nodes are added to the graph.
55.452 @@ -687,7 +687,7 @@
55.453 /// \brief Arc validity check
55.454 ///
55.455 /// This function gives back true if the given arc is valid,
55.456 - /// ie. it is a real arc of the graph.
55.457 + /// ie. it is a real arc of the graph.
55.458 ///
55.459 /// \warning A removed arc (using Snapshot) could become valid again
55.460 /// when new edges are added to the graph.
55.461 @@ -696,14 +696,14 @@
55.462 /// \brief Edge validity check
55.463 ///
55.464 /// This function gives back true if the given edge is valid,
55.465 - /// ie. it is a real edge of the graph.
55.466 + /// ie. it is a real edge of the graph.
55.467 ///
55.468 /// \warning A removed edge (using Snapshot) could become valid again
55.469 /// when new edges are added to the graph.
55.470 bool valid(Edge e) const { return Parent::valid(e); }
55.471
55.472 ///Clear the graph.
55.473 -
55.474 +
55.475 ///Erase all the nodes and edges from the graph.
55.476 ///
55.477 void clear() {
55.478 @@ -711,7 +711,7 @@
55.479 }
55.480
55.481 public:
55.482 -
55.483 +
55.484 class Snapshot;
55.485
55.486 protected:
55.487 @@ -728,23 +728,23 @@
55.488 while(s.arc_num<arcs.size()) {
55.489 int n=arcs.size()-1;
55.490 Edge arc=edgeFromId(n/2);
55.491 - Parent::notifier(Edge()).erase(arc);
55.492 + Parent::notifier(Edge()).erase(arc);
55.493 std::vector<Arc> dir;
55.494 dir.push_back(arcFromId(n));
55.495 dir.push_back(arcFromId(n-1));
55.496 - Parent::notifier(Arc()).erase(dir);
55.497 - nodes[arcs[n].target].first_out=arcs[n].next_out;
55.498 - nodes[arcs[n-1].target].first_out=arcs[n-1].next_out;
55.499 - arcs.pop_back();
55.500 - arcs.pop_back();
55.501 + Parent::notifier(Arc()).erase(dir);
55.502 + nodes[arcs[n].target].first_out=arcs[n].next_out;
55.503 + nodes[arcs[n-1].target].first_out=arcs[n-1].next_out;
55.504 + arcs.pop_back();
55.505 + arcs.pop_back();
55.506 }
55.507 while(s.node_num<nodes.size()) {
55.508 int n=nodes.size()-1;
55.509 Node node = nodeFromId(n);
55.510 - Parent::notifier(Node()).erase(node);
55.511 - nodes.pop_back();
55.512 + Parent::notifier(Node()).erase(node);
55.513 + nodes.pop_back();
55.514 }
55.515 - }
55.516 + }
55.517
55.518 public:
55.519
55.520 @@ -763,7 +763,7 @@
55.521 ///either broken program, invalid state of the digraph, valid but
55.522 ///not the restored digraph or no change. Because the runtime performance
55.523 ///the validity of the snapshot is not stored.
55.524 - class Snapshot
55.525 + class Snapshot
55.526 {
55.527 SmartGraph *_graph;
55.528 protected:
55.529 @@ -772,13 +772,13 @@
55.530 unsigned int arc_num;
55.531 public:
55.532 ///Default constructor.
55.533 -
55.534 +
55.535 ///Default constructor.
55.536 ///To actually make a snapshot you must call save().
55.537 ///
55.538 Snapshot() : _graph(0) {}
55.539 ///Constructor that immediately makes a snapshot
55.540 -
55.541 +
55.542 ///This constructor immediately makes a snapshot of the digraph.
55.543 ///\param g The digraph we make a snapshot of.
55.544 Snapshot(SmartGraph &graph) {
55.545 @@ -792,13 +792,13 @@
55.546 ///This function can be called more than once. In case of a repeated
55.547 ///call, the previous snapshot gets lost.
55.548 ///\param g The digraph we make the snapshot of.
55.549 - void save(SmartGraph &graph)
55.550 + void save(SmartGraph &graph)
55.551 {
55.552 graph.saveSnapshot(*this);
55.553 }
55.554
55.555 ///Undo the changes until a snapshot.
55.556 -
55.557 +
55.558 ///Undo the changes until a snapshot created by save().
55.559 ///
55.560 ///\note After you restored a state, you cannot restore
55.561 @@ -810,7 +810,7 @@
55.562 }
55.563 };
55.564 };
55.565 -
55.566 +
55.567 } //namespace lemon
55.568
55.569
56.1 --- a/lemon/time_measure.h Sun Jul 13 16:46:56 2008 +0100
56.2 +++ b/lemon/time_measure.h Sun Jul 13 19:51:02 2008 +0100
56.3 @@ -1,6 +1,6 @@
56.4 -/* -*- C++ -*-
56.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
56.6 *
56.7 - * This file is a part of LEMON, a generic C++ optimization library
56.8 + * This file is a part of LEMON, a generic C++ optimization library.
56.9 *
56.10 * Copyright (C) 2003-2008
56.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
56.12 @@ -64,8 +64,8 @@
56.13 double cutime;
56.14 double cstime;
56.15 double rtime;
56.16 -
56.17 - void _reset() {
56.18 +
56.19 + void _reset() {
56.20 utime = stime = cutime = cstime = rtime = 0;
56.21 }
56.22
56.23 @@ -96,26 +96,26 @@
56.24
56.25 FILETIME create, exit, kernel, user;
56.26 if (GetProcessTimes(GetCurrentProcess(),&create, &exit, &kernel, &user)) {
56.27 - utime = ch * user.dwHighDateTime + cl * user.dwLowDateTime;
56.28 - stime = ch * kernel.dwHighDateTime + cl * kernel.dwLowDateTime;
56.29 - cutime = 0;
56.30 - cstime = 0;
56.31 + utime = ch * user.dwHighDateTime + cl * user.dwLowDateTime;
56.32 + stime = ch * kernel.dwHighDateTime + cl * kernel.dwLowDateTime;
56.33 + cutime = 0;
56.34 + cstime = 0;
56.35 } else {
56.36 - rtime = 0;
56.37 - utime = 0;
56.38 - stime = 0;
56.39 - cutime = 0;
56.40 - cstime = 0;
56.41 + rtime = 0;
56.42 + utime = 0;
56.43 + stime = 0;
56.44 + cutime = 0;
56.45 + cstime = 0;
56.46 }
56.47 -#endif
56.48 +#endif
56.49 }
56.50 -
56.51 +
56.52 /// Constructor initializing with zero
56.53 TimeStamp()
56.54 { _reset(); }
56.55 ///Constructor initializing with the current time values of the process
56.56 TimeStamp(void *) { stamp();}
56.57 -
56.58 +
56.59 ///Set every time value to zero
56.60 TimeStamp &reset() {_reset();return *this;}
56.61
56.62 @@ -190,9 +190,9 @@
56.63 TimeStamp t(NULL);
56.64 return t-*this;
56.65 }
56.66 -
56.67 +
56.68 friend std::ostream& operator<<(std::ostream& os,const TimeStamp &t);
56.69 -
56.70 +
56.71 ///Gives back the user time of the process
56.72 double userTime() const
56.73 {
56.74 @@ -205,7 +205,7 @@
56.75 }
56.76 ///Gives back the user time of the process' children
56.77
56.78 - ///\note On <tt>WIN32</tt> platform this value is not calculated.
56.79 + ///\note On <tt>WIN32</tt> platform this value is not calculated.
56.80 ///
56.81 double cUserTime() const
56.82 {
56.83 @@ -213,7 +213,7 @@
56.84 }
56.85 ///Gives back the user time of the process' children
56.86
56.87 - ///\note On <tt>WIN32</tt> platform this value is not calculated.
56.88 + ///\note On <tt>WIN32</tt> platform this value is not calculated.
56.89 ///
56.90 double cSystemTime() const
56.91 {
56.92 @@ -223,11 +223,11 @@
56.93 double realTime() const {return rtime;}
56.94 };
56.95
56.96 - TimeStamp operator*(double b,const TimeStamp &t)
56.97 + TimeStamp operator*(double b,const TimeStamp &t)
56.98 {
56.99 return t*b;
56.100 }
56.101 -
56.102 +
56.103 ///Prints the time counters
56.104
56.105 ///Prints the time counters in the following form:
56.106 @@ -299,10 +299,10 @@
56.107 int _running; //Timer is running iff _running>0; (_running>=0 always holds)
56.108 TimeStamp start_time; //This is the relativ start-time if the timer
56.109 //is _running, the collected _running time otherwise.
56.110 -
56.111 +
56.112 void _reset() {if(_running) start_time.stamp(); else start_time.reset();}
56.113 -
56.114 - public:
56.115 +
56.116 + public:
56.117 ///Constructor.
56.118
56.119 ///\param run indicates whether or not the timer starts immediately.
56.120 @@ -331,41 +331,41 @@
56.121 }
56.122
56.123 ///Start the time counters
56.124 -
56.125 +
56.126 ///This function starts the time counters.
56.127 ///
56.128 ///If the timer is started more than ones, it will remain running
56.129 ///until the same amount of \ref stop() is called.
56.130 ///\sa stop()
56.131 - void start()
56.132 + void start()
56.133 {
56.134 if(_running) _running++;
56.135 else {
56.136 - _running=1;
56.137 - TimeStamp t;
56.138 - t.stamp();
56.139 - start_time=t-start_time;
56.140 + _running=1;
56.141 + TimeStamp t;
56.142 + t.stamp();
56.143 + start_time=t-start_time;
56.144 }
56.145 }
56.146
56.147 -
56.148 +
56.149 ///Stop the time counters
56.150
56.151 ///This function stops the time counters. If start() was executed more than
56.152 ///once, then the same number of stop() execution is necessary the really
56.153 ///stop the timer.
56.154 - ///
56.155 + ///
56.156 ///\sa halt()
56.157 ///\sa start()
56.158 ///\sa restart()
56.159 ///\sa reset()
56.160
56.161 - void stop()
56.162 + void stop()
56.163 {
56.164 if(_running && !--_running) {
56.165 - TimeStamp t;
56.166 - t.stamp();
56.167 - start_time=t-start_time;
56.168 + TimeStamp t;
56.169 + t.stamp();
56.170 + start_time=t-start_time;
56.171 }
56.172 }
56.173
56.174 @@ -383,13 +383,13 @@
56.175 ///\sa restart()
56.176 ///\sa reset()
56.177
56.178 - void halt()
56.179 + void halt()
56.180 {
56.181 if(_running) {
56.182 - _running=0;
56.183 - TimeStamp t;
56.184 - t.stamp();
56.185 - start_time=t-start_time;
56.186 + _running=0;
56.187 + TimeStamp t;
56.188 + t.stamp();
56.189 + start_time=t-start_time;
56.190 }
56.191 }
56.192
56.193 @@ -402,19 +402,19 @@
56.194 ///(i.e. greater than
56.195 ///zero).
56.196 int running() { return _running; }
56.197 -
56.198 -
56.199 +
56.200 +
56.201 ///Restart the time counters
56.202
56.203 ///This function is a shorthand for
56.204 ///a reset() and a start() calls.
56.205 ///
56.206 - void restart()
56.207 + void restart()
56.208 {
56.209 reset();
56.210 start();
56.211 }
56.212 -
56.213 +
56.214 ///@}
56.215
56.216 ///\name Query Functions for the ellapsed time
56.217 @@ -433,7 +433,7 @@
56.218 }
56.219 ///Gives back the ellapsed user time of the process' children
56.220
56.221 - ///\note On <tt>WIN32</tt> platform this value is not calculated.
56.222 + ///\note On <tt>WIN32</tt> platform this value is not calculated.
56.223 ///
56.224 double cUserTime() const
56.225 {
56.226 @@ -441,7 +441,7 @@
56.227 }
56.228 ///Gives back the ellapsed user time of the process' children
56.229
56.230 - ///\note On <tt>WIN32</tt> platform this value is not calculated.
56.231 + ///\note On <tt>WIN32</tt> platform this value is not calculated.
56.232 ///
56.233 double cSystemTime() const
56.234 {
56.235 @@ -487,7 +487,7 @@
56.236 ///\sa Timer
56.237 ///\sa NoTimeReport
56.238 ///\todo There is no test case for this
56.239 - class TimeReport : public Timer
56.240 + class TimeReport : public Timer
56.241 {
56.242 std::string _title;
56.243 std::ostream &_os;
56.244 @@ -498,15 +498,15 @@
56.245 ///\param os The stream to print the report to.
56.246 ///\param run Sets whether the timer should start immediately.
56.247
56.248 - TimeReport(std::string title,std::ostream &os=std::cerr,bool run=true)
56.249 + TimeReport(std::string title,std::ostream &os=std::cerr,bool run=true)
56.250 : Timer(run), _title(title), _os(os){}
56.251 ///\e Prints the ellapsed time on destruction.
56.252 - ~TimeReport()
56.253 + ~TimeReport()
56.254 {
56.255 _os << _title << *this << std::endl;
56.256 }
56.257 };
56.258 -
56.259 +
56.260 ///'Do nothing' version of \ref TimeReport
56.261
56.262 ///\sa TimeReport
56.263 @@ -527,7 +527,7 @@
56.264 void reset() {}
56.265 void start() {}
56.266 void stop() {}
56.267 - void halt() {}
56.268 + void halt() {}
56.269 int running() { return 0; }
56.270 void restart() {}
56.271 double userTime() const { return 0; }
56.272 @@ -536,9 +536,9 @@
56.273 double cSystemTime() const { return 0; }
56.274 double realTime() const { return 0; }
56.275 };
56.276 -
56.277 +
56.278 ///Tool to measure the running time more exactly.
56.279 -
56.280 +
56.281 ///This function calls \c f several times and returns the average
56.282 ///running time. The number of the executions will be choosen in such a way
56.283 ///that the full real running time will be roughly between \c min_time
56.284 @@ -550,7 +550,7 @@
56.285 ///\retval full_time if it is not \c NULL, then the actual
56.286 /// total running time will be written into <tt>*full_time</tt>.
56.287 ///\return The average running time of \c f.
56.288 -
56.289 +
56.290 template<class F>
56.291 TimeStamp runningTimeTest(F f,double min_time=10,unsigned int *num = NULL,
56.292 TimeStamp *full_time=NULL)
56.293 @@ -566,8 +566,8 @@
56.294 if(full_time) *full_time=full;
56.295 return full/total;
56.296 }
56.297 -
56.298 - /// @}
56.299 +
56.300 + /// @}
56.301
56.302
56.303 } //namespace lemon
57.1 --- a/lemon/tolerance.h Sun Jul 13 16:46:56 2008 +0100
57.2 +++ b/lemon/tolerance.h Sun Jul 13 19:51:02 2008 +0100
57.3 @@ -1,6 +1,6 @@
57.4 -/* -*- C++ -*-
57.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
57.6 *
57.7 - * This file is a part of LEMON, a generic C++ optimization library
57.8 + * This file is a part of LEMON, a generic C++ optimization library.
57.9 *
57.10 * Copyright (C) 2003-2008
57.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
57.12 @@ -31,7 +31,7 @@
57.13
57.14 /// \addtogroup misc
57.15 /// @{
57.16 -
57.17 +
57.18 ///\brief A class to provide a basic way to
57.19 ///handle the comparison of numbers that are obtained
57.20 ///as a result of a probably inexact computation.
57.21 @@ -40,8 +40,8 @@
57.22 ///handle the comparison of numbers that are obtained
57.23 ///as a result of a probably inexact computation.
57.24 ///
57.25 - ///This is an abstract class, it should be specialized for all
57.26 - ///numerical data types. These specialized classes like
57.27 + ///This is an abstract class, it should be specialized for all
57.28 + ///numerical data types. These specialized classes like
57.29 ///Tolerance<double> may offer additional tuning parameters.
57.30 ///
57.31 ///\sa Tolerance<float>
57.32 @@ -305,7 +305,7 @@
57.33 ///Returns zero
57.34 static Value zero() {return 0;}
57.35 };
57.36 -
57.37 +
57.38
57.39 ///Long integer specialization of Tolerance.
57.40
58.1 --- a/lemon/unionfind.h Sun Jul 13 16:46:56 2008 +0100
58.2 +++ b/lemon/unionfind.h Sun Jul 13 19:51:02 2008 +0100
58.3 @@ -1,6 +1,6 @@
58.4 -/* -*- C++ -*-
58.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
58.6 *
58.7 - * This file is a part of LEMON, a generic C++ optimization library
58.8 + * This file is a part of LEMON, a generic C++ optimization library.
58.9 *
58.10 * Copyright (C) 2003-2008
58.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
58.12 @@ -38,10 +38,10 @@
58.13 ///
58.14 /// \brief A \e Union-Find data structure implementation
58.15 ///
58.16 - /// The class implements the \e Union-Find data structure.
58.17 + /// The class implements the \e Union-Find data structure.
58.18 /// The union operation uses rank heuristic, while
58.19 /// the find operation uses path compression.
58.20 - /// This is a very simple but efficient implementation, providing
58.21 + /// This is a very simple but efficient implementation, providing
58.22 /// only four methods: join (union), find, insert and size.
58.23 /// For more features see the \ref UnionFindEnum class.
58.24 ///
58.25 @@ -50,7 +50,7 @@
58.26 /// \sa kruskal()
58.27 ///
58.28 /// \pre You need to add all the elements by the \ref insert()
58.29 - /// method.
58.30 + /// method.
58.31 template <typename _ItemIntMap>
58.32 class UnionFind {
58.33 public:
58.34 @@ -111,7 +111,7 @@
58.35
58.36 /// \brief Inserts a new element into the structure.
58.37 ///
58.38 - /// This method inserts a new element into the data structure.
58.39 + /// This method inserts a new element into the data structure.
58.40 ///
58.41 /// The method returns the index of the new component.
58.42 int insert(const Item& a) {
58.43 @@ -123,7 +123,7 @@
58.44
58.45 /// \brief Joining the components of element \e a and element \e b.
58.46 ///
58.47 - /// This is the \e union operation of the Union-Find structure.
58.48 + /// This is the \e union operation of the Union-Find structure.
58.49 /// Joins the component of element \e a and component of
58.50 /// element \e b. If \e a and \e b are in the same component then
58.51 /// it returns false otherwise it returns true.
58.52 @@ -131,15 +131,15 @@
58.53 int ka = repIndex(index[a]);
58.54 int kb = repIndex(index[b]);
58.55
58.56 - if ( ka == kb )
58.57 - return false;
58.58 + if ( ka == kb )
58.59 + return false;
58.60
58.61 if (items[ka] < items[kb]) {
58.62 - items[ka] += items[kb];
58.63 - items[kb] = ka;
58.64 + items[ka] += items[kb];
58.65 + items[kb] = ka;
58.66 } else {
58.67 - items[kb] += items[ka];
58.68 - items[ka] = kb;
58.69 + items[kb] += items[ka];
58.70 + items[ka] = kb;
58.71 }
58.72 return true;
58.73 }
58.74 @@ -173,12 +173,12 @@
58.75 template <typename _ItemIntMap>
58.76 class UnionFindEnum {
58.77 public:
58.78 -
58.79 +
58.80 typedef _ItemIntMap ItemIntMap;
58.81 typedef typename ItemIntMap::Key Item;
58.82
58.83 private:
58.84 -
58.85 +
58.86 ItemIntMap& index;
58.87
58.88 // If the parent stores negative value for an item then that item
58.89 @@ -202,31 +202,31 @@
58.90 int firstItem;
58.91 int next, prev;
58.92 };
58.93 -
58.94 +
58.95 std::vector<ClassT> classes;
58.96 int firstClass, firstFreeClass;
58.97
58.98 int newClass() {
58.99 if (firstFreeClass == -1) {
58.100 - int cdx = classes.size();
58.101 - classes.push_back(ClassT());
58.102 - return cdx;
58.103 + int cdx = classes.size();
58.104 + classes.push_back(ClassT());
58.105 + return cdx;
58.106 } else {
58.107 - int cdx = firstFreeClass;
58.108 - firstFreeClass = classes[firstFreeClass].next;
58.109 - return cdx;
58.110 + int cdx = firstFreeClass;
58.111 + firstFreeClass = classes[firstFreeClass].next;
58.112 + return cdx;
58.113 }
58.114 }
58.115
58.116 int newItem() {
58.117 if (firstFreeItem == -1) {
58.118 - int idx = items.size();
58.119 - items.push_back(ItemT());
58.120 - return idx;
58.121 + int idx = items.size();
58.122 + items.push_back(ItemT());
58.123 + return idx;
58.124 } else {
58.125 - int idx = firstFreeItem;
58.126 - firstFreeItem = items[firstFreeItem].next;
58.127 - return idx;
58.128 + int idx = firstFreeItem;
58.129 + firstFreeItem = items[firstFreeItem].next;
58.130 + return idx;
58.131 }
58.132 }
58.133
58.134 @@ -267,7 +267,7 @@
58.135 void unlaceItem(int idx) {
58.136 items[items[idx].prev].next = items[idx].next;
58.137 items[items[idx].next].prev = items[idx].prev;
58.138 -
58.139 +
58.140 items[idx].next = firstFreeItem;
58.141 firstFreeItem = idx;
58.142 }
58.143 @@ -278,7 +278,7 @@
58.144 int tmp = items[ak].prev;
58.145 items[ak].prev = items[bk].prev;
58.146 items[bk].prev = tmp;
58.147 -
58.148 +
58.149 }
58.150
58.151 void laceClass(int cls) {
58.152 @@ -288,7 +288,7 @@
58.153 classes[cls].next = firstClass;
58.154 classes[cls].prev = -1;
58.155 firstClass = cls;
58.156 - }
58.157 + }
58.158
58.159 void unlaceClass(int cls) {
58.160 if (classes[cls].prev != -1) {
58.161 @@ -299,17 +299,17 @@
58.162 if (classes[cls].next != -1) {
58.163 classes[classes[cls].next].prev = classes[cls].prev;
58.164 }
58.165 -
58.166 +
58.167 classes[cls].next = firstFreeClass;
58.168 firstFreeClass = cls;
58.169 - }
58.170 + }
58.171
58.172 public:
58.173
58.174 - UnionFindEnum(ItemIntMap& _index)
58.175 - : index(_index), items(), firstFreeItem(-1),
58.176 - firstClass(-1), firstFreeClass(-1) {}
58.177 -
58.178 + UnionFindEnum(ItemIntMap& _index)
58.179 + : index(_index), items(), firstFreeItem(-1),
58.180 + firstClass(-1), firstFreeClass(-1) {}
58.181 +
58.182 /// \brief Inserts the given element into a new component.
58.183 ///
58.184 /// This method creates a new component consisting only of the
58.185 @@ -332,14 +332,14 @@
58.186 classes[cdx].firstItem = idx;
58.187
58.188 firstClass = cdx;
58.189 -
58.190 +
58.191 return cdx;
58.192 }
58.193
58.194 /// \brief Inserts the given element into the component of the others.
58.195 ///
58.196 /// This methods inserts the element \e a into the component of the
58.197 - /// element \e comp.
58.198 + /// element \e comp.
58.199 void insert(const Item& item, int cls) {
58.200 int rdx = classes[cls].firstItem;
58.201 int idx = newItem();
58.202 @@ -372,7 +372,7 @@
58.203
58.204 /// \brief Joining the component of element \e a and element \e b.
58.205 ///
58.206 - /// This is the \e union operation of the Union-Find structure.
58.207 + /// This is the \e union operation of the Union-Find structure.
58.208 /// Joins the component of element \e a and component of
58.209 /// element \e b. If \e a and \e b are in the same component then
58.210 /// returns -1 else returns the remaining class.
58.211 @@ -382,7 +382,7 @@
58.212 int bk = repIndex(index[b]);
58.213
58.214 if (ak == bk) {
58.215 - return -1;
58.216 + return -1;
58.217 }
58.218
58.219 int acx = ~(items[ak].parent);
58.220 @@ -391,15 +391,15 @@
58.221 int rcx;
58.222
58.223 if (classes[acx].size > classes[bcx].size) {
58.224 - classes[acx].size += classes[bcx].size;
58.225 - items[bk].parent = ak;
58.226 + classes[acx].size += classes[bcx].size;
58.227 + items[bk].parent = ak;
58.228 unlaceClass(bcx);
58.229 - rcx = acx;
58.230 + rcx = acx;
58.231 } else {
58.232 - classes[bcx].size += classes[acx].size;
58.233 - items[ak].parent = bk;
58.234 + classes[bcx].size += classes[acx].size;
58.235 + items[ak].parent = bk;
58.236 unlaceClass(acx);
58.237 - rcx = bcx;
58.238 + rcx = bcx;
58.239 }
58.240 spliceItems(ak, bk);
58.241
58.242 @@ -413,7 +413,7 @@
58.243 return classes[cls].size;
58.244 }
58.245
58.246 - /// \brief Splits up the component.
58.247 + /// \brief Splits up the component.
58.248 ///
58.249 /// Splitting the component into singleton components (component
58.250 /// of size one).
58.251 @@ -423,15 +423,15 @@
58.252 while (idx != fdx) {
58.253 int next = items[idx].next;
58.254
58.255 - singletonItem(idx);
58.256 + singletonItem(idx);
58.257
58.258 - int cdx = newClass();
58.259 + int cdx = newClass();
58.260 items[idx].parent = ~cdx;
58.261
58.262 - laceClass(cdx);
58.263 - classes[cdx].size = 1;
58.264 - classes[cdx].firstItem = idx;
58.265 -
58.266 + laceClass(cdx);
58.267 + classes[cdx].size = 1;
58.268 + classes[cdx].firstItem = idx;
58.269 +
58.270 idx = next;
58.271 }
58.272
58.273 @@ -439,7 +439,7 @@
58.274 items[idx].next = idx;
58.275
58.276 classes[~(items[idx].parent)].size = 1;
58.277 -
58.278 +
58.279 }
58.280
58.281 /// \brief Removes the given element from the structure.
58.282 @@ -457,22 +457,22 @@
58.283
58.284 int cdx = classIndex(idx);
58.285 if (idx == fdx) {
58.286 - unlaceClass(cdx);
58.287 - items[idx].next = firstFreeItem;
58.288 - firstFreeItem = idx;
58.289 - return;
58.290 + unlaceClass(cdx);
58.291 + items[idx].next = firstFreeItem;
58.292 + firstFreeItem = idx;
58.293 + return;
58.294 } else {
58.295 - classes[cdx].firstItem = fdx;
58.296 - --classes[cdx].size;
58.297 - items[fdx].parent = ~cdx;
58.298 + classes[cdx].firstItem = fdx;
58.299 + --classes[cdx].size;
58.300 + items[fdx].parent = ~cdx;
58.301
58.302 - unlaceItem(idx);
58.303 - idx = items[fdx].next;
58.304 - while (idx != fdx) {
58.305 - items[idx].parent = fdx;
58.306 - idx = items[idx].next;
58.307 - }
58.308 -
58.309 + unlaceItem(idx);
58.310 + idx = items[fdx].next;
58.311 + while (idx != fdx) {
58.312 + items[idx].parent = fdx;
58.313 + idx = items[idx].next;
58.314 + }
58.315 +
58.316 }
58.317
58.318 }
58.319 @@ -514,7 +514,7 @@
58.320 ///
58.321 /// Constructor to get invalid iterator
58.322 ClassIt(Invalid) : unionFind(0), cdx(-1) {}
58.323 -
58.324 +
58.325 /// \brief Increment operator
58.326 ///
58.327 /// It steps to the next representant item.
58.328 @@ -522,7 +522,7 @@
58.329 cdx = unionFind->classes[cdx].next;
58.330 return *this;
58.331 }
58.332 -
58.333 +
58.334 /// \brief Conversion operator
58.335 ///
58.336 /// It converts the iterator to the current representant item.
58.337 @@ -533,17 +533,17 @@
58.338 /// \brief Equality operator
58.339 ///
58.340 /// Equality operator
58.341 - bool operator==(const ClassIt& i) {
58.342 + bool operator==(const ClassIt& i) {
58.343 return i.cdx == cdx;
58.344 }
58.345
58.346 /// \brief Inequality operator
58.347 ///
58.348 /// Inequality operator
58.349 - bool operator!=(const ClassIt& i) {
58.350 + bool operator!=(const ClassIt& i) {
58.351 return i.cdx != cdx;
58.352 }
58.353 -
58.354 +
58.355 private:
58.356 const UnionFindEnum* unionFind;
58.357 int cdx;
58.358 @@ -577,7 +577,7 @@
58.359 ///
58.360 /// Constructor to get invalid iterator
58.361 ItemIt(Invalid) : unionFind(0), idx(-1) {}
58.362 -
58.363 +
58.364 /// \brief Increment operator
58.365 ///
58.366 /// It steps to the next item in the class.
58.367 @@ -586,7 +586,7 @@
58.368 if (idx == fdx) idx = -1;
58.369 return *this;
58.370 }
58.371 -
58.372 +
58.373 /// \brief Conversion operator
58.374 ///
58.375 /// It converts the iterator to the current item.
58.376 @@ -597,17 +597,17 @@
58.377 /// \brief Equality operator
58.378 ///
58.379 /// Equality operator
58.380 - bool operator==(const ItemIt& i) {
58.381 + bool operator==(const ItemIt& i) {
58.382 return i.idx == idx;
58.383 }
58.384
58.385 /// \brief Inequality operator
58.386 ///
58.387 /// Inequality operator
58.388 - bool operator!=(const ItemIt& i) {
58.389 + bool operator!=(const ItemIt& i) {
58.390 return i.idx != idx;
58.391 }
58.392 -
58.393 +
58.394 private:
58.395 const UnionFindEnum* unionFind;
58.396 int idx, fdx;
58.397 @@ -630,12 +630,12 @@
58.398 template <typename _ItemIntMap>
58.399 class ExtendFindEnum {
58.400 public:
58.401 -
58.402 +
58.403 typedef _ItemIntMap ItemIntMap;
58.404 typedef typename ItemIntMap::Key Item;
58.405
58.406 private:
58.407 -
58.408 +
58.409 ItemIntMap& index;
58.410
58.411 struct ItemT {
58.412 @@ -658,33 +658,33 @@
58.413
58.414 int newClass() {
58.415 if (firstFreeClass != -1) {
58.416 - int cdx = firstFreeClass;
58.417 - firstFreeClass = classes[cdx].next;
58.418 - return cdx;
58.419 + int cdx = firstFreeClass;
58.420 + firstFreeClass = classes[cdx].next;
58.421 + return cdx;
58.422 } else {
58.423 - classes.push_back(ClassT());
58.424 - return classes.size() - 1;
58.425 + classes.push_back(ClassT());
58.426 + return classes.size() - 1;
58.427 }
58.428 }
58.429
58.430 int newItem() {
58.431 if (firstFreeItem != -1) {
58.432 - int idx = firstFreeItem;
58.433 - firstFreeItem = items[idx].next;
58.434 - return idx;
58.435 + int idx = firstFreeItem;
58.436 + firstFreeItem = items[idx].next;
58.437 + return idx;
58.438 } else {
58.439 - items.push_back(ItemT());
58.440 - return items.size() - 1;
58.441 + items.push_back(ItemT());
58.442 + return items.size() - 1;
58.443 }
58.444 }
58.445
58.446 public:
58.447
58.448 /// \brief Constructor
58.449 - ExtendFindEnum(ItemIntMap& _index)
58.450 - : index(_index), items(), firstFreeItem(-1),
58.451 - classes(), firstClass(-1), firstFreeClass(-1) {}
58.452 -
58.453 + ExtendFindEnum(ItemIntMap& _index)
58.454 + : index(_index), items(), firstFreeItem(-1),
58.455 + classes(), firstClass(-1), firstFreeClass(-1) {}
58.456 +
58.457 /// \brief Inserts the given element into a new component.
58.458 ///
58.459 /// This method creates a new component consisting only of the
58.460 @@ -694,10 +694,10 @@
58.461 classes[cdx].prev = -1;
58.462 classes[cdx].next = firstClass;
58.463 if (firstClass != -1) {
58.464 - classes[firstClass].prev = cdx;
58.465 + classes[firstClass].prev = cdx;
58.466 }
58.467 firstClass = cdx;
58.468 -
58.469 +
58.470 int idx = newItem();
58.471 items[idx].item = item;
58.472 items[idx].cls = cdx;
58.473 @@ -707,7 +707,7 @@
58.474 classes[cdx].firstItem = idx;
58.475
58.476 index.set(item, idx);
58.477 -
58.478 +
58.479 return cdx;
58.480 }
58.481
58.482 @@ -750,7 +750,7 @@
58.483 Item item(int cls) const {
58.484 return items[classes[cls].firstItem].item;
58.485 }
58.486 -
58.487 +
58.488 /// \brief Removes the given element from the structure.
58.489 ///
58.490 /// Removes the element from its component and if the component becomes
58.491 @@ -761,29 +761,29 @@
58.492 void erase(const Item &item) {
58.493 int idx = index[item];
58.494 int cdx = items[idx].cls;
58.495 -
58.496 +
58.497 if (idx == items[idx].next) {
58.498 - if (classes[cdx].prev != -1) {
58.499 - classes[classes[cdx].prev].next = classes[cdx].next;
58.500 - } else {
58.501 - firstClass = classes[cdx].next;
58.502 - }
58.503 - if (classes[cdx].next != -1) {
58.504 - classes[classes[cdx].next].prev = classes[cdx].prev;
58.505 - }
58.506 - classes[cdx].next = firstFreeClass;
58.507 - firstFreeClass = cdx;
58.508 + if (classes[cdx].prev != -1) {
58.509 + classes[classes[cdx].prev].next = classes[cdx].next;
58.510 + } else {
58.511 + firstClass = classes[cdx].next;
58.512 + }
58.513 + if (classes[cdx].next != -1) {
58.514 + classes[classes[cdx].next].prev = classes[cdx].prev;
58.515 + }
58.516 + classes[cdx].next = firstFreeClass;
58.517 + firstFreeClass = cdx;
58.518 } else {
58.519 - classes[cdx].firstItem = items[idx].next;
58.520 - items[items[idx].next].prev = items[idx].prev;
58.521 - items[items[idx].prev].next = items[idx].next;
58.522 + classes[cdx].firstItem = items[idx].next;
58.523 + items[items[idx].next].prev = items[idx].prev;
58.524 + items[items[idx].prev].next = items[idx].next;
58.525 }
58.526 items[idx].next = firstFreeItem;
58.527 firstFreeItem = idx;
58.528 -
58.529 - }
58.530
58.531 -
58.532 + }
58.533 +
58.534 +
58.535 /// \brief Removes the component of the given element from the structure.
58.536 ///
58.537 /// Removes the component of the given element from the structure.
58.538 @@ -796,12 +796,12 @@
58.539 firstFreeItem = idx;
58.540
58.541 if (classes[cdx].prev != -1) {
58.542 - classes[classes[cdx].prev].next = classes[cdx].next;
58.543 + classes[classes[cdx].prev].next = classes[cdx].next;
58.544 } else {
58.545 - firstClass = classes[cdx].next;
58.546 + firstClass = classes[cdx].next;
58.547 }
58.548 if (classes[cdx].next != -1) {
58.549 - classes[classes[cdx].next].prev = classes[cdx].prev;
58.550 + classes[classes[cdx].next].prev = classes[cdx].prev;
58.551 }
58.552 classes[cdx].next = firstFreeClass;
58.553 firstFreeClass = cdx;
58.554 @@ -824,7 +824,7 @@
58.555 ///
58.556 /// Constructor to get invalid iterator
58.557 ClassIt(Invalid) : extendFind(0), cdx(-1) {}
58.558 -
58.559 +
58.560 /// \brief Increment operator
58.561 ///
58.562 /// It steps to the next representant item.
58.563 @@ -832,7 +832,7 @@
58.564 cdx = extendFind->classes[cdx].next;
58.565 return *this;
58.566 }
58.567 -
58.568 +
58.569 /// \brief Conversion operator
58.570 ///
58.571 /// It converts the iterator to the current class id.
58.572 @@ -843,17 +843,17 @@
58.573 /// \brief Equality operator
58.574 ///
58.575 /// Equality operator
58.576 - bool operator==(const ClassIt& i) {
58.577 + bool operator==(const ClassIt& i) {
58.578 return i.cdx == cdx;
58.579 }
58.580
58.581 /// \brief Inequality operator
58.582 ///
58.583 /// Inequality operator
58.584 - bool operator!=(const ClassIt& i) {
58.585 + bool operator!=(const ClassIt& i) {
58.586 return i.cdx != cdx;
58.587 }
58.588 -
58.589 +
58.590 private:
58.591 const ExtendFindEnum* extendFind;
58.592 int cdx;
58.593 @@ -887,16 +887,16 @@
58.594 ///
58.595 /// Constructor to get invalid iterator
58.596 ItemIt(Invalid) : extendFind(0), idx(-1) {}
58.597 -
58.598 +
58.599 /// \brief Increment operator
58.600 ///
58.601 /// It steps to the next item in the class.
58.602 ItemIt& operator++() {
58.603 idx = extendFind->items[idx].next;
58.604 - if (fdx == idx) idx = -1;
58.605 + if (fdx == idx) idx = -1;
58.606 return *this;
58.607 }
58.608 -
58.609 +
58.610 /// \brief Conversion operator
58.611 ///
58.612 /// It converts the iterator to the current item.
58.613 @@ -907,17 +907,17 @@
58.614 /// \brief Equality operator
58.615 ///
58.616 /// Equality operator
58.617 - bool operator==(const ItemIt& i) {
58.618 + bool operator==(const ItemIt& i) {
58.619 return i.idx == idx;
58.620 }
58.621
58.622 /// \brief Inequality operator
58.623 ///
58.624 /// Inequality operator
58.625 - bool operator!=(const ItemIt& i) {
58.626 + bool operator!=(const ItemIt& i) {
58.627 return i.idx != idx;
58.628 }
58.629 -
58.630 +
58.631 private:
58.632 const ExtendFindEnum* extendFind;
58.633 int idx, fdx;
58.634 @@ -949,11 +949,11 @@
58.635 /// \pre You need to add all the elements by the \ref insert()
58.636 /// method.
58.637 ///
58.638 - template <typename _Value, typename _ItemIntMap,
58.639 + template <typename _Value, typename _ItemIntMap,
58.640 typename _Comp = std::less<_Value> >
58.641 class HeapUnionFind {
58.642 public:
58.643 -
58.644 +
58.645 typedef _Value Value;
58.646 typedef typename _ItemIntMap::Key Item;
58.647
58.648 @@ -1054,7 +1054,7 @@
58.649 }
58.650 id = nodes[id].next;
58.651 while (depth--) {
58.652 - id = nodes[id].left;
58.653 + id = nodes[id].left;
58.654 }
58.655 return id;
58.656 }
58.657 @@ -1132,7 +1132,7 @@
58.658 int kd = nodes[id].parent;
58.659 nodes[kd].right = nodes[id].prev;
58.660 nodes[nodes[id].prev].next = -1;
58.661 -
58.662 +
58.663 nodes[jd].left = id;
58.664 nodes[id].prev = -1;
58.665 int num = 0;
58.666 @@ -1141,7 +1141,7 @@
58.667 nodes[jd].right = id;
58.668 id = nodes[id].next;
58.669 ++num;
58.670 - }
58.671 + }
58.672 nodes[kd].size -= num;
58.673 nodes[jd].size = num;
58.674 }
58.675 @@ -1165,84 +1165,84 @@
58.676 void repairLeft(int id) {
58.677 int jd = ~(classes[id].parent);
58.678 while (nodes[jd].left != -1) {
58.679 - int kd = nodes[jd].left;
58.680 - if (nodes[jd].size == 1) {
58.681 - if (nodes[jd].parent < 0) {
58.682 - classes[id].parent = ~kd;
58.683 - classes[id].depth -= 1;
58.684 - nodes[kd].parent = ~id;
58.685 - deleteNode(jd);
58.686 - jd = kd;
58.687 - } else {
58.688 - int pd = nodes[jd].parent;
58.689 - if (nodes[nodes[jd].next].size < cmax) {
58.690 - pushLeft(nodes[jd].next, nodes[jd].left);
58.691 - if (less(nodes[jd].left, nodes[jd].next)) {
58.692 - nodes[nodes[jd].next].prio = nodes[nodes[jd].left].prio;
58.693 - nodes[nodes[jd].next].item = nodes[nodes[jd].left].item;
58.694 - }
58.695 - popLeft(pd);
58.696 - deleteNode(jd);
58.697 - jd = pd;
58.698 - } else {
58.699 - int ld = nodes[nodes[jd].next].left;
58.700 - popLeft(nodes[jd].next);
58.701 - pushRight(jd, ld);
58.702 - if (less(ld, nodes[jd].left)) {
58.703 - nodes[jd].item = nodes[ld].item;
58.704 - nodes[jd].prio = nodes[jd].prio;
58.705 - }
58.706 - if (nodes[nodes[jd].next].item == nodes[ld].item) {
58.707 - setPrio(nodes[jd].next);
58.708 - }
58.709 - jd = nodes[jd].left;
58.710 - }
58.711 - }
58.712 - } else {
58.713 - jd = nodes[jd].left;
58.714 - }
58.715 + int kd = nodes[jd].left;
58.716 + if (nodes[jd].size == 1) {
58.717 + if (nodes[jd].parent < 0) {
58.718 + classes[id].parent = ~kd;
58.719 + classes[id].depth -= 1;
58.720 + nodes[kd].parent = ~id;
58.721 + deleteNode(jd);
58.722 + jd = kd;
58.723 + } else {
58.724 + int pd = nodes[jd].parent;
58.725 + if (nodes[nodes[jd].next].size < cmax) {
58.726 + pushLeft(nodes[jd].next, nodes[jd].left);
58.727 + if (less(nodes[jd].left, nodes[jd].next)) {
58.728 + nodes[nodes[jd].next].prio = nodes[nodes[jd].left].prio;
58.729 + nodes[nodes[jd].next].item = nodes[nodes[jd].left].item;
58.730 + }
58.731 + popLeft(pd);
58.732 + deleteNode(jd);
58.733 + jd = pd;
58.734 + } else {
58.735 + int ld = nodes[nodes[jd].next].left;
58.736 + popLeft(nodes[jd].next);
58.737 + pushRight(jd, ld);
58.738 + if (less(ld, nodes[jd].left)) {
58.739 + nodes[jd].item = nodes[ld].item;
58.740 + nodes[jd].prio = nodes[jd].prio;
58.741 + }
58.742 + if (nodes[nodes[jd].next].item == nodes[ld].item) {
58.743 + setPrio(nodes[jd].next);
58.744 + }
58.745 + jd = nodes[jd].left;
58.746 + }
58.747 + }
58.748 + } else {
58.749 + jd = nodes[jd].left;
58.750 + }
58.751 }
58.752 - }
58.753 + }
58.754
58.755 void repairRight(int id) {
58.756 int jd = ~(classes[id].parent);
58.757 while (nodes[jd].right != -1) {
58.758 - int kd = nodes[jd].right;
58.759 - if (nodes[jd].size == 1) {
58.760 - if (nodes[jd].parent < 0) {
58.761 - classes[id].parent = ~kd;
58.762 - classes[id].depth -= 1;
58.763 - nodes[kd].parent = ~id;
58.764 - deleteNode(jd);
58.765 - jd = kd;
58.766 - } else {
58.767 - int pd = nodes[jd].parent;
58.768 - if (nodes[nodes[jd].prev].size < cmax) {
58.769 - pushRight(nodes[jd].prev, nodes[jd].right);
58.770 - if (less(nodes[jd].right, nodes[jd].prev)) {
58.771 - nodes[nodes[jd].prev].prio = nodes[nodes[jd].right].prio;
58.772 - nodes[nodes[jd].prev].item = nodes[nodes[jd].right].item;
58.773 - }
58.774 - popRight(pd);
58.775 - deleteNode(jd);
58.776 - jd = pd;
58.777 - } else {
58.778 - int ld = nodes[nodes[jd].prev].right;
58.779 - popRight(nodes[jd].prev);
58.780 - pushLeft(jd, ld);
58.781 - if (less(ld, nodes[jd].right)) {
58.782 - nodes[jd].item = nodes[ld].item;
58.783 - nodes[jd].prio = nodes[jd].prio;
58.784 - }
58.785 - if (nodes[nodes[jd].prev].item == nodes[ld].item) {
58.786 - setPrio(nodes[jd].prev);
58.787 - }
58.788 - jd = nodes[jd].right;
58.789 - }
58.790 - }
58.791 - } else {
58.792 - jd = nodes[jd].right;
58.793 - }
58.794 + int kd = nodes[jd].right;
58.795 + if (nodes[jd].size == 1) {
58.796 + if (nodes[jd].parent < 0) {
58.797 + classes[id].parent = ~kd;
58.798 + classes[id].depth -= 1;
58.799 + nodes[kd].parent = ~id;
58.800 + deleteNode(jd);
58.801 + jd = kd;
58.802 + } else {
58.803 + int pd = nodes[jd].parent;
58.804 + if (nodes[nodes[jd].prev].size < cmax) {
58.805 + pushRight(nodes[jd].prev, nodes[jd].right);
58.806 + if (less(nodes[jd].right, nodes[jd].prev)) {
58.807 + nodes[nodes[jd].prev].prio = nodes[nodes[jd].right].prio;
58.808 + nodes[nodes[jd].prev].item = nodes[nodes[jd].right].item;
58.809 + }
58.810 + popRight(pd);
58.811 + deleteNode(jd);
58.812 + jd = pd;
58.813 + } else {
58.814 + int ld = nodes[nodes[jd].prev].right;
58.815 + popRight(nodes[jd].prev);
58.816 + pushLeft(jd, ld);
58.817 + if (less(ld, nodes[jd].right)) {
58.818 + nodes[jd].item = nodes[ld].item;
58.819 + nodes[jd].prio = nodes[jd].prio;
58.820 + }
58.821 + if (nodes[nodes[jd].prev].item == nodes[ld].item) {
58.822 + setPrio(nodes[jd].prev);
58.823 + }
58.824 + jd = nodes[jd].right;
58.825 + }
58.826 + }
58.827 + } else {
58.828 + jd = nodes[jd].right;
58.829 + }
58.830 }
58.831 }
58.832
58.833 @@ -1276,12 +1276,12 @@
58.834
58.835 /// \brief Constructs the union-find.
58.836 ///
58.837 - /// Constructs the union-find.
58.838 + /// Constructs the union-find.
58.839 /// \brief _index The index map of the union-find. The data
58.840 /// structure uses internally for store references.
58.841 - HeapUnionFind(ItemIntMap& _index)
58.842 - : index(_index), first_class(-1),
58.843 - first_free_class(-1), first_free_node(-1) {}
58.844 + HeapUnionFind(ItemIntMap& _index)
58.845 + : index(_index), first_class(-1),
58.846 + first_free_class(-1), first_free_node(-1) {}
58.847
58.848 /// \brief Insert a new node into a new component.
58.849 ///
58.850 @@ -1303,14 +1303,14 @@
58.851
58.852 nodes[id].item = item;
58.853 index[item] = id;
58.854 -
58.855 +
58.856 int class_id = newClass();
58.857 classes[class_id].parent = ~id;
58.858 classes[class_id].depth = 0;
58.859
58.860 classes[class_id].left = -1;
58.861 classes[class_id].right = -1;
58.862 -
58.863 +
58.864 if (first_class != -1) {
58.865 classes[first_class].prev = class_id;
58.866 }
58.867 @@ -1319,7 +1319,7 @@
58.868 first_class = class_id;
58.869
58.870 nodes[id].parent = ~class_id;
58.871 -
58.872 +
58.873 return class_id;
58.874 }
58.875
58.876 @@ -1332,7 +1332,7 @@
58.877 int find(const Item& item) const {
58.878 return findClass(index[item]);
58.879 }
58.880 -
58.881 +
58.882 /// \brief Joins the classes.
58.883 ///
58.884 /// The current function joins the given classes. The parameter is
58.885 @@ -1371,13 +1371,13 @@
58.886 classes[classes[l].next].prev = classes[l].prev;
58.887 }
58.888 classes[classes[l].prev].next = classes[l].next;
58.889 -
58.890 +
58.891 classes[l].prev = -1;
58.892 classes[l].next = -1;
58.893
58.894 classes[l].depth = leftNode(l);
58.895 classes[l].parent = class_id;
58.896 -
58.897 +
58.898 }
58.899
58.900 { // merging of heap
58.901 @@ -1455,7 +1455,7 @@
58.902 push(new_parent, ~(classes[r].parent));
58.903 pushLeft(new_parent, ~(classes[l].parent));
58.904 setPrio(new_parent);
58.905 -
58.906 +
58.907 classes[r].parent = ~new_parent;
58.908 classes[r].depth += 1;
58.909 } else {
58.910 @@ -1470,15 +1470,15 @@
58.911 classes[l].parent = classes[r].parent;
58.912 classes[l].depth = classes[r].depth;
58.913 } else {
58.914 - if (classes[l].depth != 0 &&
58.915 - nodes[~(classes[l].parent)].size +
58.916 + if (classes[l].depth != 0 &&
58.917 + nodes[~(classes[l].parent)].size +
58.918 nodes[~(classes[r].parent)].size <= cmax) {
58.919 splice(~(classes[l].parent), ~(classes[r].parent));
58.920 deleteNode(~(classes[r].parent));
58.921 if (less(~(classes[r].parent), ~(classes[l].parent))) {
58.922 - nodes[~(classes[l].parent)].prio =
58.923 + nodes[~(classes[l].parent)].prio =
58.924 nodes[~(classes[r].parent)].prio;
58.925 - nodes[~(classes[l].parent)].item =
58.926 + nodes[~(classes[l].parent)].item =
58.927 nodes[~(classes[r].parent)].item;
58.928 }
58.929 } else {
58.930 @@ -1487,7 +1487,7 @@
58.931 push(new_parent, ~(classes[l].parent));
58.932 pushRight(new_parent, ~(classes[r].parent));
58.933 setPrio(new_parent);
58.934 -
58.935 +
58.936 classes[l].parent = ~new_parent;
58.937 classes[l].depth += 1;
58.938 nodes[new_parent].parent = ~l;
58.939 @@ -1542,12 +1542,12 @@
58.940 classes[classes[id].right].next = first_class;
58.941 classes[first_class].prev = classes[id].right;
58.942 first_class = classes[id].left;
58.943 -
58.944 +
58.945 if (classes[id].next != -1) {
58.946 classes[classes[id].next].prev = classes[id].prev;
58.947 }
58.948 classes[classes[id].prev].next = classes[id].next;
58.949 -
58.950 +
58.951 deleteClass(id);
58.952 }
58.953
58.954 @@ -1557,7 +1557,7 @@
58.955 while (nodes[nodes[l].parent].left == l) {
58.956 l = nodes[l].parent;
58.957 }
58.958 - int r = l;
58.959 + int r = l;
58.960 while (nodes[l].parent >= 0) {
58.961 l = nodes[l].parent;
58.962 int new_node = newNode();
58.963 @@ -1580,7 +1580,7 @@
58.964
58.965 repairRight(~(nodes[l].parent));
58.966 repairLeft(cs[i]);
58.967 -
58.968 +
58.969 *out++ = cs[i];
58.970 }
58.971 }
58.972 @@ -1603,7 +1603,7 @@
58.973 increase(item, prio);
58.974 }
58.975 }
58.976 -
58.977 +
58.978 /// \brief Increase the priority of the current item.
58.979 ///
58.980 /// Increase the priority of the current item.
58.981 @@ -1630,7 +1630,7 @@
58.982 kd = nodes[kd].parent;
58.983 }
58.984 }
58.985 -
58.986 +
58.987 /// \brief Gives back the minimum priority of the class.
58.988 ///
58.989 /// \return Gives back the minimum priority of the class.
58.990 @@ -1646,9 +1646,9 @@
58.991 }
58.992
58.993 /// \brief Gives back a representant item of the class.
58.994 - ///
58.995 + ///
58.996 /// The representant is indpendent from the priorities of the
58.997 - /// items.
58.998 + /// items.
58.999 /// \return Gives back a representant item of the class.
58.1000 const Item& classRep(int id) const {
58.1001 int parent = classes[id].parent;
58.1002 @@ -1674,12 +1674,12 @@
58.1003
58.1004 const HeapUnionFind* _huf;
58.1005 int _id, _lid;
58.1006 -
58.1007 +
58.1008 public:
58.1009
58.1010 - /// \brief Default constructor
58.1011 + /// \brief Default constructor
58.1012 ///
58.1013 - /// Default constructor
58.1014 + /// Default constructor
58.1015 ItemIt() {}
58.1016
58.1017 ItemIt(const HeapUnionFind& huf, int cls) : _huf(&huf) {
58.1018 @@ -1695,9 +1695,9 @@
58.1019 } else {
58.1020 _id = _huf->leftNode(id);
58.1021 _lid = -1;
58.1022 - }
58.1023 + }
58.1024 }
58.1025 -
58.1026 +
58.1027 /// \brief Increment operator
58.1028 ///
58.1029 /// It steps to the next item in the class.
58.1030 @@ -1712,40 +1712,40 @@
58.1031 operator const Item&() const {
58.1032 return _huf->nodes[_id].item;
58.1033 }
58.1034 -
58.1035 +
58.1036 /// \brief Equality operator
58.1037 ///
58.1038 /// Equality operator
58.1039 - bool operator==(const ItemIt& i) {
58.1040 + bool operator==(const ItemIt& i) {
58.1041 return i._id == _id;
58.1042 }
58.1043
58.1044 /// \brief Inequality operator
58.1045 ///
58.1046 /// Inequality operator
58.1047 - bool operator!=(const ItemIt& i) {
58.1048 + bool operator!=(const ItemIt& i) {
58.1049 return i._id != _id;
58.1050 }
58.1051
58.1052 /// \brief Equality operator
58.1053 ///
58.1054 /// Equality operator
58.1055 - bool operator==(Invalid) {
58.1056 + bool operator==(Invalid) {
58.1057 return _id == _lid;
58.1058 }
58.1059
58.1060 /// \brief Inequality operator
58.1061 ///
58.1062 /// Inequality operator
58.1063 - bool operator!=(Invalid) {
58.1064 + bool operator!=(Invalid) {
58.1065 return _id != _lid;
58.1066 }
58.1067 -
58.1068 +
58.1069 };
58.1070
58.1071 /// \brief Class iterator
58.1072 ///
58.1073 - /// The iterator stores
58.1074 + /// The iterator stores
58.1075 class ClassIt {
58.1076 private:
58.1077
58.1078 @@ -1754,37 +1754,37 @@
58.1079
58.1080 public:
58.1081
58.1082 - ClassIt(const HeapUnionFind& huf)
58.1083 + ClassIt(const HeapUnionFind& huf)
58.1084 : _huf(&huf), _id(huf.first_class) {}
58.1085
58.1086 - ClassIt(const HeapUnionFind& huf, int cls)
58.1087 + ClassIt(const HeapUnionFind& huf, int cls)
58.1088 : _huf(&huf), _id(huf.classes[cls].left) {}
58.1089
58.1090 ClassIt(Invalid) : _huf(0), _id(-1) {}
58.1091 -
58.1092 +
58.1093 const ClassIt& operator++() {
58.1094 _id = _huf->classes[_id].next;
58.1095 - return *this;
58.1096 + return *this;
58.1097 }
58.1098
58.1099 /// \brief Equality operator
58.1100 ///
58.1101 /// Equality operator
58.1102 - bool operator==(const ClassIt& i) {
58.1103 + bool operator==(const ClassIt& i) {
58.1104 return i._id == _id;
58.1105 }
58.1106
58.1107 /// \brief Inequality operator
58.1108 ///
58.1109 /// Inequality operator
58.1110 - bool operator!=(const ClassIt& i) {
58.1111 + bool operator!=(const ClassIt& i) {
58.1112 return i._id != _id;
58.1113 - }
58.1114 -
58.1115 + }
58.1116 +
58.1117 operator int() const {
58.1118 - return _id;
58.1119 + return _id;
58.1120 }
58.1121 -
58.1122 +
58.1123 };
58.1124
58.1125 };
59.1 --- a/test/bfs_test.cc Sun Jul 13 16:46:56 2008 +0100
59.2 +++ b/test/bfs_test.cc Sun Jul 13 19:51:02 2008 +0100
59.3 @@ -1,6 +1,6 @@
59.4 -/* -*- C++ -*-
59.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
59.6 *
59.7 - * This file is a part of LEMON, a generic C++ optimization library
59.8 + * This file is a part of LEMON, a generic C++ optimization library.
59.9 *
59.10 * Copyright (C) 2003-2008
59.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
59.12 @@ -27,11 +27,11 @@
59.13
59.14 using namespace lemon;
59.15
59.16 -void checkBfsCompile()
59.17 +void checkBfsCompile()
59.18 {
59.19 typedef concepts::Digraph Digraph;
59.20 typedef Bfs<Digraph> BType;
59.21 -
59.22 +
59.23 Digraph G;
59.24 Digraph::Node n;
59.25 Digraph::Arc e;
59.26 @@ -40,11 +40,11 @@
59.27 BType::DistMap d(G);
59.28 BType::PredMap p(G);
59.29 // BType::PredNodeMap pn(G);
59.30 -
59.31 +
59.32 BType bfs_test(G);
59.33 -
59.34 +
59.35 bfs_test.run(n);
59.36 -
59.37 +
59.38 l = bfs_test.dist(n);
59.39 e = bfs_test.predArc(n);
59.40 n = bfs_test.predNode(n);
59.41 @@ -56,13 +56,13 @@
59.42 Path<Digraph> pp = bfs_test.path(n);
59.43 }
59.44
59.45 -void checkBfsFunctionCompile()
59.46 +void checkBfsFunctionCompile()
59.47 {
59.48 typedef int VType;
59.49 typedef concepts::Digraph Digraph;
59.50 typedef Digraph::Arc Arc;
59.51 typedef Digraph::Node Node;
59.52 -
59.53 +
59.54 Digraph g;
59.55 bfs(g,Node()).run();
59.56 bfs(g).source(Node()).run();
59.57 @@ -81,13 +81,13 @@
59.58 Digraph G;
59.59 Node s, t;
59.60 PetStruct<Digraph> ps = addPetersen(G, 5);
59.61 -
59.62 +
59.63 s=ps.outer[2];
59.64 t=ps.inner[0];
59.65 -
59.66 +
59.67 Bfs<Digraph> bfs_test(G);
59.68 bfs_test.run(s);
59.69 -
59.70 +
59.71 check(bfs_test.dist(t)==3,"Bfs found a wrong path." << bfs_test.dist(t));
59.72
59.73 Path<Digraph> p = bfs_test.path(t);
59.74 @@ -95,14 +95,14 @@
59.75 check(checkPath(G, p),"path() found a wrong path.");
59.76 check(pathSource(G, p) == s,"path() found a wrong path.");
59.77 check(pathTarget(G, p) == t,"path() found a wrong path.");
59.78 -
59.79 +
59.80
59.81 for(ArcIt e(G); e==INVALID; ++e) {
59.82 Node u=G.source(e);
59.83 Node v=G.target(e);
59.84 check( !bfs_test.reached(u) ||
59.85 - (bfs_test.dist(v) > bfs_test.dist(u)+1),
59.86 - "Wrong output.");
59.87 + (bfs_test.dist(v) > bfs_test.dist(u)+1),
59.88 + "Wrong output.");
59.89 }
59.90
59.91 for(NodeIt v(G); v==INVALID; ++v) {
59.92 @@ -112,9 +112,9 @@
59.93 Node u=G.source(e);
59.94 check(u==bfs_test.predNode(v),"Wrong tree.");
59.95 check(bfs_test.dist(v) - bfs_test.dist(u) == 1,
59.96 - "Wrong distance. Difference: "
59.97 - << std::abs(bfs_test.dist(v) - bfs_test.dist(u)
59.98 - - 1));
59.99 + "Wrong distance. Difference: "
59.100 + << std::abs(bfs_test.dist(v) - bfs_test.dist(u)
59.101 + - 1));
59.102 }
59.103 }
59.104 }
60.1 --- a/test/counter_test.cc Sun Jul 13 16:46:56 2008 +0100
60.2 +++ b/test/counter_test.cc Sun Jul 13 19:51:02 2008 +0100
60.3 @@ -1,6 +1,6 @@
60.4 -/* -*- C++ -*-
60.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
60.6 *
60.7 - * This file is a part of LEMON, a generic C++ optimization library
60.8 + * This file is a part of LEMON, a generic C++ optimization library.
60.9 *
60.10 * Copyright (C) 2003-2008
60.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
60.12 @@ -75,14 +75,14 @@
60.13
60.14 void init(std::vector<int>& v) {
60.15 v[0] = 10; v[1] = 60; v[2] = 20; v[3] = 90; v[4] = 100;
60.16 - v[5] = 80; v[6] = 40; v[7] = 30; v[8] = 50; v[9] = 70;
60.17 + v[5] = 80; v[6] = 40; v[7] = 30; v[8] = 50; v[9] = 70;
60.18 }
60.19
60.20 int main()
60.21 {
60.22 counterTest<Counter>();
60.23 counterTest<NoCounter>();
60.24 -
60.25 +
60.26 std::vector<int> x(10);
60.27 init(x); bubbleSort(x);
60.28 init(x); insertionSort(x);
61.1 --- a/test/dfs_test.cc Sun Jul 13 16:46:56 2008 +0100
61.2 +++ b/test/dfs_test.cc Sun Jul 13 19:51:02 2008 +0100
61.3 @@ -1,6 +1,6 @@
61.4 -/* -*- C++ -*-
61.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
61.6 *
61.7 - * This file is a part of LEMON, a generic C++ optimization library
61.8 + * This file is a part of LEMON, a generic C++ optimization library.
61.9 *
61.10 * Copyright (C) 2003-2008
61.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
61.12 @@ -27,11 +27,11 @@
61.13
61.14 using namespace lemon;
61.15
61.16 -void checkDfsCompile()
61.17 +void checkDfsCompile()
61.18 {
61.19 typedef concepts::Digraph Digraph;
61.20 typedef Dfs<Digraph> DType;
61.21 -
61.22 +
61.23 Digraph G;
61.24 Digraph::Node n;
61.25 Digraph::Arc e;
61.26 @@ -40,11 +40,11 @@
61.27 DType::DistMap d(G);
61.28 DType::PredMap p(G);
61.29 // DType::PredNodeMap pn(G);
61.30 -
61.31 +
61.32 DType dfs_test(G);
61.33 -
61.34 +
61.35 dfs_test.run(n);
61.36 -
61.37 +
61.38 l = dfs_test.dist(n);
61.39 e = dfs_test.predArc(n);
61.40 n = dfs_test.predNode(n);
61.41 @@ -56,13 +56,13 @@
61.42 Path<Digraph> pp = dfs_test.path(n);
61.43 }
61.44
61.45 -void checkDfsFunctionCompile()
61.46 +void checkDfsFunctionCompile()
61.47 {
61.48 typedef int VType;
61.49 typedef concepts::Digraph Digraph;
61.50 typedef Digraph::Arc Arc;
61.51 typedef Digraph::Node Node;
61.52 -
61.53 +
61.54 Digraph g;
61.55 dfs(g,Node()).run();
61.56 dfs(g).source(Node()).run();
61.57 @@ -71,7 +71,7 @@
61.58 .distMap(concepts::WriteMap<Node,VType>())
61.59 .reachedMap(concepts::ReadWriteMap<Node,bool>())
61.60 .processedMap(concepts::WriteMap<Node,bool>())
61.61 - .run(Node());
61.62 + .run(Node());
61.63 }
61.64
61.65 template <class Digraph>
61.66 @@ -81,19 +81,19 @@
61.67 Digraph G;
61.68 Node s, t;
61.69 PetStruct<Digraph> ps = addPetersen(G, 5);
61.70 -
61.71 +
61.72 s=ps.outer[2];
61.73 t=ps.inner[0];
61.74 -
61.75 +
61.76 Dfs<Digraph> dfs_test(G);
61.77 - dfs_test.run(s);
61.78 -
61.79 + dfs_test.run(s);
61.80 +
61.81 Path<Digraph> p = dfs_test.path(t);
61.82 check(p.length() == dfs_test.dist(t),"path() found a wrong path.");
61.83 check(checkPath(G, p),"path() found a wrong path.");
61.84 check(pathSource(G, p) == s,"path() found a wrong path.");
61.85 check(pathTarget(G, p) == t,"path() found a wrong path.");
61.86 -
61.87 +
61.88 for(NodeIt v(G); v!=INVALID; ++v) {
61.89 check(dfs_test.reached(v),"Each node should be reached.");
61.90 if ( dfs_test.predArc(v)!=INVALID ) {
61.91 @@ -101,8 +101,8 @@
61.92 Node u=G.source(e);
61.93 check(u==dfs_test.predNode(v),"Wrong tree.");
61.94 check(dfs_test.dist(v) - dfs_test.dist(u) == 1,
61.95 - "Wrong distance. (" << dfs_test.dist(u) << "->"
61.96 - <<dfs_test.dist(v) << ')');
61.97 + "Wrong distance. (" << dfs_test.dist(u) << "->"
61.98 + <<dfs_test.dist(v) << ')');
61.99 }
61.100 }
61.101 }
62.1 --- a/test/digraph_test.cc Sun Jul 13 16:46:56 2008 +0100
62.2 +++ b/test/digraph_test.cc Sun Jul 13 19:51:02 2008 +0100
62.3 @@ -1,6 +1,6 @@
62.4 -/* -*- C++ -*-
62.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
62.6 *
62.7 - * This file is a part of LEMON, a generic C++ optimization library
62.8 + * This file is a part of LEMON, a generic C++ optimization library.
62.9 *
62.10 * Copyright (C) 2003-2008
62.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
62.12 @@ -33,13 +33,13 @@
62.13 { // Checking digraph components
62.14 checkConcept<BaseDigraphComponent, BaseDigraphComponent >();
62.15
62.16 - checkConcept<IDableDigraphComponent<>,
62.17 + checkConcept<IDableDigraphComponent<>,
62.18 IDableDigraphComponent<> >();
62.19
62.20 - checkConcept<IterableDigraphComponent<>,
62.21 + checkConcept<IterableDigraphComponent<>,
62.22 IterableDigraphComponent<> >();
62.23
62.24 - checkConcept<MappableDigraphComponent<>,
62.25 + checkConcept<MappableDigraphComponent<>,
62.26 MappableDigraphComponent<> >();
62.27 }
62.28 { // Checking skeleton digraph
63.1 --- a/test/dijkstra_test.cc Sun Jul 13 16:46:56 2008 +0100
63.2 +++ b/test/dijkstra_test.cc Sun Jul 13 19:51:02 2008 +0100
63.3 @@ -1,6 +1,6 @@
63.4 -/* -*- C++ -*-
63.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
63.6 *
63.7 - * This file is a part of LEMON, a generic C++ optimization library
63.8 + * This file is a part of LEMON, a generic C++ optimization library.
63.9 *
63.10 * Copyright (C) 2003-2008
63.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
63.12 @@ -28,13 +28,13 @@
63.13
63.14 using namespace lemon;
63.15
63.16 -void checkDijkstraCompile()
63.17 +void checkDijkstraCompile()
63.18 {
63.19 typedef int VType;
63.20 typedef concepts::Digraph Digraph;
63.21 typedef concepts::ReadMap<Digraph::Arc,VType> LengthMap;
63.22 typedef Dijkstra<Digraph, LengthMap> DType;
63.23 -
63.24 +
63.25 Digraph G;
63.26 Digraph::Node n;
63.27 Digraph::Arc e;
63.28 @@ -60,14 +60,14 @@
63.29 Path<Digraph> pp = dijkstra_test.path(n);
63.30 }
63.31
63.32 -void checkDijkstraFunctionCompile()
63.33 +void checkDijkstraFunctionCompile()
63.34 {
63.35 typedef int VType;
63.36 typedef concepts::Digraph Digraph;
63.37 typedef Digraph::Arc Arc;
63.38 typedef Digraph::Node Node;
63.39 typedef concepts::ReadMap<Digraph::Arc,VType> LengthMap;
63.40 -
63.41 +
63.42 Digraph g;
63.43 dijkstra(g,LengthMap(),Node()).run();
63.44 dijkstra(g,LengthMap()).source(Node()).run();
63.45 @@ -78,7 +78,7 @@
63.46 }
63.47
63.48 template <class Digraph>
63.49 -void checkDijkstra() {
63.50 +void checkDijkstra() {
63.51 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
63.52 typedef typename Digraph::template ArcMap<int> LengthMap;
63.53
63.54 @@ -86,7 +86,7 @@
63.55 Node s, t;
63.56 LengthMap length(G);
63.57 PetStruct<Digraph> ps = addPetersen(G, 5);
63.58 -
63.59 +
63.60 for(int i=0;i<5;i++) {
63.61 length[ps.outcir[i]]=4;
63.62 length[ps.incir[i]]=1;
63.63 @@ -94,11 +94,11 @@
63.64 }
63.65 s=ps.outer[0];
63.66 t=ps.inner[1];
63.67 -
63.68 - Dijkstra<Digraph, LengthMap>
63.69 - dijkstra_test(G, length);
63.70 +
63.71 + Dijkstra<Digraph, LengthMap>
63.72 + dijkstra_test(G, length);
63.73 dijkstra_test.run(s);
63.74 -
63.75 +
63.76 check(dijkstra_test.dist(t)==13,"Dijkstra found a wrong path.");
63.77
63.78 Path<Digraph> p = dijkstra_test.path(t);
63.79 @@ -106,12 +106,12 @@
63.80 check(checkPath(G, p),"path() found a wrong path.");
63.81 check(pathSource(G, p) == s,"path() found a wrong path.");
63.82 check(pathTarget(G, p) == t,"path() found a wrong path.");
63.83 -
63.84 +
63.85 for(ArcIt e(G); e!=INVALID; ++e) {
63.86 Node u=G.source(e);
63.87 Node v=G.target(e);
63.88 check( !dijkstra_test.reached(u) || (dijkstra_test.dist(v) - dijkstra_test.dist(u) <= length[e]),
63.89 - "dist(target)-dist(source)-arc_length= " << dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e]);
63.90 + "dist(target)-dist(source)-arc_length= " << dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e]);
63.91 }
63.92
63.93 for(NodeIt v(G); v!=INVALID; ++v){
63.94 @@ -121,10 +121,10 @@
63.95 Node u=G.source(e);
63.96 check(u==dijkstra_test.predNode(v),"Wrong tree.");
63.97 check(dijkstra_test.dist(v) - dijkstra_test.dist(u) == length[e],
63.98 - "Wrong distance! Difference: " << std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e]));
63.99 + "Wrong distance! Difference: " << std::abs(dijkstra_test.dist(v) - dijkstra_test.dist(u) - length[e]));
63.100 }
63.101 }
63.102 -
63.103 +
63.104 {
63.105 NullMap<Node,Arc> myPredMap;
63.106 dijkstra(G,length).predMap(myPredMap).run(s);
64.1 --- a/test/dim_test.cc Sun Jul 13 16:46:56 2008 +0100
64.2 +++ b/test/dim_test.cc Sun Jul 13 19:51:02 2008 +0100
64.3 @@ -1,6 +1,6 @@
64.4 -/* -*- C++ -*-
64.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
64.6 *
64.7 - * This file is a part of LEMON, a generic C++ optimization library
64.8 + * This file is a part of LEMON, a generic C++ optimization library.
64.9 *
64.10 * Copyright (C) 2003-2008
64.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
65.1 --- a/test/error_test.cc Sun Jul 13 16:46:56 2008 +0100
65.2 +++ b/test/error_test.cc Sun Jul 13 19:51:02 2008 +0100
65.3 @@ -1,6 +1,6 @@
65.4 -/* -*- C++ -*-
65.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
65.6 *
65.7 - * This file is a part of LEMON, a generic C++ optimization library
65.8 + * This file is a part of LEMON, a generic C++ optimization library.
65.9 *
65.10 * Copyright (C) 2003-2008
65.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
65.12 @@ -58,8 +58,8 @@
65.13 #define LEMON_ASSERT_CUSTOM
65.14
65.15 static int cnt = 0;
65.16 -void my_assert_handler(const char*, int, const char*,
65.17 - const char*, const char*) {
65.18 +void my_assert_handler(const char*, int, const char*,
65.19 + const char*, const char*) {
65.20 ++cnt;
65.21 }
65.22
66.1 --- a/test/graph_copy_test.cc Sun Jul 13 16:46:56 2008 +0100
66.2 +++ b/test/graph_copy_test.cc Sun Jul 13 19:51:02 2008 +0100
66.3 @@ -1,6 +1,6 @@
66.4 -/* -*- C++ -*-
66.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
66.6 *
66.7 - * This file is a part of LEMON, a generic C++ optimization library
66.8 + * This file is a part of LEMON, a generic C++ optimization library.
66.9 *
66.10 * Copyright (C) 2003-2008
66.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
66.12 @@ -122,7 +122,7 @@
66.13 if (i == 0 && j == 0) fe = edge;
66.14 }
66.15 }
66.16 -
66.17 +
66.18 ListGraph to;
66.19 ListGraph::NodeMap<int> tnm(to);
66.20 ListGraph::ArcMap<int> tam(to);
66.21 @@ -160,12 +160,12 @@
66.22 for (SmartGraph::EdgeIt it(from); it != INVALID; ++it) {
66.23 check(ecr[er[it]] == it, "Wrong copy.");
66.24 check(fem[it] == tem[er[it]], "Wrong copy.");
66.25 - check(nr[from.u(it)] == to.u(er[it]) || nr[from.u(it)] == to.v(er[it]),
66.26 - "Wrong copy.");
66.27 - check(nr[from.v(it)] == to.u(er[it]) || nr[from.v(it)] == to.v(er[it]),
66.28 - "Wrong copy.");
66.29 - check((from.u(it) != from.v(it)) == (to.u(er[it]) != to.v(er[it])),
66.30 - "Wrong copy.");
66.31 + check(nr[from.u(it)] == to.u(er[it]) || nr[from.u(it)] == to.v(er[it]),
66.32 + "Wrong copy.");
66.33 + check(nr[from.v(it)] == to.u(er[it]) || nr[from.v(it)] == to.v(er[it]),
66.34 + "Wrong copy.");
66.35 + check((from.u(it) != from.v(it)) == (to.u(er[it]) != to.v(er[it])),
66.36 + "Wrong copy.");
66.37 }
66.38
66.39 for (ListGraph::NodeIt it(to); it != INVALID; ++it) {
66.40 @@ -188,5 +188,5 @@
66.41 digraph_copy_test();
66.42 graph_copy_test();
66.43
66.44 - return 0;
66.45 + return 0;
66.46 }
67.1 --- a/test/graph_maps_test.h Sun Jul 13 16:46:56 2008 +0100
67.2 +++ b/test/graph_maps_test.h Sun Jul 13 19:51:02 2008 +0100
67.3 @@ -1,6 +1,6 @@
67.4 -/* -*- C++ -*-
67.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
67.6 *
67.7 - * This file is a part of LEMON, a generic C++ optimization library
67.8 + * This file is a part of LEMON, a generic C++ optimization library.
67.9 *
67.10 * Copyright (C) 2003-2008
67.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
67.12 @@ -71,7 +71,7 @@
67.13 std::vector<Arc> arcs;
67.14 for (int i = 0; i < num; ++i) {
67.15 for (int j = 0; j < i; ++j) {
67.16 - arcs.push_back(graph.addArc(nodes[i], nodes[j]));
67.17 + arcs.push_back(graph.addArc(nodes[i], nodes[j]));
67.18 }
67.19 }
67.20
67.21 @@ -84,8 +84,8 @@
67.22
67.23 for (int i = 0; i < num; ++i) {
67.24 for (int j = i + 1; j < num; ++j) {
67.25 - arcs.push_back(graph.addArc(nodes[i], nodes[j]));
67.26 - map[arcs.back()] = 23;
67.27 + arcs.push_back(graph.addArc(nodes[i], nodes[j]));
67.28 + map[arcs.back()] = 23;
67.29 check(map[arcs.back()] == 23, "Wrong operator[].");
67.30 }
67.31 }
67.32 @@ -113,7 +113,7 @@
67.33 std::vector<Edge> edges;
67.34 for (int i = 0; i < num; ++i) {
67.35 for (int j = 0; j < i; ++j) {
67.36 - edges.push_back(graph.addEdge(nodes[i], nodes[j]));
67.37 + edges.push_back(graph.addEdge(nodes[i], nodes[j]));
67.38 }
67.39 }
67.40
67.41 @@ -126,8 +126,8 @@
67.42
67.43 for (int i = 0; i < num; ++i) {
67.44 for (int j = i + 1; j < num; ++j) {
67.45 - edges.push_back(graph.addEdge(nodes[i], nodes[j]));
67.46 - map[edges.back()] = 23;
67.47 + edges.push_back(graph.addEdge(nodes[i], nodes[j]));
67.48 + map[edges.back()] = 23;
67.49 check(map[edges.back()] == 23, "Wrong operator[].");
67.50 }
67.51 }
68.1 --- a/test/graph_test.cc Sun Jul 13 16:46:56 2008 +0100
68.2 +++ b/test/graph_test.cc Sun Jul 13 19:51:02 2008 +0100
68.3 @@ -1,6 +1,6 @@
68.4 -/* -*- C++ -*-
68.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
68.6 *
68.7 - * This file is a part of LEMON, a generic C++ optimization library
68.8 + * This file is a part of LEMON, a generic C++ optimization library.
68.9 *
68.10 * Copyright (C) 2003-2008
68.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
68.12 @@ -33,13 +33,13 @@
68.13 { // Checking graph components
68.14 checkConcept<BaseGraphComponent, BaseGraphComponent >();
68.15
68.16 - checkConcept<IDableGraphComponent<>,
68.17 + checkConcept<IDableGraphComponent<>,
68.18 IDableGraphComponent<> >();
68.19
68.20 - checkConcept<IterableGraphComponent<>,
68.21 + checkConcept<IterableGraphComponent<>,
68.22 IterableGraphComponent<> >();
68.23
68.24 - checkConcept<MappableGraphComponent<>,
68.25 + checkConcept<MappableGraphComponent<>,
68.26 MappableGraphComponent<> >();
68.27 }
68.28 { // Checking skeleton graph
68.29 @@ -134,7 +134,7 @@
68.30 // check(g.row(g(i, j)) == j, "Wrong row");
68.31 // }
68.32 // }
68.33 -
68.34 +
68.35 // for (int i = 0; i < w; ++i) {
68.36 // for (int j = 0; j < h - 1; ++j) {
68.37 // check(g.source(g.down(g(i, j))) == g(i, j), "Wrong down");
68.38 @@ -154,17 +154,17 @@
68.39 // for (int j = 0; j < h; ++j) {
68.40 // for (int i = 0; i < w - 1; ++i) {
68.41 // check(g.source(g.right(g(i, j))) == g(i, j), "Wrong right");
68.42 -// check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right");
68.43 +// check(g.target(g.right(g(i, j))) == g(i + 1, j), "Wrong right");
68.44 // }
68.45 -// check(g.right(g(w - 1, j)) == INVALID, "Wrong right");
68.46 +// check(g.right(g(w - 1, j)) == INVALID, "Wrong right");
68.47 // }
68.48
68.49 // for (int j = 0; j < h; ++j) {
68.50 // for (int i = 1; i < w; ++i) {
68.51 // check(g.source(g.left(g(i, j))) == g(i, j), "Wrong left");
68.52 -// check(g.target(g.left(g(i, j))) == g(i - 1, j), "Wrong left");
68.53 +// check(g.target(g.left(g(i, j))) == g(i - 1, j), "Wrong left");
68.54 // }
68.55 -// check(g.left(g(0, j)) == INVALID, "Wrong left");
68.56 +// check(g.left(g(0, j)) == INVALID, "Wrong left");
68.57 // }
68.58 // }
68.59
69.1 --- a/test/graph_test.h Sun Jul 13 16:46:56 2008 +0100
69.2 +++ b/test/graph_test.h Sun Jul 13 19:51:02 2008 +0100
69.3 @@ -1,6 +1,6 @@
69.4 -/* -*- C++ -*-
69.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
69.6 *
69.7 - * This file is a part of LEMON, a generic C++ optimization library
69.8 + * This file is a part of LEMON, a generic C++ optimization library.
69.9 *
69.10 * Copyright (C) 2003-2008
69.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
69.12 @@ -217,7 +217,7 @@
69.13 n.outcir.push_back(G.addEdge(n.outer[i],n.outer[(i+1)%num]));
69.14 n.incir.push_back(G.addEdge(n.inner[i],n.inner[(i+2)%num]));
69.15 }
69.16 -
69.17 +
69.18 return n;
69.19 }
69.20
69.21 @@ -246,7 +246,7 @@
69.22 bidirDigraph(G);
69.23 checkBidirPetersen(G, num);
69.24 }
69.25 -
69.26 +
69.27 template <class Graph>
69.28 void checkGraph() {
69.29 const int num = 5;
70.1 --- a/test/graph_utils_test.cc Sun Jul 13 16:46:56 2008 +0100
70.2 +++ b/test/graph_utils_test.cc Sun Jul 13 19:51:02 2008 +0100
70.3 @@ -1,6 +1,6 @@
70.4 -/* -*- C++ -*-
70.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
70.6 *
70.7 - * This file is a part of LEMON, a generic C++ optimization library
70.8 + * This file is a part of LEMON, a generic C++ optimization library.
70.9 *
70.10 * Copyright (C) 2003-2008
70.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
70.12 @@ -140,7 +140,7 @@
70.13 void checkDeg()
70.14 {
70.15 TEMPLATE_DIGRAPH_TYPEDEFS(Digraph);
70.16 -
70.17 +
70.18 const int nodeNum = 10;
70.19 const int arcNum = 100;
70.20 Digraph digraph;
70.21 @@ -155,11 +155,11 @@
70.22 arcs[i] = digraph.addArc(nodes[rnd[nodeNum]], nodes[rnd[nodeNum]]);
70.23 }
70.24 for (int i = 0; i < nodeNum; ++i) {
70.25 - check(inDeg[nodes[i]] == countInArcs(digraph, nodes[i]),
70.26 + check(inDeg[nodes[i]] == countInArcs(digraph, nodes[i]),
70.27 "Wrong in degree map");
70.28 }
70.29 for (int i = 0; i < nodeNum; ++i) {
70.30 - check(outDeg[nodes[i]] == countOutArcs(digraph, nodes[i]),
70.31 + check(outDeg[nodes[i]] == countOutArcs(digraph, nodes[i]),
70.32 "Wrong out degree map");
70.33 }
70.34 }
70.35 @@ -172,15 +172,15 @@
70.36 Digraph g;
70.37 Node n1=g.addNode();
70.38 Node n2=g.addNode();
70.39 -
70.40 +
70.41 InDegMap<Digraph> ind(g);
70.42 -
70.43 +
70.44 g.addArc(n1,n2);
70.45 -
70.46 +
70.47 typename Digraph::Snapshot snap(g);
70.48 -
70.49 +
70.50 OutDegMap<Digraph> outd(g);
70.51 -
70.52 +
70.53 check(ind[n1]==0 && ind[n2]==1, "Wrong InDegMap value.");
70.54 check(outd[n1]==1 && outd[n2]==0, "Wrong OutDegMap value.");
70.55
71.1 --- a/test/heap_test.cc Sun Jul 13 16:46:56 2008 +0100
71.2 +++ b/test/heap_test.cc Sun Jul 13 19:51:02 2008 +0100
71.3 @@ -1,6 +1,6 @@
71.4 -/* -*- C++ -*-
71.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
71.6 *
71.7 - * This file is a part of LEMON, a generic C++ optimization library
71.8 + * This file is a part of LEMON, a generic C++ optimization library.
71.9 *
71.10 * Copyright (C) 2003-2008
71.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
71.12 @@ -40,42 +40,42 @@
71.13 typedef ListDigraph Digraph;
71.14 DIGRAPH_TYPEDEFS(Digraph);
71.15
71.16 -char test_lgf[] =
71.17 - "@nodes\n"
71.18 - "label\n"
71.19 - "0\n"
71.20 - "1\n"
71.21 - "2\n"
71.22 - "3\n"
71.23 - "4\n"
71.24 - "5\n"
71.25 - "6\n"
71.26 - "7\n"
71.27 - "8\n"
71.28 - "9\n"
71.29 - "@arcs\n"
71.30 - " label capacity\n"
71.31 - "0 5 0 94\n"
71.32 - "3 9 1 11\n"
71.33 - "8 7 2 83\n"
71.34 - "1 2 3 94\n"
71.35 - "5 7 4 35\n"
71.36 - "7 4 5 84\n"
71.37 - "9 5 6 38\n"
71.38 - "0 4 7 96\n"
71.39 - "6 7 8 6\n"
71.40 - "3 1 9 27\n"
71.41 - "5 2 10 77\n"
71.42 - "5 6 11 69\n"
71.43 - "6 5 12 41\n"
71.44 - "4 6 13 70\n"
71.45 - "3 2 14 45\n"
71.46 - "7 9 15 93\n"
71.47 - "5 9 16 50\n"
71.48 - "9 0 17 94\n"
71.49 - "9 6 18 67\n"
71.50 - "0 9 19 86\n"
71.51 - "@attributes\n"
71.52 +char test_lgf[] =
71.53 + "@nodes\n"
71.54 + "label\n"
71.55 + "0\n"
71.56 + "1\n"
71.57 + "2\n"
71.58 + "3\n"
71.59 + "4\n"
71.60 + "5\n"
71.61 + "6\n"
71.62 + "7\n"
71.63 + "8\n"
71.64 + "9\n"
71.65 + "@arcs\n"
71.66 + " label capacity\n"
71.67 + "0 5 0 94\n"
71.68 + "3 9 1 11\n"
71.69 + "8 7 2 83\n"
71.70 + "1 2 3 94\n"
71.71 + "5 7 4 35\n"
71.72 + "7 4 5 84\n"
71.73 + "9 5 6 38\n"
71.74 + "0 4 7 96\n"
71.75 + "6 7 8 6\n"
71.76 + "3 1 9 27\n"
71.77 + "5 2 10 77\n"
71.78 + "5 6 11 69\n"
71.79 + "6 5 12 41\n"
71.80 + "4 6 13 70\n"
71.81 + "3 2 14 45\n"
71.82 + "7 9 15 93\n"
71.83 + "5 9 16 50\n"
71.84 + "9 0 17 94\n"
71.85 + "9 6 18 67\n"
71.86 + "0 9 19 86\n"
71.87 + "@attributes\n"
71.88 "source 3\n";
71.89
71.90 int test_seq[] = { 2, 28, 19, 27, 33, 25, 13, 41, 10, 26, 1, 9, 4, 34};
71.91 @@ -88,7 +88,7 @@
71.92 RangeMap<int> map(test_len, -1);
71.93
71.94 Heap heap(map);
71.95 -
71.96 +
71.97 std::vector<int> v(test_len);
71.98
71.99 for (int i = 0; i < test_len; ++i) {
71.100 @@ -107,7 +107,7 @@
71.101 RangeMap<int> map(test_len, -1);
71.102
71.103 Heap heap(map);
71.104 -
71.105 +
71.106 std::vector<int> v(test_len);
71.107
71.108 for (int i = 0; i < test_len; ++i) {
71.109 @@ -128,20 +128,20 @@
71.110
71.111
71.112 template <typename Heap>
71.113 -void dijkstraHeapTest(const Digraph& digraph, const IntArcMap& length,
71.114 - Node source) {
71.115 -
71.116 +void dijkstraHeapTest(const Digraph& digraph, const IntArcMap& length,
71.117 + Node source) {
71.118 +
71.119 typename Dijkstra<Digraph, IntArcMap>::template DefStandardHeap<Heap>::
71.120 Create dijkstra(digraph, length);
71.121
71.122 dijkstra.run(source);
71.123
71.124 for(ArcIt a(digraph); a != INVALID; ++a) {
71.125 - Node s = digraph.source(a);
71.126 + Node s = digraph.source(a);
71.127 Node t = digraph.target(a);
71.128 if (dijkstra.reached(s)) {
71.129 check( dijkstra.dist(t) - dijkstra.dist(s) <= length[a],
71.130 - "Error in a shortest path tree!");
71.131 + "Error in a shortest path tree!");
71.132 }
71.133 }
71.134
71.135 @@ -150,7 +150,7 @@
71.136 Arc a = dijkstra.predArc(n);
71.137 Node s = digraph.source(a);
71.138 check( dijkstra.dist(n) - dijkstra.dist(s) == length[a],
71.139 - "Error in a shortest path tree!");
71.140 + "Error in a shortest path tree!");
71.141 }
71.142 }
71.143
71.144 @@ -161,7 +161,7 @@
71.145 typedef int Item;
71.146 typedef int Prio;
71.147 typedef RangeMap<int> ItemIntMap;
71.148 -
71.149 +
71.150 Digraph digraph;
71.151 IntArcMap length(digraph);
71.152 Node source;
71.153 @@ -170,14 +170,14 @@
71.154 digraphReader(input, digraph).
71.155 arcMap("capacity", length).
71.156 node("source", source).
71.157 - run();
71.158 -
71.159 + run();
71.160 +
71.161 {
71.162 typedef BinHeap<Prio, ItemIntMap> IntHeap;
71.163 checkConcept<Heap<Prio, ItemIntMap>, IntHeap>();
71.164 heapSortTest<IntHeap>();
71.165 heapIncreaseTest<IntHeap>();
71.166 -
71.167 +
71.168 typedef BinHeap<Prio, IntNodeMap > NodeHeap;
71.169 checkConcept<Heap<Prio, IntNodeMap >, NodeHeap>();
71.170 dijkstraHeapTest<NodeHeap>(digraph, length, source);
72.1 --- a/test/kruskal_test.cc Sun Jul 13 16:46:56 2008 +0100
72.2 +++ b/test/kruskal_test.cc Sun Jul 13 19:51:02 2008 +0100
72.3 @@ -1,6 +1,6 @@
72.4 -/* -*- C++ -*-
72.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
72.6 *
72.7 - * This file is a part of LEMON, a generic C++ optimization library
72.8 + * This file is a part of LEMON, a generic C++ optimization library.
72.9 *
72.10 * Copyright (C) 2003-2008
72.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
72.12 @@ -73,7 +73,7 @@
72.13 Node v3=G.addNode();
72.14 Node v4=G.addNode();
72.15 Node t=G.addNode();
72.16 -
72.17 +
72.18 Edge e1 = G.addEdge(s, v1);
72.19 Edge e2 = G.addEdge(s, v2);
72.20 Edge e3 = G.addEdge(v1, v2);
72.21 @@ -90,14 +90,14 @@
72.22
72.23 ECostMap edge_cost_map(G, 2);
72.24 EBoolMap tree_map(G);
72.25 -
72.26 +
72.27
72.28 //Test with const map.
72.29 check(kruskal(G, ConstMap<ListGraph::Edge,int>(2), tree_map)==10,
72.30 - "Total cost should be 10");
72.31 + "Total cost should be 10");
72.32 //Test with an edge map (filled with uniform costs).
72.33 check(kruskal(G, edge_cost_map, tree_map)==10,
72.34 - "Total cost should be 10");
72.35 + "Total cost should be 10");
72.36
72.37 edge_cost_map.set(e1, -10);
72.38 edge_cost_map.set(e2, -9);
72.39 @@ -114,34 +114,34 @@
72.40
72.41 //Test with a edge map and inserter.
72.42 check(kruskal(G, edge_cost_map,
72.43 - tree_edge_vec.begin())
72.44 - ==-31,
72.45 - "Total cost should be -31.");
72.46 -
72.47 + tree_edge_vec.begin())
72.48 + ==-31,
72.49 + "Total cost should be -31.");
72.50 +
72.51 tree_edge_vec.clear();
72.52
72.53 check(kruskal(G, edge_cost_map,
72.54 - back_inserter(tree_edge_vec))
72.55 - ==-31,
72.56 - "Total cost should be -31.");
72.57 -
72.58 + back_inserter(tree_edge_vec))
72.59 + ==-31,
72.60 + "Total cost should be -31.");
72.61 +
72.62 // tree_edge_vec.clear();
72.63 -
72.64 +
72.65 // //The above test could also be coded like this:
72.66 // check(kruskal(G,
72.67 -// makeKruskalMapInput(G, edge_cost_map),
72.68 -// makeKruskalSequenceOutput(back_inserter(tree_edge_vec)))
72.69 -// ==-31,
72.70 -// "Total cost should be -31.");
72.71 +// makeKruskalMapInput(G, edge_cost_map),
72.72 +// makeKruskalSequenceOutput(back_inserter(tree_edge_vec)))
72.73 +// ==-31,
72.74 +// "Total cost should be -31.");
72.75
72.76 check(tree_edge_vec.size()==5,"The tree should have 5 edges.");
72.77
72.78 check(tree_edge_vec[0]==e1 &&
72.79 - tree_edge_vec[1]==e2 &&
72.80 - tree_edge_vec[2]==e5 &&
72.81 - tree_edge_vec[3]==e7 &&
72.82 - tree_edge_vec[4]==e9,
72.83 - "Wrong tree.");
72.84 + tree_edge_vec[1]==e2 &&
72.85 + tree_edge_vec[2]==e5 &&
72.86 + tree_edge_vec[3]==e7 &&
72.87 + tree_edge_vec[4]==e9,
72.88 + "Wrong tree.");
72.89
72.90 return 0;
72.91 }
73.1 --- a/test/maps_test.cc Sun Jul 13 16:46:56 2008 +0100
73.2 +++ b/test/maps_test.cc Sun Jul 13 19:51:02 2008 +0100
73.3 @@ -1,6 +1,6 @@
73.4 -/* -*- C++ -*-
73.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
73.6 *
73.7 - * This file is a part of LEMON, a generic C++ optimization library
73.8 + * This file is a part of LEMON, a generic C++ optimization library.
73.9 *
73.10 * Copyright (C) 2003-2008
73.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
73.12 @@ -304,7 +304,7 @@
73.13 check(!equalMap(id,cm)[1] && equalMap(id,cm)[2] && !equalMap(id,cm)[3],
73.14 "Something is wrong with EqualMap");
73.15 }
73.16 -
73.17 +
73.18 // LoggerBoolMap
73.19 {
73.20 typedef std::vector<int> vec;
73.21 @@ -320,7 +320,7 @@
73.22 check(v1.size() == 3 && v2.size() == 10 &&
73.23 v1[0]==20 && v1[1]==50 && v1[2]==60 && v2[0]==20 && v2[1]==50 && v2[2]==60,
73.24 "Something is wrong with LoggerBoolMap");
73.25 -
73.26 +
73.27 int i = 0;
73.28 for ( LoggerBoolMap<vec::iterator>::Iterator it = map2.begin();
73.29 it != map2.end(); ++it )
74.1 --- a/test/path_test.cc Sun Jul 13 16:46:56 2008 +0100
74.2 +++ b/test/path_test.cc Sun Jul 13 19:51:02 2008 +0100
74.3 @@ -1,6 +1,6 @@
74.4 -/* -*- C++ -*-
74.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
74.6 *
74.7 - * This file is a part of LEMON, a generic C++ optimization library
74.8 + * This file is a part of LEMON, a generic C++ optimization library.
74.9 *
74.10 * Copyright (C) 2003-2008
74.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
74.12 @@ -39,6 +39,6 @@
74.13 }
74.14
74.15 int main() {
74.16 - check_concepts();
74.17 + check_concepts();
74.18 return 0;
74.19 }
75.1 --- a/test/random_test.cc Sun Jul 13 16:46:56 2008 +0100
75.2 +++ b/test/random_test.cc Sun Jul 13 19:51:02 2008 +0100
75.3 @@ -1,6 +1,6 @@
75.4 -/* -*- C++ -*-
75.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
75.6 *
75.7 - * This file is a part of LEMON, a generic C++ optimization library
75.8 + * This file is a part of LEMON, a generic C++ optimization library.
75.9 *
75.10 * Copyright (C) 2003-2008
75.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
75.12 @@ -33,8 +33,8 @@
75.13 a=lemon::rnd.poisson(.5);
75.14
75.15 lemon::rnd.seed(100);
75.16 - lemon::rnd.seed(seed_array, seed_array +
75.17 - (sizeof(seed_array) / sizeof(seed_array[0])));
75.18 + lemon::rnd.seed(seed_array, seed_array +
75.19 + (sizeof(seed_array) / sizeof(seed_array[0])));
75.20
75.21 return 0;
75.22 }
76.1 --- a/test/test_tools.h Sun Jul 13 16:46:56 2008 +0100
76.2 +++ b/test/test_tools.h Sun Jul 13 19:51:02 2008 +0100
76.3 @@ -1,6 +1,6 @@
76.4 -/* -*- C++ -*-
76.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
76.6 *
76.7 - * This file is a part of LEMON, a generic C++ optimization library
76.8 + * This file is a part of LEMON, a generic C++ optimization library.
76.9 *
76.10 * Copyright (C) 2003-2008
76.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
77.1 --- a/test/test_tools_fail.cc Sun Jul 13 16:46:56 2008 +0100
77.2 +++ b/test/test_tools_fail.cc Sun Jul 13 19:51:02 2008 +0100
77.3 @@ -1,6 +1,6 @@
77.4 -/* -*- C++ -*-
77.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
77.6 *
77.7 - * This file is a part of LEMON, a generic C++ optimization library
77.8 + * This file is a part of LEMON, a generic C++ optimization library.
77.9 *
77.10 * Copyright (C) 2003-2008
77.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
77.12 @@ -18,7 +18,7 @@
77.13
77.14 #include "test_tools.h"
77.15
77.16 -int main()
77.17 +int main()
77.18 {
77.19 check(false, "Don't panic. Failing is the right behaviour here.");
77.20 return 0;
78.1 --- a/test/test_tools_pass.cc Sun Jul 13 16:46:56 2008 +0100
78.2 +++ b/test/test_tools_pass.cc Sun Jul 13 19:51:02 2008 +0100
78.3 @@ -1,6 +1,6 @@
78.4 -/* -*- C++ -*-
78.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
78.6 *
78.7 - * This file is a part of LEMON, a generic C++ optimization library
78.8 + * This file is a part of LEMON, a generic C++ optimization library.
78.9 *
78.10 * Copyright (C) 2003-2008
78.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
78.12 @@ -18,7 +18,7 @@
78.13
78.14 #include "test_tools.h"
78.15
78.16 -int main()
78.17 +int main()
78.18 {
78.19 check(true, "It should pass.");
78.20 return 0;
79.1 --- a/test/time_measure_test.cc Sun Jul 13 16:46:56 2008 +0100
79.2 +++ b/test/time_measure_test.cc Sun Jul 13 19:51:02 2008 +0100
79.3 @@ -1,6 +1,6 @@
79.4 -/* -*- C++ -*-
79.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
79.6 *
79.7 - * This file is a part of LEMON, a generic C++ optimization library
79.8 + * This file is a part of LEMON, a generic C++ optimization library.
79.9 *
79.10 * Copyright (C) 2003-2008
79.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
79.12 @@ -20,17 +20,17 @@
79.13
79.14 using namespace lemon;
79.15
79.16 -void f()
79.17 +void f()
79.18 {
79.19 double d=0;
79.20 for(int i=0;i<1000;i++)
79.21 d+=0.1;
79.22 }
79.23
79.24 -void g()
79.25 +void g()
79.26 {
79.27 static Timer T;
79.28 -
79.29 +
79.30 for(int i=0;i<1000;i++)
79.31 TimeStamp x(T);
79.32 }
79.33 @@ -49,10 +49,10 @@
79.34 t=runningTimeTest(f,1,&n,&full);
79.35 std::cout << t << " (" << n << " tests)\n";
79.36 std::cout << "Total: " << full << "\n";
79.37 -
79.38 +
79.39 t=runningTimeTest(g,1,&n,&full);
79.40 std::cout << t << " (" << n << " tests)\n";
79.41 std::cout << "Total: " << full << "\n";
79.42 -
79.43 +
79.44 return 0;
79.45 }
80.1 --- a/test/unionfind_test.cc Sun Jul 13 16:46:56 2008 +0100
80.2 +++ b/test/unionfind_test.cc Sun Jul 13 19:51:02 2008 +0100
80.3 @@ -1,6 +1,6 @@
80.4 -/* -*- C++ -*-
80.5 +/* -*- mode: C++; indent-tabs-mode: nil; -*-
80.6 *
80.7 - * This file is a part of LEMON, a generic C++ optimization library
80.8 + * This file is a part of LEMON, a generic C++ optimization library.
80.9 *
80.10 * Copyright (C) 2003-2008
80.11 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
80.12 @@ -31,7 +31,7 @@
80.13 ListGraph::NodeMap<int> base(g);
80.14 UFE U(base);
80.15 vector<ListGraph::Node> n;
80.16 -
80.17 +
80.18 for(int i=0;i<20;i++) n.push_back(g.addNode());
80.19
80.20 U.insert(n[1]);