gravatar
kpeter (Peter Kovacs)
kpeter@inf.elte.hu
Improve the migration script and guide (#166) - Safer replacement of 'graph' and 'edge'. - Fix the erroneous renaming of [Gg]raphToEps. - Fixes and improvements in the migration guide.
0 2 0
default
2 files changed with 31 insertions and 18 deletions:
↑ Collapse diff ↑
Ignore white space 192 line context
1 1
/* -*- mode: C++; indent-tabs-mode: nil; -*-
2 2
 *
3 3
 * This file is a part of LEMON, a generic C++ optimization library.
4 4
 *
5 5
 * Copyright (C) 2003-2008
6 6
 * Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport
7 7
 * (Egervary Research Group on Combinatorial Optimization, EGRES).
8 8
 *
9 9
 * Permission to use, modify and distribute this software is granted
10 10
 * provided that this copyright notice appears in all copies. For
11 11
 * precise terms see the accompanying LICENSE file.
12 12
 *
13 13
 * This software is provided "AS IS" with no warranty of any kind,
14 14
 * express or implied, and with no claim as to its suitability for any
15 15
 * purpose.
16 16
 *
17 17
 */
18 18

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

	
22 22
\page migration Migration from the 0.x Series
23 23

	
24 24
This guide gives an in depth description on what has changed compared
25 25
to the 0.x release series.
26 26

	
27 27
Many of these changes adjusted automatically by the
28
<tt>script/lemon-0.x-to-1.x.sh</tt> tool. Those requiring manual
28
<tt>lemon-0.x-to-1.x.sh</tt> tool. Those requiring manual
29 29
update are typeset <b>boldface</b>.
30 30

	
31 31
\section migration-graph Graph Related Name Changes
32 32

	
33 33
- \ref concepts::Digraph "Directed graphs" are called \c Digraph and
34 34
  they have <tt>Arc</tt>s (instead of <tt>Edge</tt>s), while
35 35
  \ref concepts::Graph "undirected graphs" are called \c Graph
36 36
  (instead of \c UGraph) and they have <tt>Edge</tt>s (instead of
37 37
  <tt>UEdge</tt>s). These changes reflected thoroughly everywhere in
38 38
  the library. Namely,
39 39
  - \c Graph -> \c Digraph
40 40
    - \c %ListGraph -> \c ListDigraph, \c %SmartGraph -> \c SmartDigraph etc.
41 41
  - \c UGraph -> \c Graph
42 42
    - \c ListUGraph -> \c ListGraph, \c SmartUGraph -> \c SmartGraph etc.
43 43
  - \c Edge -> \c Arc, \c UEdge -> \c Edge
44 44
  - \c EdgeMap -> \c ArcMap, \c UEdgeMap -> \c EdgeMap
45 45
  - \c EdgeIt -> \c ArcIt, \c UEdgeIt -> \c EdgeIt
46 46
  - Class names and function names containing the words \c graph,
47 47
    \c ugraph, \e edge or \e arc should also be updated.
48 48
- <b>The two endpoints of an (\e undirected) \c Edge can be obtained by the
49 49
  <tt>u()</tt> and <tt>v()</tt> member function of the graph
50 50
  (instead of <tt>source()</tt> and <tt>target()</tt>). This change
51 51
  must be done by hand.</b>
52 52
  \n Of course, you can still use <tt>source()</tt> and <tt>target()</tt>
53 53
  for <tt>Arc</tt>s (directed edges).
54 54

	
55 55
\warning
56
<b>The <tt>script/lemon-0.x-to-1.x.sh</tt> tool replaces all instances of
57
the words \c graph, \c digraph, \c edge and \c arc, so it replaces them
58
in strings, comments etc. as well as in all identifiers.</b>
56
<b>The <tt>lemon-0.x-to-1.x.sh</tt> script replaces the words \c graph,
57
\c ugraph, \c edge and \c uedge in your own identifiers and in
58
strings, comments etc. as well as in all LEMON specific identifiers.
59
So use the script carefully and make a backup copy of your source files
60
before applying the script to them.</b>
59 61

	
60 62
\section migration-lgf LGF tools
61 63
 - The \ref lgf-format "LGF file format" has changed,
62 64
   <tt>\@nodeset</tt> has changed to <tt>\@nodes</tt>,
63 65
   <tt>\@edgeset</tt> and <tt>\@uedgeset</tt> to <tt>\@arcs</tt> or
64 66
   <tt>\@edges</tt>, which become completely equivalents. The
65 67
   <tt>\@nodes</tt>, <tt>\@edges</tt> and <tt>\@uedges</tt> sections are
66 68
   removed from the format, the content of them should be
67 69
   the part of <tt>\@attributes</tt> section. The data fields in
68 70
   the sections must follow a strict format, they must be either character
69 71
   sequences without whitespaces or quoted strings.
70 72
 - The <tt>LemonReader</tt> and <tt>LemonWriter</tt> core interfaces
71 73
   are no longer available.
72 74
 - The implementation of the general section readers and writers has changed
73 75
   they are simple functors now. Beside the old
74 76
   stream based section handling, currently line oriented section
75 77
   reading and writing are also supported. In the
76 78
   section readers the lines must be counted manually. The sections
77 79
   should be read and written with the SectionWriter and SectionReader
78 80
   classes.
79 81
 - Instead of the item readers and writers, item converters should be
80 82
   used. The converters are functors, which map the type to
81 83
   std::string or std::string to the type. The converters for standard
82 84
   containers hasn't yet been implemented in the new LEMON. The converters
83 85
   can return strings in any format, because if it is necessary, the LGF
84 86
   writer and reader will quote and unquote the given value.
85 87
 - The DigraphReader and DigraphWriter can used similarly to the
86 88
   0.x series, however the <tt>read</tt> or <tt>write</tt> prefix of
87 89
   the member functions are removed.
88 90
 - The new LEMON supports the function like interface, the \c
89 91
   digraphReader and \c digraphWriter functions are more convenient than
90 92
   using the classes directly.
91 93

	
92 94
\section migration-search BFS, DFS and Dijkstra
93 95
- <b>Using the function interface of BFS, DFS and %Dijkstra both source and
94 96
  target nodes can be given as parameters of the <tt>run()</tt> function
95 97
  (instead of \c bfs(), \c dfs() or \c dijkstra() itself).</b>
96 98
- \ref named-templ-param "Named class template parameters" of \c Bfs,
97 99
  \c Dfs, \c Dijkstra, \c BfsVisit, \c DfsVisit are renamed to start
98 100
  with "Set" instead of "Def". Namely,
99 101
  - \c DefPredMap -> \c SetPredMap
100 102
  - \c DefDistMap -> \c SetDistMap
101 103
  - \c DefReachedMap -> \c SetReachedMap
102 104
  - \c DefProcessedMap -> \c SetProcessedMap
103 105
  - \c DefHeap -> \c SetHeap
104 106
  - \c DefStandardHeap -> \c SetStandardHeap
105 107
  - \c DefOperationTraits -> \c SetOperationTraits
106 108
  - \c DefProcessedMapToBeDefaultMap -> \c SetStandardProcessedMap
107 109

	
108 110
\section migration-error Exceptions and Debug tools
109 111

	
110 112
<b>The class hierarchy of exceptions has largely been simplified. Now,
111 113
only the i/o related tools may throw exceptions. All other exceptions
112 114
have been replaced with either the \c LEMON_ASSERT or the \c LEMON_DEBUG
113 115
macros.</b>
114 116

	
115 117
<b>On the other hand, the parameter order of constructors of the
116 118
exceptions has been changed. See \ref IoError and \ref FormatError for
117 119
more details.</b>
118 120

	
119 121
\section migration-other Others
120 122
- <b>The contents of <tt>graph_utils.h</tt> are moved to <tt>core.h</tt>
121 123
  and <tt>maps.h</tt>. <tt>core.h</tt> is included by all graph types,
122 124
  therefore it usually do not have to be included directly.</b>
123 125
- <b><tt>path_utils.h</tt> is merged to \c path.h.</b>
124 126
- <b>The semantic of the assignment operations and copy constructors of maps
125 127
  are still under discussion. So, you must copy them by hand (i.e. copy
126 128
  each entry one-by-one)</b>
127 129
- <b>The parameters of the graph copying tools (i.e. \c GraphCopy,
128 130
  \c DigraphCopy) have to be given in the from-to order.</b>
129 131
- \c copyDigraph() and \c copyGraph() are renamed to \c digraphCopy()
130 132
  and \c graphCopy(), respectively.
131 133
- <b>The interface of \ref DynArcLookUp has changed. It is now the same as
132 134
  of \ref ArcLookUp and \ref AllArcLookUp</b>
133 135
- Some map types should also been renamed. Namely,
134 136
  - \c IntegerMap -> \c RangeMap
135 137
  - \c StdMap -> \c SparseMap
136 138
  - \c FunctorMap -> \c FunctorToMap
137 139
  - \c MapFunctor -> \c MapToFunctor
138 140
  - \c ForkWriteMap -> \c ForkMap
139 141
  - \c StoreBoolMap -> \c LoggerBoolMap
140 142
- \c dim2::BoundingBox -> \c dim2::Box
141 143

	
142 144
*/
143 145
}
Ignore white space 192 line context
1 1
#!/bin/bash
2 2

	
3 3
set -e
4 4

	
5 5
if [ $# -eq 0 -o x$1 = "x-h" -o x$1 = "x-help" -o x$1 = "x--help" ]; then
6 6
    echo "Usage:"
7 7
    echo "  $0 source-file(s)"
8 8
    exit
9 9
fi
10 10

	
11 11
for i in $@
12 12
do
13 13
    echo Update $i...
14 14
    TMP=`mktemp`
15 15
    sed -e "s/undirected graph/_gr_aph_label_/g"\
16 16
        -e "s/undirected edge/_ed_ge_label_/g"\
17
        -e "s/graph_/_gr_aph_label__/g"\
18
        -e "s/_graph/__gr_aph_label_/g"\
19 17
        -e "s/UGraph/_Gr_aph_label_/g"\
20
        -e "s/uGraph/_gr_aph_label_/g"\
21
        -e "s/ugraph/_gr_aph_label_/g"\
18
        -e "s/u[Gg]raph/_gr_aph_label_/g"\
19
        -e "s/\<Graph\>/_Digr_aph_label_/g"\
20
        -e "s/\<graph\>/_digr_aph_label_/g"\
21
        -e "s/\<Graphs\>/_Digr_aph_label_s/g"\
22
        -e "s/\<graphs\>/_digr_aph_label_s/g"\
23
        -e "s/_Graph/__Gr_aph_label_/g"\
24
        -e "s/\([Gg]\)raph\([a-z_]\)/_\1r_aph_label_\2/g"\
25
        -e "s/\([a-z_]\)graph/\1_gr_aph_label_/g"\
22 26
        -e "s/Graph/_Digr_aph_label_/g"\
23 27
        -e "s/graph/_digr_aph_label_/g"\
24 28
        -e "s/UEdge/_Ed_ge_label_/g"\
25
        -e "s/uEdge/_ed_ge_label_/g"\
26
        -e "s/uedge/_ed_ge_label_/g"\
29
        -e "s/u[Ee]dge/_ed_ge_label_/g"\
27 30
        -e "s/IncEdgeIt/_In_cEd_geIt_label_/g"\
31
        -e "s/\<Edge\>/_Ar_c_label_/g"\
32
        -e "s/\<edge\>/_ar_c_label_/g"\
33
        -e "s/\<Edges\>/_Ar_c_label_s/g"\
34
        -e "s/\<edges\>/_ar_c_label_s/g"\
35
        -e "s/_Edge/__Ed_ge_label_/g"\
36
        -e "s/Edge\([a-z_]\)/_Ed_ge_label_\1/g"\
37
        -e "s/edge\([a-z_]\)/_ed_ge_label_\1/g"\
38
        -e "s/\([a-z_]\)edge/\1_ed_ge_label_/g"\
28 39
        -e "s/Edge/_Ar_c_label_/g"\
29 40
        -e "s/edge/_ar_c_label_/g"\
30
        -e "s/ANode/_Re_d_label_/g"\
31
        -e "s/BNode/_Blu_e_label_/g"\
32
        -e "s/A-Node/_Re_d_label_/g"\
33
        -e "s/B-Node/_Blu_e_label_/g"\
34
        -e "s/anode/_re_d_label_/g"\
35
        -e "s/bnode/_blu_e_label_/g"\
36
        -e "s/aNode/_re_d_label_/g"\
37
        -e "s/bNode/_blu_e_label_/g"\
41
        -e "s/A[Nn]ode/_Re_d_label_/g"\
42
        -e "s/B[Nn]ode/_Blu_e_label_/g"\
43
        -e "s/A-[Nn]ode/_Re_d_label_/g"\
44
        -e "s/B-[Nn]ode/_Blu_e_label_/g"\
45
        -e "s/a[Nn]ode/_re_d_label_/g"\
46
        -e "s/b[Nn]ode/_blu_e_label_/g"\
38 47
        -e "s/_Digr_aph_label_/Digraph/g"\
39 48
        -e "s/_digr_aph_label_/digraph/g"\
40 49
        -e "s/_Gr_aph_label_/Graph/g"\
41 50
        -e "s/_gr_aph_label_/graph/g"\
42 51
        -e "s/_Ar_c_label_/Arc/g"\
43 52
        -e "s/_ar_c_label_/arc/g"\
44 53
        -e "s/_Ed_ge_label_/Edge/g"\
45 54
        -e "s/_ed_ge_label_/edge/g"\
46 55
        -e "s/_In_cEd_geIt_label_/IncEdgeIt/g"\
47 56
        -e "s/_Re_d_label_/Red/g"\
48 57
        -e "s/_Blu_e_label_/Blue/g"\
49 58
        -e "s/_re_d_label_/red/g"\
50 59
        -e "s/_blu_e_label_/blue/g"\
60
        -e "s/DigraphToEps/GraphToEps/g"\
61
        -e "s/digraphToEps/graphToEps/g"\
51 62
        -e "s/\<DefPredMap\>/SetPredMap/g"\
52 63
        -e "s/\<DefDistMap\>/SetDistMap/g"\
53 64
        -e "s/\<DefReachedMap\>/SetReachedMap/g"\
54 65
        -e "s/\<DefProcessedMap\>/SetProcessedMap/g"\
55 66
        -e "s/\<DefHeap\>/SetHeap/g"\
56 67
        -e "s/\<DefStandardHeap\>/SetStandradHeap/g"\
57 68
        -e "s/\<DefOperationTraits\>/SetOperationTraits/g"\
58 69
        -e "s/\<DefProcessedMapToBeDefaultMap\>/SetStandardProcessedMap/g"\
59 70
        -e "s/\<copyGraph\>/graphCopy/g"\
60 71
        -e "s/\<copyDigraph\>/digraphCopy/g"\
61 72
        -e "s/\<IntegerMap\>/RangeMap/g"\
62 73
        -e "s/\<integerMap\>/rangeMap/g"\
63 74
        -e "s/\<\([sS]\)tdMap\>/\1parseMap/g"\
64 75
        -e "s/\<\([Ff]\)unctorMap\>/\1unctorToMap/g"\
65 76
        -e "s/\<\([Mm]\)apFunctor\>/\1apToFunctor/g"\
66 77
        -e "s/\<\([Ff]\)orkWriteMap\>/\1orkMap/g"\
67 78
        -e "s/\<StoreBoolMap\>/LoggerBoolMap/g"\
68 79
        -e "s/\<storeBoolMap\>/loggerBoolMap/g"\
69 80
        -e "s/\<BoundingBox\>/Box/g"\
70 81
    <$i > $TMP
71 82
    mv $TMP $i
72 83
done
0 comments (0 inline)