1
38
2
1
1
4
14
19
17
1
1
46
46
13
13
46
46
34
34
19
35
48
68
46
68
97
87
1
1
1 |
/* -*- mode: C++; indent-tabs-mode: nil; -*- |
|
2 |
* |
|
3 |
* This file is a part of LEMON, a generic C++ optimization library. |
|
4 |
* |
|
5 |
* Copyright (C) 2003-2008 |
|
6 |
* Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport |
|
7 |
* (Egervary Research Group on Combinatorial Optimization, EGRES). |
|
8 |
* |
|
9 |
* Permission to use, modify and distribute this software is granted |
|
10 |
* provided that this copyright notice appears in all copies. For |
|
11 |
* precise terms see the accompanying LICENSE file. |
|
12 |
* |
|
13 |
* This software is provided "AS IS" with no warranty of any kind, |
|
14 |
* express or implied, and with no claim as to its suitability for any |
|
15 |
* purpose. |
|
16 |
* |
|
17 |
*/ |
|
18 |
|
|
19 |
namespace lemon { |
|
20 |
/*! |
|
21 |
|
|
22 |
\page migration Migration from the 0.x Series |
|
23 |
|
|
24 |
This guide gives an in depth description on what has changed compared |
|
25 |
to the 0.x release series. |
|
26 |
|
|
27 |
Many of these changes adjusted automatically by the |
|
28 |
<tt>script/lemon-0.x-to-1.x.sh</tt> tool. Those requiring manual |
|
29 |
update are typeset <b>boldface</b>. |
|
30 |
|
|
31 |
\section migration-graph Graph Related Name Changes |
|
32 |
|
|
33 |
- \ref concepts::Digraph "Directed graphs" are called \c Digraph and |
|
34 |
they have <tt>Arc</tt>s (instead of <tt>Edge</tt>s), while |
|
35 |
\ref concepts::Graph "undirected graphs" are called \c Graph |
|
36 |
(instead of \c UGraph) and they have <tt>Edge</tt>s (instead of |
|
37 |
<tt>UEdge</tt>s). These changes reflected thoroughly everywhere in |
|
38 |
the library. Namely, |
|
39 |
- \c Graph -> \c Digraph |
|
40 |
- \c %ListGraph -> \c ListDigraph, \c %SmartGraph -> \c SmartDigraph etc. |
|
41 |
- \c UGraph -> \c Graph |
|
42 |
- \c ListUGraph -> \c ListGraph, \c SmartUGraph -> \c SmartGraph etc. |
|
43 |
- \c Edge -> \c Arc, \c UEdge -> \c Edge |
|
44 |
- \c EdgeMap -> \c ArcMap, \c UEdgeMap -> \c EdgeMap |
|
45 |
- \c EdgeIt -> \c ArcIt, \c UEdgeIt -> \c EdgeIt |
|
46 |
- Class names and function names containing the words \c graph, |
|
47 |
\c ugraph, \e edge or \e arc should also be updated. |
|
48 |
- <b>The two endpoints of an (\e undirected) \c Edge can be obtained by the |
|
49 |
<tt>u()</tt> and <tt>v()</tt> member function of the graph |
|
50 |
(instead of <tt>source()</tt> and <tt>target()</tt>). This change |
|
51 |
must be done by hand.</b> |
|
52 |
\n Of course, you can still use <tt>source()</tt> and <tt>target()</tt> |
|
53 |
for <tt>Arc</tt>s (directed edges). |
|
54 |
|
|
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> |
|
59 |
|
|
60 |
\section migration-lgf LGF tools |
|
61 |
- The \ref lgf-format "LGF file format" has changed, |
|
62 |
<tt>\@nodeset</tt> has changed to <tt>\@nodes</tt>, |
|
63 |
<tt>\@edgeset</tt> and <tt>\@uedgeset</tt> to <tt>\@arcs</tt> or |
|
64 |
<tt>\@edges</tt>, which become completely equivalents. The |
|
65 |
<tt>\@nodes</tt>, <tt>\@edges</tt> and <tt>\@uedges</tt> sections are |
|
66 |
removed from the format, the content of them should be |
|
67 |
the part of <tt>\@attributes</tt> section. The data fields in |
|
68 |
the sections must follow a strict format, they must be either character |
|
69 |
sequences without whitespaces or quoted strings. |
|
70 |
- The <tt>LemonReader</tt> and <tt>LemonWriter</tt> core interfaces |
|
71 |
are no longer available. |
|
72 |
- The implementation of the general section readers and writers has changed |
|
73 |
they are simple functors now. Beside the old |
|
74 |
stream based section handling, currently line oriented section |
|
75 |
reading and writing are also supported. In the |
|
76 |
section readers the lines must be counted manually. The sections |
|
77 |
should be read and written with the SectionWriter and SectionReader |
|
78 |
classes. |
|
79 |
- Instead of the item readers and writers, item converters should be |
|
80 |
used. The converters are functors, which map the type to |
|
81 |
std::string or std::string to the type. The converters for standard |
|
82 |
containers hasn't yet been implemented in the new LEMON. The converters |
|
83 |
can return strings in any format, because if it is necessary, the LGF |
|
84 |
writer and reader will quote and unquote the given value. |
|
85 |
- The DigraphReader and DigraphWriter can used similarly to the |
|
86 |
0.x series, however the <tt>read</tt> or <tt>write</tt> prefix of |
|
87 |
the member functions are removed. |
|
88 |
- The new LEMON supports the function like interface, the \c |
|
89 |
digraphReader and \c digraphWriter functions are more convenient than |
|
90 |
using the classes directly. |
|
91 |
|
|
92 |
\section migration-search BFS, DFS and Dijkstra |
|
93 |
- <b>Using the function interface of BFS, DFS and %Dijkstra both source and |
|
94 |
target nodes can be given as parameters of the <tt>run()</tt> function |
|
95 |
(instead of \c bfs(), \c dfs() or \c dijkstra() itself).</b> |
|
96 |
- \ref named-templ-param "Named class template parameters" of \c Bfs, |
|
97 |
\c Dfs, \c Dijkstra, \c BfsVisit, \c DfsVisit are renamed to start |
|
98 |
with "Set" instead of "Def". Namely, |
|
99 |
- \c DefPredMap -> \c SetPredMap |
|
100 |
- \c DefDistMap -> \c SetDistMap |
|
101 |
- \c DefReachedMap -> \c SetReachedMap |
|
102 |
- \c DefProcessedMap -> \c SetProcessedMap |
|
103 |
- \c DefHeap -> \c SetHeap |
|
104 |
- \c DefStandardHeap -> \c SetStandardHeap |
|
105 |
- \c DefOperationTraits -> \c SetOperationTraits |
|
106 |
- \c DefProcessedMapToBeDefaultMap -> \c SetStandardProcessedMap |
|
107 |
|
|
108 |
\section migration-error Exceptions and Debug tools |
|
109 |
|
|
110 |
<b>The class hierarchy of exceptions has largely been simplified. Now, |
|
111 |
only the i/o related tools may throw exceptions. All other exceptions |
|
112 |
have been replaced with either the \c LEMON_ASSERT or the \c LEMON_DEBUG |
|
113 |
macros.</b> |
|
114 |
|
|
115 |
<b>On the other hand, the parameter order of constructors of the |
|
116 |
exceptions has been changed. See \ref IoError and \ref FormatError for |
|
117 |
more details.</b> |
|
118 |
|
|
119 |
\section migration-other Others |
|
120 |
- <b>The contents of <tt>graph_utils.h</tt> are moved to <tt>core.h</tt> |
|
121 |
and <tt>maps.h</tt>. <tt>core.h</tt> is included by all graph types, |
|
122 |
therefore it usually do not have to be included directly.</b> |
|
123 |
- <b><tt>path_utils.h</tt> is merged to \c path.h.</b> |
|
124 |
- <b>The semantic of the assignment operations and copy constructors of maps |
|
125 |
are still under discussion. So, you must copy them by hand (i.e. copy |
|
126 |
each entry one-by-one)</b> |
|
127 |
- <b>The parameters of the graph copying tools (i.e. \c GraphCopy, |
|
128 |
\c DigraphCopy) have to be given in the from-to order.</b> |
|
129 |
- \c copyDigraph() and \c copyGraph() are renamed to \c digraphCopy() |
|
130 |
and \c graphCopy(), respectively. |
|
131 |
- <b>The interface of \ref DynArcLookUp has changed. It is now the same as |
|
132 |
of \ref ArcLookUp and \ref AllArcLookUp</b> |
|
133 |
- Some map types should also been renamed. Namely, |
|
134 |
- \c IntegerMap -> \c RangeMap |
|
135 |
- \c StdMap -> \c SparseMap |
|
136 |
- \c FunctorMap -> \c FunctorToMap |
|
137 |
- \c MapFunctor -> \c MapToFunctor |
|
138 |
- \c ForkWriteMap -> \c ForkMap |
|
139 |
- \c StoreBoolMap -> \c LoggerBoolMap |
|
140 |
- \c dim2::BoundingBox -> \c dim2::Box |
|
141 |
|
|
142 |
*/ |
|
143 |
} |
1 |
#!/bin/bash |
|
2 |
|
|
3 |
set -e |
|
4 |
|
|
5 |
if [ $# -eq 0 -o x$1 = "x-h" -o x$1 = "x-help" -o x$1 = "x--help" ]; then |
|
6 |
echo "Usage:" |
|
7 |
echo " $0 source-file" |
|
8 |
exit |
|
9 |
fi |
|
10 |
|
|
11 |
TMP=`mktemp` |
|
12 |
|
|
13 |
sed -e "s/undirected graph/_gr_aph_label_/g"\ |
|
14 |
-e "s/undirected edge/_ed_ge_label_/g"\ |
|
15 |
-e "s/graph_/_gr_aph_label__/g"\ |
|
16 |
-e "s/_graph/__gr_aph_label_/g"\ |
|
17 |
-e "s/UGraph/_Gr_aph_label_/g"\ |
|
18 |
-e "s/uGraph/_gr_aph_label_/g"\ |
|
19 |
-e "s/ugraph/_gr_aph_label_/g"\ |
|
20 |
-e "s/Graph/_Digr_aph_label_/g"\ |
|
21 |
-e "s/graph/_digr_aph_label_/g"\ |
|
22 |
-e "s/UEdge/_Ed_ge_label_/g"\ |
|
23 |
-e "s/uEdge/_ed_ge_label_/g"\ |
|
24 |
-e "s/uedge/_ed_ge_label_/g"\ |
|
25 |
-e "s/IncEdgeIt/_In_cEd_geIt_label_/g"\ |
|
26 |
-e "s/Edge/_Ar_c_label_/g"\ |
|
27 |
-e "s/edge/_ar_c_label_/g"\ |
|
28 |
-e "s/ANode/_Re_d_label_/g"\ |
|
29 |
-e "s/BNode/_Blu_e_label_/g"\ |
|
30 |
-e "s/A-Node/_Re_d_label_/g"\ |
|
31 |
-e "s/B-Node/_Blu_e_label_/g"\ |
|
32 |
-e "s/anode/_re_d_label_/g"\ |
|
33 |
-e "s/bnode/_blu_e_label_/g"\ |
|
34 |
-e "s/aNode/_re_d_label_/g"\ |
|
35 |
-e "s/bNode/_blu_e_label_/g"\ |
|
36 |
-e "s/_Digr_aph_label_/Digraph/g"\ |
|
37 |
-e "s/_digr_aph_label_/digraph/g"\ |
|
38 |
-e "s/_Gr_aph_label_/Graph/g"\ |
|
39 |
-e "s/_gr_aph_label_/graph/g"\ |
|
40 |
-e "s/_Ar_c_label_/Arc/g"\ |
|
41 |
-e "s/_ar_c_label_/arc/g"\ |
|
42 |
-e "s/_Ed_ge_label_/Edge/g"\ |
|
43 |
-e "s/_ed_ge_label_/edge/g"\ |
|
44 |
-e "s/_In_cEd_geIt_label_/IncEdgeIt/g"\ |
|
45 |
-e "s/_Re_d_label_/Red/g"\ |
|
46 |
-e "s/_Blu_e_label_/Blue/g"\ |
|
47 |
-e "s/_re_d_label_/red/g"\ |
|
48 |
-e "s/_blu_e_label_/blue/g"\ |
|
49 |
-e "s/\(\W\)DefPredMap\(\W\)/\1SetPredMap\2/g"\ |
|
50 |
-e "s/\(\W\)DefPredMap$/\1SetPredMap/g"\ |
|
51 |
-e "s/^DefPredMap\(\W\)/SetPredMap\1/g"\ |
|
52 |
-e "s/^DefPredMap$/SetPredMap/g"\ |
|
53 |
-e "s/\(\W\)DefDistMap\(\W\)/\1SetDistMap\2/g"\ |
|
54 |
-e "s/\(\W\)DefDistMap$/\1SetDistMap/g"\ |
|
55 |
-e "s/^DefDistMap\(\W\)/SetDistMap\1/g"\ |
|
56 |
-e "s/^DefDistMap$/SetDistMap/g"\ |
|
57 |
-e "s/\(\W\)DefReachedMap\(\W\)/\1SetReachedMap\2/g"\ |
|
58 |
-e "s/\(\W\)DefReachedMap$/\1SetReachedMap/g"\ |
|
59 |
-e "s/^DefReachedMap\(\W\)/SetReachedMap\1/g"\ |
|
60 |
-e "s/^DefReachedMap$/SetReachedMap/g"\ |
|
61 |
-e "s/\(\W\)DefProcessedMap\(\W\)/\1SetProcessedMap\2/g"\ |
|
62 |
-e "s/\(\W\)DefProcessedMap$/\1SetProcessedMap/g"\ |
|
63 |
-e "s/^DefProcessedMap\(\W\)/SetProcessedMap\1/g"\ |
|
64 |
-e "s/^DefProcessedMap$/SetProcessedMap/g"\ |
|
65 |
-e "s/\(\W\)DefHeap\(\W\)/\1SetHeap\2/g"\ |
|
66 |
-e "s/\(\W\)DefHeap$/\1SetHeap/g"\ |
|
67 |
-e "s/^DefHeap\(\W\)/SetHeap\1/g"\ |
|
68 |
-e "s/^DefHeap$/SetHeap/g"\ |
|
69 |
-e "s/\(\W\)DefStandardHeap\(\W\)/\1SetStandradHeap\2/g"\ |
|
70 |
-e "s/\(\W\)DefStandardHeap$/\1SetStandradHeap/g"\ |
|
71 |
-e "s/^DefStandardHeap\(\W\)/SetStandradHeap\1/g"\ |
|
72 |
-e "s/^DefStandardHeap$/SetStandradHeap/g"\ |
|
73 |
-e "s/\(\W\)DefOperationTraits\(\W\)/\1SetOperationTraits\2/g"\ |
|
74 |
-e "s/\(\W\)DefOperationTraits$/\1SetOperationTraits/g"\ |
|
75 |
-e "s/^DefOperationTraits\(\W\)/SetOperationTraits\1/g"\ |
|
76 |
-e "s/^DefOperationTraits$/SetOperationTraits/g"\ |
|
77 |
-e "s/\(\W\)DefProcessedMapToBeDefaultMap\(\W\)/\1SetStandardProcessedMap\2/g"\ |
|
78 |
-e "s/\(\W\)DefProcessedMapToBeDefaultMap$/\1SetStandardProcessedMap/g"\ |
|
79 |
-e "s/^DefProcessedMapToBeDefaultMap\(\W\)/SetStandardProcessedMap\1/g"\ |
|
80 |
-e "s/^DefProcessedMapToBeDefaultMap$/SetStandardProcessedMap/g"\ |
|
81 |
-e "s/\(\W\)IntegerMap\(\W\)/\1RangeMap\2/g"\ |
|
82 |
-e "s/\(\W\)IntegerMap$/\1RangeMap/g"\ |
|
83 |
-e "s/^IntegerMap\(\W\)/RangeMap\1/g"\ |
|
84 |
-e "s/^IntegerMap$/RangeMap/g"\ |
|
85 |
-e "s/\(\W\)integerMap\(\W\)/\1rangeMap\2/g"\ |
|
86 |
-e "s/\(\W\)integerMap$/\1rangeMap/g"\ |
|
87 |
-e "s/^integerMap\(\W\)/rangeMap\1/g"\ |
|
88 |
-e "s/^integerMap$/rangeMap/g"\ |
|
89 |
-e "s/\(\W\)copyGraph\(\W\)/\1graphCopy\2/g"\ |
|
90 |
-e "s/\(\W\)copyGraph$/\1graphCopy/g"\ |
|
91 |
-e "s/^copyGraph\(\W\)/graphCopy\1/g"\ |
|
92 |
-e "s/^copyGraph$/graphCopy/g"\ |
|
93 |
-e "s/\(\W\)copyDigraph\(\W\)/\1digraphCopy\2/g"\ |
|
94 |
-e "s/\(\W\)copyDigraph$/\1digraphCopy/g"\ |
|
95 |
-e "s/^copyDigraph\(\W\)/digraphCopy\1/g"\ |
|
96 |
-e "s/^copyDigraph$/digraphCopy/g"\ |
|
97 |
-e "s/\(\W\)\([sS]\)tdMap\(\W\)/\1\2parseMap\3/g"\ |
|
98 |
-e "s/\(\W\)\([sS]\)tdMap$/\1\2parseMap/g"\ |
|
99 |
-e "s/^\([sS]\)tdMap\(\W\)/\1parseMap\2/g"\ |
|
100 |
-e "s/^\([sS]\)tdMap$/\1parseMap/g"\ |
|
101 |
-e "s/\(\W\)\([Ff]\)unctorMap\(\W\)/\1\2unctorToMap\3/g"\ |
|
102 |
-e "s/\(\W\)\([Ff]\)unctorMap$/\1\2unctorToMap/g"\ |
|
103 |
-e "s/^\([Ff]\)unctorMap\(\W\)/\1unctorToMap\2/g"\ |
|
104 |
-e "s/^\([Ff]\)unctorMap$/\1unctorToMap/g"\ |
|
105 |
-e "s/\(\W\)\([Mm]\)apFunctor\(\W\)/\1\2apToFunctor\3/g"\ |
|
106 |
-e "s/\(\W\)\([Mm]\)apFunctor$/\1\2apToFunctor/g"\ |
|
107 |
-e "s/^\([Mm]\)apFunctor\(\W\)/\1apToFunctor\2/g"\ |
|
108 |
-e "s/^\([Mm]\)apFunctor$/\1apToFunctor/g"\ |
|
109 |
-e "s/\(\W\)\([Ff]\)orkWriteMap\(\W\)/\1\2orkMap\3/g"\ |
|
110 |
-e "s/\(\W\)\([Ff]\)orkWriteMap$/\1\2orkMap/g"\ |
|
111 |
-e "s/^\([Ff]\)orkWriteMap\(\W\)/\1orkMap\2/g"\ |
|
112 |
-e "s/^\([Ff]\)orkWriteMap$/\1orkMap/g"\ |
|
113 |
-e "s/\(\W\)StoreBoolMap\(\W\)/\1LoggerBoolMap\2/g"\ |
|
114 |
-e "s/\(\W\)StoreBoolMap$/\1LoggerBoolMap/g"\ |
|
115 |
-e "s/^StoreBoolMap\(\W\)/LoggerBoolMap\1/g"\ |
|
116 |
-e "s/^StoreBoolMap$/LoggerBoolMap/g"\ |
|
117 |
-e "s/\(\W\)storeBoolMap\(\W\)/\1loggerBoolMap\2/g"\ |
|
118 |
-e "s/\(\W\)storeBoolMap$/\1loggerBoolMap/g"\ |
|
119 |
-e "s/^storeBoolMap\(\W\)/loggerBoolMap\1/g"\ |
|
120 |
-e "s/^storeBoolMap$/loggerBoolMap/g"\ |
|
121 |
-e "s/\(\W\)BoundingBox\(\W\)/\1Box\2/g"\ |
|
122 |
-e "s/\(\W\)BoundingBox$/\1Box/g"\ |
|
123 |
-e "s/^BoundingBox\(\W\)/Box\1/g"\ |
|
124 |
-e "s/^BoundingBox$/Box/g"\ |
|
125 |
<$1 > $TMP |
|
126 |
|
|
127 |
mv $TMP $1 |
|
... | ... |
No newline at end of file |
... | ... |
@@ -19,24 +19,24 @@ |
19 | 19 |
lib_LTLIBRARIES = |
20 | 20 |
lemon_HEADERS = |
21 | 21 |
bits_HEADERS = |
22 | 22 |
concept_HEADERS = |
23 | 23 |
noinst_HEADERS = |
24 | 24 |
noinst_PROGRAMS = |
25 | 25 |
bin_PROGRAMS = |
26 | 26 |
check_PROGRAMS = |
27 |
dist_bin_SCRIPTS = |
|
27 | 28 |
TESTS = |
28 | 29 |
XFAIL_TESTS = |
29 | 30 |
|
30 | 31 |
include lemon/Makefile.am |
31 | 32 |
include test/Makefile.am |
32 | 33 |
include doc/Makefile.am |
33 | 34 |
include demo/Makefile.am |
34 |
include benchmark/Makefile.am |
|
35 | 35 |
include tools/Makefile.am |
36 | 36 |
|
37 | 37 |
MRPROPERFILES = \ |
38 | 38 |
aclocal.m4 \ |
39 | 39 |
config.h.in \ |
40 | 40 |
config.h.in~ \ |
41 | 41 |
configure \ |
42 | 42 |
Makefile.in \ |
... | ... |
@@ -32,15 +32,11 @@ |
32 | 32 |
demo/ |
33 | 33 |
|
34 | 34 |
Some example programs to make you easier to get familiar with LEMON. |
35 | 35 |
|
36 | 36 |
test/ |
37 | 37 |
|
38 | 38 |
Contains programs to check the integrity and correctness of LEMON. |
39 | 39 |
|
40 |
benchmark/ |
|
41 |
|
|
42 |
Contains programs for measuring the performance of algorithms. |
|
43 |
|
|
44 | 40 |
tools/ |
45 | 41 |
|
46 | 42 |
Various utilities related to LEMON. |
... | ... |
@@ -76,29 +76,16 @@ |
76 | 76 |
AC_MSG_CHECKING([whether to build the additional tools]) |
77 | 77 |
if test x"$enable_tools" != x"no"; then |
78 | 78 |
AC_MSG_RESULT([yes]) |
79 | 79 |
else |
80 | 80 |
AC_MSG_RESULT([no]) |
81 | 81 |
fi |
82 | 82 |
AM_CONDITIONAL([WANT_TOOLS], [test x"$enable_tools" != x"no"]) |
83 | 83 |
|
84 |
dnl Disable/enable building the benchmarks. |
|
85 |
AC_ARG_ENABLE([benchmark], |
|
86 |
AS_HELP_STRING([--enable-benchmark], [build the benchmarks]) |
|
87 |
AS_HELP_STRING([--disable-benchmark], [do not build the benchmarks @<:@default@:>@]), |
|
88 |
[], [enable_benchmark=no]) |
|
89 |
AC_MSG_CHECKING([whether to build the benchmarks]) |
|
90 |
if test x"$enable_benchmark" != x"no"; then |
|
91 |
AC_MSG_RESULT([yes]) |
|
92 |
else |
|
93 |
AC_MSG_RESULT([no]) |
|
94 |
fi |
|
95 |
AM_CONDITIONAL([WANT_BENCHMARK], [test x"$enable_benchmark" != x"no"]) |
|
96 |
|
|
97 | 84 |
dnl Checks for header files. |
98 | 85 |
AC_CHECK_HEADERS(limits.h sys/time.h sys/times.h unistd.h) |
99 | 86 |
|
100 | 87 |
dnl Checks for typedefs, structures, and compiler characteristics. |
101 | 88 |
AC_C_CONST |
102 | 89 |
AC_C_INLINE |
103 | 90 |
AC_TYPE_SIZE_T |
104 | 91 |
AC_HEADER_TIME |
... | ... |
@@ -127,17 +114,16 @@ |
127 | 114 |
echo |
128 | 115 |
echo C++ compiler.................. : $CXX |
129 | 116 |
echo C++ compiles flags............ : $CXXFLAGS |
130 | 117 |
echo |
131 | 118 |
#echo GLPK support.................. : $lx_glpk_found |
132 | 119 |
#echo CPLEX support................. : $lx_cplex_found |
133 | 120 |
#echo SOPLEX support................ : $lx_soplex_found |
134 | 121 |
#echo |
135 |
echo Build benchmarks.............. : $enable_benchmark |
|
136 | 122 |
echo Build demo programs........... : $enable_demo |
137 | 123 |
echo Build additional tools........ : $enable_tools |
138 | 124 |
echo |
139 | 125 |
echo The packace will be installed in |
140 | 126 |
echo -n ' ' |
141 | 127 |
echo $prefix. |
142 | 128 |
echo |
143 | 129 |
echo '*********************************************************************' |
... | ... |
@@ -22,17 +22,17 @@ |
22 | 22 |
/// |
23 | 23 |
/// This example shows how the argument parser can be used. |
24 | 24 |
/// |
25 | 25 |
/// \include arg_parser_demo.cc |
26 | 26 |
|
27 | 27 |
#include <lemon/arg_parser.h> |
28 | 28 |
|
29 | 29 |
using namespace lemon; |
30 |
int main(int argc, |
|
30 |
int main(int argc, char **argv) |
|
31 | 31 |
{ |
32 | 32 |
// Initialize the argument parser |
33 | 33 |
ArgParser ap(argc, argv); |
34 | 34 |
int i; |
35 | 35 |
std::string s; |
36 | 36 |
double d = 1.0; |
37 | 37 |
bool b, nh; |
38 | 38 |
bool g1, g2, g3; |
... | ... |
@@ -21,17 +21,17 @@ |
21 | 21 |
/// \brief Demo of the graph drawing function \ref graphToEps() |
22 | 22 |
/// |
23 | 23 |
/// This demo program shows examples how to use the function \ref |
24 | 24 |
/// graphToEps(). It takes no input but simply creates seven |
25 | 25 |
/// <tt>.eps</tt> files demonstrating the capability of \ref |
26 | 26 |
/// graphToEps(), and showing how to draw directed graphs, |
27 | 27 |
/// how to handle parallel egdes, how to change the properties (like |
28 | 28 |
/// color, shape, size, title etc.) of nodes and arcs individually |
29 |
/// using appropriate |
|
29 |
/// using appropriate graph maps. |
|
30 | 30 |
/// |
31 | 31 |
/// \include graph_to_eps_demo.cc |
32 | 32 |
|
33 | 33 |
#include<lemon/list_graph.h> |
34 | 34 |
#include<lemon/graph_to_eps.h> |
35 | 35 |
#include<lemon/math.h> |
36 | 36 |
|
37 | 37 |
using namespace std; |
1 | 1 |
EXTRA_DIST += \ |
2 | 2 |
doc/Doxyfile.in \ |
3 | 3 |
doc/coding_style.dox \ |
4 | 4 |
doc/dirs.dox \ |
5 | 5 |
doc/groups.dox \ |
6 | 6 |
doc/lgf.dox \ |
7 | 7 |
doc/license.dox \ |
8 | 8 |
doc/mainpage.dox \ |
9 |
doc/migration.dox \ |
|
9 | 10 |
doc/named-param.dox \ |
10 | 11 |
doc/namespaces.dox \ |
11 | 12 |
doc/html \ |
12 | 13 |
doc/CMakeLists.txt |
13 | 14 |
|
14 | 15 |
DOC_EPS_IMAGES18 = \ |
15 | 16 |
nodeshape_0.eps \ |
16 | 17 |
nodeshape_1.eps \ |
... | ... |
@@ -37,77 +37,80 @@ |
37 | 37 |
limitations or in the set of operations through which the graph can be |
38 | 38 |
accessed. LEMON provides several physical graph structures to meet |
39 | 39 |
the diverging requirements of the possible users. In order to save on |
40 | 40 |
running time or on memory usage, some structures may fail to provide |
41 | 41 |
some graph features like arc/edge or node deletion. |
42 | 42 |
|
43 | 43 |
You are free to use the graph structure that fit your requirements |
44 | 44 |
the best, most graph algorithms and auxiliary data structures can be used |
45 |
with any graph |
|
45 |
with any graph structure. |
|
46 |
|
|
47 |
<b>See also:</b> \ref graph_concepts "Graph Structure Concepts". |
|
46 | 48 |
*/ |
47 | 49 |
|
48 | 50 |
/** |
49 | 51 |
@defgroup maps Maps |
50 | 52 |
@ingroup datas |
51 | 53 |
\brief Map structures implemented in LEMON. |
52 | 54 |
|
53 | 55 |
This group describes the map structures implemented in LEMON. |
54 | 56 |
|
55 |
LEMON provides several special purpose maps that e.g. combine |
|
57 |
LEMON provides several special purpose maps and map adaptors that e.g. combine |
|
56 | 58 |
new maps from existing ones. |
59 |
|
|
60 |
<b>See also:</b> \ref map_concepts "Map Concepts". |
|
57 | 61 |
*/ |
58 | 62 |
|
59 | 63 |
/** |
60 | 64 |
@defgroup graph_maps Graph Maps |
61 | 65 |
@ingroup maps |
62 | 66 |
\brief Special graph-related maps. |
63 | 67 |
|
64 | 68 |
This group describes maps that are specifically designed to assign |
65 | 69 |
values to the nodes and arcs of graphs. |
66 | 70 |
*/ |
67 | 71 |
|
68 |
|
|
69 | 72 |
/** |
70 | 73 |
\defgroup map_adaptors Map Adaptors |
71 | 74 |
\ingroup maps |
72 | 75 |
\brief Tools to create new maps from existing ones |
73 | 76 |
|
74 | 77 |
This group describes map adaptors that are used to create "implicit" |
75 | 78 |
maps from other maps. |
76 | 79 |
|
77 | 80 |
Most of them are \ref lemon::concepts::ReadMap "read-only maps". |
78 | 81 |
They can make arithmetic and logical operations between one or two maps |
79 | 82 |
(negation, shifting, addition, multiplication, logical 'and', 'or', |
80 | 83 |
'not' etc.) or e.g. convert a map to another one of different Value type. |
81 | 84 |
|
82 | 85 |
The typical usage of this classes is passing implicit maps to |
83 | 86 |
algorithms. If a function type algorithm is called then the function |
84 | 87 |
type map adaptors can be used comfortable. For example let's see the |
85 |
usage of map adaptors with the \c |
|
88 |
usage of map adaptors with the \c graphToEps() function. |
|
86 | 89 |
\code |
87 | 90 |
Color nodeColor(int deg) { |
88 | 91 |
if (deg >= 2) { |
89 | 92 |
return Color(0.5, 0.0, 0.5); |
90 | 93 |
} else if (deg == 1) { |
91 | 94 |
return Color(1.0, 0.5, 1.0); |
92 | 95 |
} else { |
93 | 96 |
return Color(0.0, 0.0, 0.0); |
94 | 97 |
} |
95 | 98 |
} |
96 | 99 |
|
97 | 100 |
Digraph::NodeMap<int> degree_map(graph); |
98 | 101 |
|
99 |
|
|
102 |
graphToEps(graph, "graph.eps") |
|
100 | 103 |
.coords(coords).scaleToA4().undirected() |
101 | 104 |
.nodeColors(composeMap(functorToMap(nodeColor), degree_map)) |
102 | 105 |
.run(); |
103 | 106 |
\endcode |
104 | 107 |
The \c functorToMap() function makes an \c int to \c Color map from the |
105 |
\ |
|
108 |
\c nodeColor() function. The \c composeMap() compose the \c degree_map |
|
106 | 109 |
and the previously created map. The composed map is a proper function to |
107 | 110 |
get the color of each node. |
108 | 111 |
|
109 | 112 |
The usage with class type algorithms is little bit harder. In this |
110 | 113 |
case the function type map adaptors can not be used, because the |
111 | 114 |
function map adaptors give back temporary objects. |
112 | 115 |
\code |
113 | 116 |
Digraph graph; |
... | ... |
@@ -138,64 +141,63 @@ |
138 | 141 |
|
139 | 142 |
LEMON provides flexible data structures to work with paths. |
140 | 143 |
All of them have similar interfaces and they can be copied easily with |
141 | 144 |
assignment operators and copy constructors. This makes it easy and |
142 | 145 |
efficient to have e.g. the Dijkstra algorithm to store its result in |
143 | 146 |
any kind of path structure. |
144 | 147 |
|
145 | 148 |
\sa lemon::concepts::Path |
146 |
|
|
147 | 149 |
*/ |
148 | 150 |
|
149 | 151 |
/** |
150 | 152 |
@defgroup auxdat Auxiliary Data Structures |
151 | 153 |
@ingroup datas |
152 | 154 |
\brief Auxiliary data structures implemented in LEMON. |
153 | 155 |
|
154 | 156 |
This group describes some data structures implemented in LEMON in |
155 | 157 |
order to make it easier to implement combinatorial algorithms. |
156 | 158 |
*/ |
157 | 159 |
|
158 |
|
|
159 | 160 |
/** |
160 | 161 |
@defgroup algs Algorithms |
161 | 162 |
\brief This group describes the several algorithms |
162 | 163 |
implemented in LEMON. |
163 | 164 |
|
164 | 165 |
This group describes the several algorithms |
165 | 166 |
implemented in LEMON. |
166 | 167 |
*/ |
167 | 168 |
|
168 | 169 |
/** |
169 | 170 |
@defgroup search Graph Search |
170 | 171 |
@ingroup algs |
171 | 172 |
\brief Common graph search algorithms. |
172 | 173 |
|
173 | 174 |
This group describes the common graph search algorithms like |
174 |
Breadth- |
|
175 |
Breadth-First Search (BFS) and Depth-First Search (DFS). |
|
175 | 176 |
*/ |
176 | 177 |
|
177 | 178 |
/** |
178 |
@defgroup shortest_path Shortest Path |
|
179 |
@defgroup shortest_path Shortest Path Algorithms |
|
179 | 180 |
@ingroup algs |
180 | 181 |
\brief Algorithms for finding shortest paths. |
181 | 182 |
|
182 | 183 |
This group describes the algorithms for finding shortest paths in graphs. |
183 | 184 |
*/ |
184 | 185 |
|
185 | 186 |
/** |
186 |
@defgroup spantree Minimum Spanning Tree |
|
187 |
@defgroup spantree Minimum Spanning Tree Algorithms |
|
187 | 188 |
@ingroup algs |
188 | 189 |
\brief Algorithms for finding a minimum cost spanning tree in a graph. |
189 | 190 |
|
190 | 191 |
This group describes the algorithms for finding a minimum cost spanning |
191 | 192 |
tree in a graph |
192 | 193 |
*/ |
193 | 194 |
|
195 |
@ingroup algs |
|
194 | 196 |
/** |
195 | 197 |
@defgroup utils Tools and Utilities |
196 | 198 |
\brief Tools and utilities for programming in LEMON |
197 | 199 |
|
198 | 200 |
Tools and utilities for programming in LEMON. |
199 | 201 |
*/ |
200 | 202 |
|
201 | 203 |
/** |
... | ... |
@@ -211,17 +213,17 @@ |
211 | 213 |
@ingroup utils |
212 | 214 |
\brief Tools for development, debugging and testing. |
213 | 215 |
|
214 | 216 |
This group describes several useful tools for development, |
215 | 217 |
debugging and testing. |
216 | 218 |
*/ |
217 | 219 |
|
218 | 220 |
/** |
219 |
@defgroup timecount Time |
|
221 |
@defgroup timecount Time Measuring and Counting |
|
220 | 222 |
@ingroup misc |
221 | 223 |
\brief Simple tools for measuring the performance of algorithms. |
222 | 224 |
|
223 | 225 |
This group describes simple tools for measuring the performance |
224 | 226 |
of algorithms. |
225 | 227 |
*/ |
226 | 228 |
|
227 | 229 |
/** |
... | ... |
@@ -234,37 +236,37 @@ |
234 | 236 |
|
235 | 237 |
/** |
236 | 238 |
@defgroup io_group Input-Output |
237 | 239 |
\brief Graph Input-Output methods |
238 | 240 |
|
239 | 241 |
This group describes the tools for importing and exporting graphs |
240 | 242 |
and graph related data. Now it supports the LEMON format |
241 | 243 |
and the encapsulated postscript (EPS) format. |
244 |
postscript (EPS) format. |
|
242 | 245 |
*/ |
243 | 246 |
|
244 | 247 |
/** |
245 | 248 |
@defgroup lemon_io LEMON Input-Output |
246 | 249 |
@ingroup io_group |
247 |
\brief Reading and writing |
|
250 |
\brief Reading and writing LEMON Graph Format. |
|
248 | 251 |
|
249 | 252 |
This group describes methods for reading and writing |
250 | 253 |
\ref lgf-format "LEMON Graph Format". |
251 | 254 |
*/ |
252 | 255 |
|
253 | 256 |
/** |
254 |
@defgroup eps_io Postscript |
|
257 |
@defgroup eps_io Postscript Exporting |
|
255 | 258 |
@ingroup io_group |
256 | 259 |
\brief General \c EPS drawer and graph exporter |
257 | 260 |
|
258 | 261 |
This group describes general \c EPS drawing methods and special |
259 | 262 |
graph exporting tools. |
260 | 263 |
*/ |
261 | 264 |
|
262 |
|
|
263 | 265 |
/** |
264 | 266 |
@defgroup concept Concepts |
265 | 267 |
\brief Skeleton classes and concept checking classes |
266 | 268 |
|
267 | 269 |
This group describes the data/algorithm skeletons and concept checking |
268 | 270 |
classes implemented in LEMON. |
269 | 271 |
|
270 | 272 |
The purpose of the classes in this group is fourfold. |
... | ... |
@@ -282,29 +284,29 @@ |
282 | 284 |
of course.) In this way it is easily to check if an algorithm |
283 | 285 |
doesn't use any extra feature of a certain implementation. |
284 | 286 |
|
285 | 287 |
- The concept descriptor classes also provide a <em>checker class</em> |
286 | 288 |
that makes it possible to check whether a certain implementation of a |
287 | 289 |
concept indeed provides all the required features. |
288 | 290 |
|
289 | 291 |
- Finally, They can serve as a skeleton of a new implementation of a concept. |
290 |
|
|
291 | 292 |
*/ |
292 | 293 |
|
293 |
|
|
294 | 294 |
/** |
295 | 295 |
@defgroup graph_concepts Graph Structure Concepts |
296 | 296 |
@ingroup concept |
297 | 297 |
\brief Skeleton and concept checking classes for graph structures |
298 | 298 |
|
299 | 299 |
This group describes the skeletons and concept checking classes of LEMON's |
300 | 300 |
graph structures and helper classes used to implement these. |
301 | 301 |
*/ |
302 | 302 |
|
303 |
|
|
304 |
This group describes the skeletons and concept checking classes of maps. |
|
303 | 305 |
/** |
304 | 306 |
\anchor demoprograms |
305 | 307 |
|
306 | 308 |
@defgroup demos Demo programs |
307 | 309 |
|
308 | 310 |
Some demo programs are listed here. Their full source codes can be found in |
309 | 311 |
the \c demo subdirectory of the source tree. |
310 | 312 |
... | ... |
@@ -73,17 +73,17 @@ |
73 | 73 |
\code |
74 | 74 |
@arcs |
75 | 75 |
capacity |
76 | 76 |
1 2 16 |
77 | 77 |
1 3 12 |
78 | 78 |
2 3 18 |
79 | 79 |
\endcode |
80 | 80 |
|
81 |
The \c \@edges is just a synonym of \c \@arcs. The @arcs section can |
|
81 |
The \c \@edges is just a synonym of \c \@arcs. The \@arcs section can |
|
82 | 82 |
also store the edge set of an undirected graph. In such case there is |
83 | 83 |
a conventional method for store arc maps in the file, if two columns |
84 | 84 |
has the same caption with \c '+' and \c '-' prefix, then these columns |
85 | 85 |
can be regarded as the values of an arc map. |
86 | 86 |
|
87 | 87 |
The \c \@attributes section contains key-value pairs, each line |
88 | 88 |
consists of two tokens, an attribute name, and then an attribute |
89 | 89 |
value. The value of the attribute could be also a label value of a |
... | ... |
@@ -38,16 +38,17 @@ |
38 | 38 |
non-commercial applications under very permissive |
39 | 39 |
\ref license "license terms". |
40 | 40 |
</b> |
41 | 41 |
|
42 | 42 |
\subsection howtoread How to read the documentation |
43 | 43 |
|
44 | 44 |
If you |
45 | 45 |
want to see how LEMON works, see |
46 |
some \ref demoprograms "demo programs" |
|
46 |
some \ref demoprograms "demo programs". |
|
47 | 47 |
|
48 | 48 |
If you know what you are looking for then try to find it under the |
49 | 49 |
<a class="el" href="modules.html">Modules</a> |
50 | 50 |
section. |
51 | 51 |
|
52 |
|
|
52 |
If you are a user of the old (0.x) series of LEMON, please check out the |
|
53 |
\ref migration "Migration Guide" for the backward incompatibilities. |
|
53 | 54 |
*/ |
... | ... |
@@ -21,22 +21,21 @@ |
21 | 21 |
namespace lemon { |
22 | 22 |
|
23 | 23 |
void ArgParser::_showHelp(void *p) |
24 | 24 |
{ |
25 | 25 |
(static_cast<ArgParser*>(p))->showHelp(); |
26 | 26 |
exit(1); |
27 | 27 |
} |
28 | 28 |
|
29 |
ArgParser::ArgParser(int argc, const char **argv) :_argc(argc), _argv(argv), |
|
30 |
_command_name(argv[0]) { |
|
29 |
ArgParser::ArgParser(int argc, const char * const *argv) |
|
30 |
:_argc(argc), _argv(argv), _command_name(argv[0]) { |
|
31 | 31 |
funcOption("-help","Print a short help message",_showHelp,this); |
32 | 32 |
synonym("help","-help"); |
33 | 33 |
synonym("h","-help"); |
34 |
|
|
35 | 34 |
} |
36 | 35 |
|
37 | 36 |
ArgParser::~ArgParser() |
38 | 37 |
{ |
39 | 38 |
for(Opts::iterator i=_opts.begin();i!=_opts.end();++i) |
40 | 39 |
if(i->second.self_delete) |
41 | 40 |
switch(i->second.type) { |
42 | 41 |
case BOOL: |
... | ... |
@@ -41,17 +41,17 @@ |
41 | 41 |
/// |
42 | 42 |
///For a complete example see the \ref arg_parser_demo.cc demo file. |
43 | 43 |
class ArgParser { |
44 | 44 |
|
45 | 45 |
static void _showHelp(void *p); |
46 | 46 |
protected: |
47 | 47 |
|
48 | 48 |
int _argc; |
49 |
const char **_argv; |
|
49 |
const char * const *_argv; |
|
50 | 50 |
|
51 | 51 |
enum OptType { UNKNOWN=0, BOOL=1, STRING=2, DOUBLE=3, INTEGER=4, FUNC=5 }; |
52 | 52 |
|
53 | 53 |
class ParData { |
54 | 54 |
public: |
55 | 55 |
union { |
56 | 56 |
bool *bool_p; |
57 | 57 |
int *int_p; |
... | ... |
@@ -114,17 +114,17 @@ |
114 | 114 |
//\param data Data to be passed to \c func |
115 | 115 |
ArgParser &funcOption(const std::string &name, |
116 | 116 |
const std::string &help, |
117 | 117 |
void (*func)(void *),void *data); |
118 | 118 |
|
119 | 119 |
public: |
120 | 120 |
|
121 | 121 |
///Constructor |
122 |
ArgParser(int argc, const char **argv); |
|
122 |
ArgParser(int argc, const char * const *argv); |
|
123 | 123 |
|
124 | 124 |
~ArgParser(); |
125 | 125 |
|
126 | 126 |
///\name Options |
127 | 127 |
/// |
128 | 128 |
|
129 | 129 |
///@{ |
130 | 130 |
... | ... |
@@ -44,70 +44,70 @@ |
44 | 44 |
|
45 | 45 |
///\brief The type of the map that stores the predecessor |
46 | 46 |
///arcs of the shortest paths. |
47 | 47 |
/// |
48 | 48 |
///The type of the map that stores the predecessor |
49 | 49 |
///arcs of the shortest paths. |
50 | 50 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
51 | 51 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
52 |
///Instantiates a |
|
52 |
///Instantiates a PredMap. |
|
53 | 53 |
|
54 |
///This function instantiates a |
|
54 |
///This function instantiates a PredMap. |
|
55 | 55 |
///\param g is the digraph, to which we would like to define the |
56 |
/// |
|
56 |
///PredMap. |
|
57 | 57 |
static PredMap *createPredMap(const Digraph &g) |
58 | 58 |
{ |
59 | 59 |
return new PredMap(g); |
60 | 60 |
} |
61 | 61 |
|
62 | 62 |
///The type of the map that indicates which nodes are processed. |
63 | 63 |
|
64 | 64 |
///The type of the map that indicates which nodes are processed. |
65 | 65 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
66 | 66 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
67 |
///Instantiates a |
|
67 |
///Instantiates a ProcessedMap. |
|
68 | 68 |
|
69 |
///This function instantiates a |
|
69 |
///This function instantiates a ProcessedMap. |
|
70 | 70 |
///\param g is the digraph, to which |
71 |
///we would like to define the |
|
71 |
///we would like to define the ProcessedMap |
|
72 | 72 |
#ifdef DOXYGEN |
73 | 73 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
74 | 74 |
#else |
75 | 75 |
static ProcessedMap *createProcessedMap(const Digraph &) |
76 | 76 |
#endif |
77 | 77 |
{ |
78 | 78 |
return new ProcessedMap(); |
79 | 79 |
} |
80 | 80 |
|
81 | 81 |
///The type of the map that indicates which nodes are reached. |
82 | 82 |
|
83 | 83 |
///The type of the map that indicates which nodes are reached. |
84 | 84 |
///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
85 | 85 |
typedef typename Digraph::template NodeMap<bool> ReachedMap; |
86 |
///Instantiates a |
|
86 |
///Instantiates a ReachedMap. |
|
87 | 87 |
|
88 |
///This function instantiates a |
|
88 |
///This function instantiates a ReachedMap. |
|
89 | 89 |
///\param g is the digraph, to which |
90 |
///we would like to define the |
|
90 |
///we would like to define the ReachedMap. |
|
91 | 91 |
static ReachedMap *createReachedMap(const Digraph &g) |
92 | 92 |
{ |
93 | 93 |
return new ReachedMap(g); |
94 | 94 |
} |
95 | 95 |
|
96 | 96 |
///The type of the map that stores the distances of the nodes. |
97 | 97 |
|
98 | 98 |
///The type of the map that stores the distances of the nodes. |
99 | 99 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
100 | 100 |
typedef typename Digraph::template NodeMap<int> DistMap; |
101 |
///Instantiates a |
|
101 |
///Instantiates a DistMap. |
|
102 | 102 |
|
103 |
///This function instantiates a |
|
103 |
///This function instantiates a DistMap. |
|
104 | 104 |
///\param g is the digraph, to which we would like to define the |
105 |
/// |
|
105 |
///DistMap. |
|
106 | 106 |
static DistMap *createDistMap(const Digraph &g) |
107 | 107 |
{ |
108 | 108 |
return new DistMap(g); |
109 | 109 |
} |
110 | 110 |
}; |
111 | 111 |
|
112 | 112 |
///%BFS algorithm class. |
113 | 113 |
|
... | ... |
@@ -222,95 +222,95 @@ |
222 | 222 |
typedef T PredMap; |
223 | 223 |
static PredMap *createPredMap(const Digraph &) |
224 | 224 |
{ |
225 | 225 |
LEMON_ASSERT(false, "PredMap is not initialized"); |
226 | 226 |
return 0; // ignore warnings |
227 | 227 |
} |
228 | 228 |
}; |
229 | 229 |
///\brief \ref named-templ-param "Named parameter" for setting |
230 |
/// |
|
230 |
///PredMap type. |
|
231 | 231 |
/// |
232 | 232 |
///\ref named-templ-param "Named parameter" for setting |
233 |
/// |
|
233 |
///PredMap type. |
|
234 | 234 |
template <class T> |
235 | 235 |
struct SetPredMap : public Bfs< Digraph, SetPredMapTraits<T> > { |
236 | 236 |
typedef Bfs< Digraph, SetPredMapTraits<T> > Create; |
237 | 237 |
}; |
238 | 238 |
|
239 | 239 |
template <class T> |
240 | 240 |
struct SetDistMapTraits : public Traits { |
241 | 241 |
typedef T DistMap; |
242 | 242 |
static DistMap *createDistMap(const Digraph &) |
243 | 243 |
{ |
244 | 244 |
LEMON_ASSERT(false, "DistMap is not initialized"); |
245 | 245 |
return 0; // ignore warnings |
246 | 246 |
} |
247 | 247 |
}; |
248 | 248 |
///\brief \ref named-templ-param "Named parameter" for setting |
249 |
/// |
|
249 |
///DistMap type. |
|
250 | 250 |
/// |
251 | 251 |
///\ref named-templ-param "Named parameter" for setting |
252 |
/// |
|
252 |
///DistMap type. |
|
253 | 253 |
template <class T> |
254 | 254 |
struct SetDistMap : public Bfs< Digraph, SetDistMapTraits<T> > { |
255 | 255 |
typedef Bfs< Digraph, SetDistMapTraits<T> > Create; |
256 | 256 |
}; |
257 | 257 |
|
258 | 258 |
template <class T> |
259 | 259 |
struct SetReachedMapTraits : public Traits { |
260 | 260 |
typedef T ReachedMap; |
261 | 261 |
static ReachedMap *createReachedMap(const Digraph &) |
262 | 262 |
{ |
263 | 263 |
LEMON_ASSERT(false, "ReachedMap is not initialized"); |
264 | 264 |
return 0; // ignore warnings |
265 | 265 |
} |
266 | 266 |
}; |
267 | 267 |
///\brief \ref named-templ-param "Named parameter" for setting |
268 |
/// |
|
268 |
///ReachedMap type. |
|
269 | 269 |
/// |
270 | 270 |
///\ref named-templ-param "Named parameter" for setting |
271 |
/// |
|
271 |
///ReachedMap type. |
|
272 | 272 |
template <class T> |
273 | 273 |
struct SetReachedMap : public Bfs< Digraph, SetReachedMapTraits<T> > { |
274 | 274 |
typedef Bfs< Digraph, SetReachedMapTraits<T> > Create; |
275 | 275 |
}; |
276 | 276 |
|
277 | 277 |
template <class T> |
278 | 278 |
struct SetProcessedMapTraits : public Traits { |
279 | 279 |
typedef T ProcessedMap; |
280 | 280 |
static ProcessedMap *createProcessedMap(const Digraph &) |
281 | 281 |
{ |
282 | 282 |
LEMON_ASSERT(false, "ProcessedMap is not initialized"); |
283 | 283 |
return 0; // ignore warnings |
284 | 284 |
} |
285 | 285 |
}; |
286 | 286 |
///\brief \ref named-templ-param "Named parameter" for setting |
287 |
/// |
|
287 |
///ProcessedMap type. |
|
288 | 288 |
/// |
289 | 289 |
///\ref named-templ-param "Named parameter" for setting |
290 |
/// |
|
290 |
///ProcessedMap type. |
|
291 | 291 |
template <class T> |
292 | 292 |
struct SetProcessedMap : public Bfs< Digraph, SetProcessedMapTraits<T> > { |
293 | 293 |
typedef Bfs< Digraph, SetProcessedMapTraits<T> > Create; |
294 | 294 |
}; |
295 | 295 |
|
296 | 296 |
struct SetStandardProcessedMapTraits : public Traits { |
297 | 297 |
typedef typename Digraph::template NodeMap<bool> ProcessedMap; |
298 | 298 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
299 | 299 |
{ |
300 | 300 |
return new ProcessedMap(g); |
301 | 301 |
return 0; // ignore warnings |
302 | 302 |
} |
303 | 303 |
}; |
304 | 304 |
///\brief \ref named-templ-param "Named parameter" for setting |
305 |
/// |
|
305 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
306 | 306 |
/// |
307 | 307 |
///\ref named-templ-param "Named parameter" for setting |
308 |
/// |
|
308 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
309 | 309 |
///If you don't set it explicitly, it will be automatically allocated. |
310 | 310 |
struct SetStandardProcessedMap : |
311 | 311 |
public Bfs< Digraph, SetStandardProcessedMapTraits > { |
312 | 312 |
typedef Bfs< Digraph, SetStandardProcessedMapTraits > Create; |
313 | 313 |
}; |
314 | 314 |
|
315 | 315 |
///@} |
316 | 316 |
|
... | ... |
@@ -830,84 +830,84 @@ |
830 | 830 |
|
831 | 831 |
///\brief The type of the map that stores the predecessor |
832 | 832 |
///arcs of the shortest paths. |
833 | 833 |
/// |
834 | 834 |
///The type of the map that stores the predecessor |
835 | 835 |
///arcs of the shortest paths. |
836 | 836 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
837 | 837 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
838 |
///Instantiates a |
|
838 |
///Instantiates a PredMap. |
|
839 | 839 |
|
840 |
///This function instantiates a |
|
840 |
///This function instantiates a PredMap. |
|
841 | 841 |
///\param g is the digraph, to which we would like to define the |
842 |
/// |
|
842 |
///PredMap. |
|
843 | 843 |
static PredMap *createPredMap(const Digraph &g) |
844 | 844 |
{ |
845 | 845 |
return new PredMap(g); |
846 | 846 |
} |
847 | 847 |
|
848 | 848 |
///The type of the map that indicates which nodes are processed. |
849 | 849 |
|
850 | 850 |
///The type of the map that indicates which nodes are processed. |
851 | 851 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
852 | 852 |
///By default it is a NullMap. |
853 | 853 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
854 |
///Instantiates a |
|
854 |
///Instantiates a ProcessedMap. |
|
855 | 855 |
|
856 |
///This function instantiates a |
|
856 |
///This function instantiates a ProcessedMap. |
|
857 | 857 |
///\param g is the digraph, to which |
858 |
///we would like to define the |
|
858 |
///we would like to define the ProcessedMap. |
|
859 | 859 |
#ifdef DOXYGEN |
860 | 860 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
861 | 861 |
#else |
862 | 862 |
static ProcessedMap *createProcessedMap(const Digraph &) |
863 | 863 |
#endif |
864 | 864 |
{ |
865 | 865 |
return new ProcessedMap(); |
866 | 866 |
} |
867 | 867 |
|
868 | 868 |
///The type of the map that indicates which nodes are reached. |
869 | 869 |
|
870 | 870 |
///The type of the map that indicates which nodes are reached. |
871 | 871 |
///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
872 | 872 |
typedef typename Digraph::template NodeMap<bool> ReachedMap; |
873 |
///Instantiates a |
|
873 |
///Instantiates a ReachedMap. |
|
874 | 874 |
|
875 |
///This function instantiates a |
|
875 |
///This function instantiates a ReachedMap. |
|
876 | 876 |
///\param g is the digraph, to which |
877 |
///we would like to define the |
|
877 |
///we would like to define the ReachedMap. |
|
878 | 878 |
static ReachedMap *createReachedMap(const Digraph &g) |
879 | 879 |
{ |
880 | 880 |
return new ReachedMap(g); |
881 | 881 |
} |
882 | 882 |
|
883 | 883 |
///The type of the map that stores the distances of the nodes. |
884 | 884 |
|
885 | 885 |
///The type of the map that stores the distances of the nodes. |
886 | 886 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
887 | 887 |
typedef typename Digraph::template NodeMap<int> DistMap; |
888 |
///Instantiates a |
|
888 |
///Instantiates a DistMap. |
|
889 | 889 |
|
890 |
///This function instantiates a |
|
890 |
///This function instantiates a DistMap. |
|
891 | 891 |
///\param g is the digraph, to which we would like to define |
892 |
///the |
|
892 |
///the DistMap |
|
893 | 893 |
static DistMap *createDistMap(const Digraph &g) |
894 | 894 |
{ |
895 | 895 |
return new DistMap(g); |
896 | 896 |
} |
897 | 897 |
|
898 | 898 |
///The type of the shortest paths. |
899 | 899 |
|
900 | 900 |
///The type of the shortest paths. |
901 | 901 |
///It must meet the \ref concepts::Path "Path" concept. |
902 | 902 |
typedef lemon::Path<Digraph> Path; |
903 | 903 |
}; |
904 | 904 |
|
905 |
/// Default traits class used by |
|
905 |
/// Default traits class used by BfsWizard |
|
906 | 906 |
|
907 | 907 |
/// To make it easier to use Bfs algorithm |
908 | 908 |
/// we have created a wizard class. |
909 | 909 |
/// This \ref BfsWizard class needs default traits, |
910 | 910 |
/// as well as the \ref Bfs class. |
911 | 911 |
/// The \ref BfsWizardBase is a class to be the default traits of the |
912 | 912 |
/// \ref BfsWizard class. |
913 | 913 |
template<class GR> |
... | ... |
@@ -1063,74 +1063,74 @@ |
1063 | 1063 |
|
1064 | 1064 |
template<class T> |
1065 | 1065 |
struct SetPredMapBase : public Base { |
1066 | 1066 |
typedef T PredMap; |
1067 | 1067 |
static PredMap *createPredMap(const Digraph &) { return 0; }; |
1068 | 1068 |
SetPredMapBase(const TR &b) : TR(b) {} |
1069 | 1069 |
}; |
1070 | 1070 |
///\brief \ref named-func-param "Named parameter" |
1071 |
///for setting |
|
1071 |
///for setting PredMap object. |
|
1072 | 1072 |
/// |
1073 | 1073 |
///\ref named-func-param "Named parameter" |
1074 |
///for setting |
|
1074 |
///for setting PredMap object. |
|
1075 | 1075 |
template<class T> |
1076 | 1076 |
BfsWizard<SetPredMapBase<T> > predMap(const T &t) |
1077 | 1077 |
{ |
1078 | 1078 |
Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); |
1079 | 1079 |
return BfsWizard<SetPredMapBase<T> >(*this); |
1080 | 1080 |
} |
1081 | 1081 |
|
1082 | 1082 |
template<class T> |
1083 | 1083 |
struct SetReachedMapBase : public Base { |
1084 | 1084 |
typedef T ReachedMap; |
1085 | 1085 |
static ReachedMap *createReachedMap(const Digraph &) { return 0; }; |
1086 | 1086 |
SetReachedMapBase(const TR &b) : TR(b) {} |
1087 | 1087 |
}; |
1088 | 1088 |
///\brief \ref named-func-param "Named parameter" |
1089 |
///for setting |
|
1089 |
///for setting ReachedMap object. |
|
1090 | 1090 |
/// |
1091 | 1091 |
/// \ref named-func-param "Named parameter" |
1092 |
///for setting |
|
1092 |
///for setting ReachedMap object. |
|
1093 | 1093 |
template<class T> |
1094 | 1094 |
BfsWizard<SetReachedMapBase<T> > reachedMap(const T &t) |
1095 | 1095 |
{ |
1096 | 1096 |
Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t)); |
1097 | 1097 |
return BfsWizard<SetReachedMapBase<T> >(*this); |
1098 | 1098 |
} |
1099 | 1099 |
|
1100 | 1100 |
template<class T> |
1101 | 1101 |
struct SetDistMapBase : public Base { |
1102 | 1102 |
typedef T DistMap; |
1103 | 1103 |
static DistMap *createDistMap(const Digraph &) { return 0; }; |
1104 | 1104 |
SetDistMapBase(const TR &b) : TR(b) {} |
1105 | 1105 |
}; |
1106 | 1106 |
///\brief \ref named-func-param "Named parameter" |
1107 |
///for setting |
|
1107 |
///for setting DistMap object. |
|
1108 | 1108 |
/// |
1109 | 1109 |
/// \ref named-func-param "Named parameter" |
1110 |
///for setting |
|
1110 |
///for setting DistMap object. |
|
1111 | 1111 |
template<class T> |
1112 | 1112 |
BfsWizard<SetDistMapBase<T> > distMap(const T &t) |
1113 | 1113 |
{ |
1114 | 1114 |
Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t)); |
1115 | 1115 |
return BfsWizard<SetDistMapBase<T> >(*this); |
1116 | 1116 |
} |
1117 | 1117 |
|
1118 | 1118 |
template<class T> |
1119 | 1119 |
struct SetProcessedMapBase : public Base { |
1120 | 1120 |
typedef T ProcessedMap; |
1121 | 1121 |
static ProcessedMap *createProcessedMap(const Digraph &) { return 0; }; |
1122 | 1122 |
SetProcessedMapBase(const TR &b) : TR(b) {} |
1123 | 1123 |
}; |
1124 | 1124 |
///\brief \ref named-func-param "Named parameter" |
1125 |
///for setting |
|
1125 |
///for setting ProcessedMap object. |
|
1126 | 1126 |
/// |
1127 | 1127 |
/// \ref named-func-param "Named parameter" |
1128 |
///for setting |
|
1128 |
///for setting ProcessedMap object. |
|
1129 | 1129 |
template<class T> |
1130 | 1130 |
BfsWizard<SetProcessedMapBase<T> > processedMap(const T &t) |
1131 | 1131 |
{ |
1132 | 1132 |
Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t)); |
1133 | 1133 |
return BfsWizard<SetProcessedMapBase<T> >(*this); |
1134 | 1134 |
} |
1135 | 1135 |
|
1136 | 1136 |
template<class T> |
... | ... |
@@ -1262,21 +1262,21 @@ |
1262 | 1262 |
typedef _Digraph Digraph; |
1263 | 1263 |
|
1264 | 1264 |
/// \brief The type of the map that indicates which nodes are reached. |
1265 | 1265 |
/// |
1266 | 1266 |
/// The type of the map that indicates which nodes are reached. |
1267 | 1267 |
/// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
1268 | 1268 |
typedef typename Digraph::template NodeMap<bool> ReachedMap; |
1269 | 1269 |
|
1270 |
/// \brief Instantiates a |
|
1270 |
/// \brief Instantiates a ReachedMap. |
|
1271 | 1271 |
/// |
1272 |
/// This function instantiates a |
|
1272 |
/// This function instantiates a ReachedMap. |
|
1273 | 1273 |
/// \param digraph is the digraph, to which |
1274 |
/// we would like to define the |
|
1274 |
/// we would like to define the ReachedMap. |
|
1275 | 1275 |
static ReachedMap *createReachedMap(const Digraph &digraph) { |
1276 | 1276 |
return new ReachedMap(digraph); |
1277 | 1277 |
} |
1278 | 1278 |
|
1279 | 1279 |
}; |
1280 | 1280 |
|
1281 | 1281 |
/// \ingroup search |
1282 | 1282 |
/// |
... | ... |
@@ -19,327 +19,317 @@ |
19 | 19 |
#ifndef LEMON_BITS_ALTERATION_NOTIFIER_H |
20 | 20 |
#define LEMON_BITS_ALTERATION_NOTIFIER_H |
21 | 21 |
|
22 | 22 |
#include <vector> |
23 | 23 |
#include <list> |
24 | 24 |
|
25 | 25 |
#include <lemon/core.h> |
26 | 26 |
|
27 |
///\ingroup graphbits |
|
28 |
///\file |
|
29 |
|
|
27 |
//\ingroup graphbits |
|
28 |
//\file |
|
29 |
//\brief Observer notifier for graph alteration observers. |
|
30 | 30 |
|
31 | 31 |
namespace lemon { |
32 | 32 |
|
33 |
/// \ingroup graphbits |
|
34 |
/// |
|
35 |
/// \brief Notifier class to notify observes about alterations in |
|
36 |
/// a container. |
|
37 |
/// |
|
38 |
/// The simple graph's can be refered as two containers, one node container |
|
39 |
/// and one edge container. But they are not standard containers they |
|
40 |
/// does not store values directly they are just key continars for more |
|
41 |
/// value containers which are the node and edge maps. |
|
42 |
/// |
|
43 |
/// The graph's node and edge sets can be changed as we add or erase |
|
44 |
/// nodes and edges in the graph. LEMON would like to handle easily |
|
45 |
/// that the node and edge maps should contain values for all nodes or |
|
46 |
/// edges. If we want to check on every indicing if the map contains |
|
47 |
/// the current indicing key that cause a drawback in the performance |
|
48 |
/// in the library. We use another solution we notify all maps about |
|
49 |
/// an alteration in the graph, which cause only drawback on the |
|
50 |
/// alteration of the graph. |
|
51 |
/// |
|
52 |
/// This class provides an interface to the container. The \e first() and \e |
|
53 |
/// next() member functions make possible to iterate on the keys of the |
|
54 |
/// container. The \e id() function returns an integer id for each key. |
|
55 |
/// The \e maxId() function gives back an upper bound of the ids. |
|
56 |
/// |
|
57 |
/// For the proper functonality of this class, we should notify it |
|
58 |
/// about each alteration in the container. The alterations have four type |
|
59 |
/// as \e add(), \e erase(), \e build() and \e clear(). The \e add() and |
|
60 |
/// \e erase() signals that only one or few items added or erased to or |
|
61 |
/// from the graph. If all items are erased from the graph or from an empty |
|
62 |
/// graph a new graph is builded then it can be signaled with the |
|
63 |
/// clear() and build() members. Important rule that if we erase items |
|
64 |
/// from graph we should first signal the alteration and after that erase |
|
65 |
/// them from the container, on the other way on item addition we should |
|
66 |
/// first extend the container and just after that signal the alteration. |
|
67 |
/// |
|
68 |
/// The alteration can be observed with a class inherited from the |
|
69 |
/// \e ObserverBase nested class. The signals can be handled with |
|
70 |
/// overriding the virtual functions defined in the base class. The |
|
71 |
/// observer base can be attached to the notifier with the |
|
72 |
/// \e attach() member and can be detached with detach() function. The |
|
73 |
/// alteration handlers should not call any function which signals |
|
74 |
/// an other alteration in the same notifier and should not |
|
75 |
/// detach any observer from the notifier. |
|
76 |
/// |
|
77 |
/// Alteration observers try to be exception safe. If an \e add() or |
|
78 |
/// a \e clear() function throws an exception then the remaining |
|
79 |
/// observeres will not be notified and the fulfilled additions will |
|
80 |
/// be rolled back by calling the \e erase() or \e clear() |
|
81 |
/// functions. Thence the \e erase() and \e clear() should not throw |
|
82 |
/// exception. Actullay, it can be throw only |
|
83 |
/// \ref AlterationObserver::ImmediateDetach ImmediateDetach |
|
84 |
/// exception which detach the observer from the notifier. |
|
85 |
/// |
|
86 |
/// There are some place when the alteration observing is not completly |
|
87 |
/// reliable. If we want to carry out the node degree in the graph |
|
88 |
/// as in the \ref InDegMap and we use the reverseEdge that cause |
|
89 |
/// unreliable functionality. Because the alteration observing signals |
|
90 |
/// only erasing and adding but not the reversing it will stores bad |
|
91 |
/// degrees. The sub graph adaptors cannot signal the alterations because |
|
92 |
/// just a setting in the filter map can modify the graph and this cannot |
|
93 |
/// be watched in any way. |
|
94 |
/// |
|
95 |
/// \param _Container The container which is observed. |
|
96 |
/// \param _Item The item type which is obserbved. |
|
33 |
// \ingroup graphbits |
|
34 |
// |
|
35 |
// \brief Notifier class to notify observes about alterations in |
|
36 |
// a container. |
|
37 |
// |
|
38 |
// The simple graph's can be refered as two containers, one node container |
|
39 |
// and one edge container. But they are not standard containers they |
|
40 |
// does not store values directly they are just key continars for more |
|
41 |
// value containers which are the node and edge maps. |
|
42 |
// |
|
43 |
// The graph's node and edge sets can be changed as we add or erase |
|
44 |
// nodes and edges in the graph. LEMON would like to handle easily |
|
45 |
// that the node and edge maps should contain values for all nodes or |
|
46 |
// edges. If we want to check on every indicing if the map contains |
|
47 |
// the current indicing key that cause a drawback in the performance |
|
48 |
// in the library. We use another solution we notify all maps about |
|
49 |
// an alteration in the graph, which cause only drawback on the |
|
50 |
// alteration of the graph. |
|
51 |
// |
|
52 |
// This class provides an interface to the container. The \e first() and \e |
|
53 |
// next() member functions make possible to iterate on the keys of the |
|
54 |
// container. The \e id() function returns an integer id for each key. |
|
55 |
// The \e maxId() function gives back an upper bound of the ids. |
|
56 |
// |
|
57 |
// For the proper functonality of this class, we should notify it |
|
58 |
// about each alteration in the container. The alterations have four type |
|
59 |
// as \e add(), \e erase(), \e build() and \e clear(). The \e add() and |
|
60 |
// \e erase() signals that only one or few items added or erased to or |
|
61 |
// from the graph. If all items are erased from the graph or from an empty |
|
62 |
// graph a new graph is builded then it can be signaled with the |
|
63 |
// clear() and build() members. Important rule that if we erase items |
|
64 |
// from graph we should first signal the alteration and after that erase |
|
65 |
// them from the container, on the other way on item addition we should |
|
66 |
// first extend the container and just after that signal the alteration. |
|
67 |
// |
|
68 |
// The alteration can be observed with a class inherited from the |
|
69 |
// \e ObserverBase nested class. The signals can be handled with |
|
70 |
// overriding the virtual functions defined in the base class. The |
|
71 |
// observer base can be attached to the notifier with the |
|
72 |
// \e attach() member and can be detached with detach() function. The |
|
73 |
// alteration handlers should not call any function which signals |
|
74 |
// an other alteration in the same notifier and should not |
|
75 |
// detach any observer from the notifier. |
|
76 |
// |
|
77 |
// Alteration observers try to be exception safe. If an \e add() or |
|
78 |
// a \e clear() function throws an exception then the remaining |
|
79 |
// observeres will not be notified and the fulfilled additions will |
|
80 |
// be rolled back by calling the \e erase() or \e clear() |
|
81 |
// functions. Thence the \e erase() and \e clear() should not throw |
|
82 |
// exception. Actullay, it can be throw only \ref ImmediateDetach |
|
83 |
// exception which detach the observer from the notifier. |
|
84 |
// |
|
85 |
// There are some place when the alteration observing is not completly |
|
86 |
// reliable. If we want to carry out the node degree in the graph |
|
87 |
// as in the \ref InDegMap and we use the reverseEdge that cause |
|
88 |
// unreliable functionality. Because the alteration observing signals |
|
89 |
// only erasing and adding but not the reversing it will stores bad |
|
90 |
// degrees. The sub graph adaptors cannot signal the alterations because |
|
91 |
// just a setting in the filter map can modify the graph and this cannot |
|
92 |
// be watched in any way. |
|
93 |
// |
|
94 |
// \param _Container The container which is observed. |
|
95 |
// \param _Item The item type which is obserbved. |
|
97 | 96 |
|
98 | 97 |
template <typename _Container, typename _Item> |
99 | 98 |
class AlterationNotifier { |
100 | 99 |
public: |
101 | 100 |
|
102 | 101 |
typedef True Notifier; |
103 | 102 |
|
104 | 103 |
typedef _Container Container; |
105 | 104 |
typedef _Item Item; |
106 | 105 |
|
107 |
/// \brief Exception which can be called from \e clear() and |
|
108 |
/// \e erase(). |
|
109 |
/// |
|
110 |
/// From the \e clear() and \e erase() function only this |
|
111 |
/// exception is allowed to throw. The exception immediatly |
|
112 |
/// detaches the current observer from the notifier. Because the |
|
113 |
/// \e clear() and \e erase() should not throw other exceptions |
|
114 |
/// it can be used to invalidate the observer. |
|
106 |
// \brief Exception which can be called from \e clear() and |
|
107 |
// \e erase(). |
|
108 |
// |
|
109 |
// From the \e clear() and \e erase() function only this |
|
110 |
// exception is allowed to throw. The exception immediatly |
|
111 |
// detaches the current observer from the notifier. Because the |
|
112 |
// \e clear() and \e erase() should not throw other exceptions |
|
113 |
// it can be used to invalidate the observer. |
|
115 | 114 |
struct ImmediateDetach {}; |
116 | 115 |
|
117 |
/// \brief ObserverBase is the base class for the observers. |
|
118 |
/// |
|
119 |
/// ObserverBase is the abstract base class for the observers. |
|
120 |
/// It will be notified about an item was inserted into or |
|
121 |
/// erased from the graph. |
|
122 |
/// |
|
123 |
/// The observer interface contains some pure virtual functions |
|
124 |
/// to override. The add() and erase() functions are |
|
125 |
/// to notify the oberver when one item is added or |
|
126 |
/// erased. |
|
127 |
/// |
|
128 |
/// The build() and clear() members are to notify the observer |
|
129 |
/// about the container is built from an empty container or |
|
130 |
/// is cleared to an empty container. |
|
131 |
|
|
116 |
// \brief ObserverBase is the base class for the observers. |
|
117 |
// |
|
118 |
// ObserverBase is the abstract base class for the observers. |
|
119 |
// It will be notified about an item was inserted into or |
|
120 |
// erased from the graph. |
|
121 |
// |
|
122 |
// The observer interface contains some pure virtual functions |
|
123 |
// to override. The add() and erase() functions are |
|
124 |
// to notify the oberver when one item is added or |
|
125 |
// erased. |
|
126 |
// |
|
127 |
// The build() and clear() members are to notify the observer |
|
128 |
// about the container is built from an empty container or |
|
129 |
// is cleared to an empty container. |
|
132 | 130 |
class ObserverBase { |
133 | 131 |
protected: |
134 | 132 |
typedef AlterationNotifier Notifier; |
135 | 133 |
|
136 | 134 |
friend class AlterationNotifier; |
137 | 135 |
|
138 |
/// \brief Default constructor. |
|
139 |
/// |
|
140 |
/// Default constructor for ObserverBase. |
|
141 |
/// |
|
136 |
// \brief Default constructor. |
|
137 |
// |
|
138 |
// Default constructor for ObserverBase. |
|
142 | 139 |
ObserverBase() : _notifier(0) {} |
143 | 140 |
|
144 |
/// \brief Constructor which attach the observer into notifier. |
|
145 |
/// |
|
146 |
// |
|
141 |
// \brief Constructor which attach the observer into notifier. |
|
142 |
// |
|
143 |
// Constructor which attach the observer into notifier. |
|
147 | 144 |
ObserverBase(AlterationNotifier& nf) { |
148 | 145 |
attach(nf); |
149 | 146 |
} |
150 | 147 |
|
151 |
/// \brief Constructor which attach the obserever to the same notifier. |
|
152 |
/// |
|
153 |
/// Constructor which attach the obserever to the same notifier as |
|
154 |
/// the other observer is attached to. |
|
148 |
// \brief Constructor which attach the obserever to the same notifier. |
|
149 |
// |
|
150 |
// Constructor which attach the obserever to the same notifier as |
|
151 |
// the other observer is attached to. |
|
155 | 152 |
ObserverBase(const ObserverBase& copy) { |
156 | 153 |
if (copy.attached()) { |
157 | 154 |
attach(*copy.notifier()); |
158 | 155 |
} |
159 | 156 |
} |
160 | 157 |
|
161 |
// |
|
158 |
// \brief Destructor |
|
162 | 159 |
virtual ~ObserverBase() { |
163 | 160 |
if (attached()) { |
164 | 161 |
detach(); |
165 | 162 |
} |
166 | 163 |
} |
167 | 164 |
|
168 |
/// \brief Attaches the observer into an AlterationNotifier. |
|
169 |
/// |
|
170 |
/// This member attaches the observer into an AlterationNotifier. |
|
171 |
/// |
|
165 |
// \brief Attaches the observer into an AlterationNotifier. |
|
166 |
// |
|
167 |
// This member attaches the observer into an AlterationNotifier. |
|
172 | 168 |
void attach(AlterationNotifier& nf) { |
173 | 169 |
nf.attach(*this); |
174 | 170 |
} |
175 | 171 |
|
176 |
/// \brief Detaches the observer into an AlterationNotifier. |
|
177 |
/// |
|
178 |
/// This member detaches the observer from an AlterationNotifier. |
|
179 |
/// |
|
172 |
// \brief Detaches the observer into an AlterationNotifier. |
|
173 |
// |
|
174 |
// This member detaches the observer from an AlterationNotifier. |
|
180 | 175 |
void detach() { |
181 | 176 |
_notifier->detach(*this); |
182 | 177 |
} |
183 | 178 |
|
184 |
/// \brief Gives back a pointer to the notifier which the map |
|
185 |
/// attached into. |
|
186 |
/// |
|
187 |
/// This function gives back a pointer to the notifier which the map |
|
188 |
/// attached into. |
|
189 |
/// |
|
179 |
// \brief Gives back a pointer to the notifier which the map |
|
180 |
// attached into. |
|
181 |
// |
|
182 |
// This function gives back a pointer to the notifier which the map |
|
183 |
// attached into. |
|
190 | 184 |
Notifier* notifier() const { return const_cast<Notifier*>(_notifier); } |
191 | 185 |
|
192 |
|
|
186 |
// Gives back true when the observer is attached into a notifier. |
|
193 | 187 |
bool attached() const { return _notifier != 0; } |
194 | 188 |
|
195 | 189 |
private: |
196 | 190 |
|
197 | 191 |
ObserverBase& operator=(const ObserverBase& copy); |
198 | 192 |
|
199 | 193 |
protected: |
200 | 194 |
|
201 | 195 |
Notifier* _notifier; |
202 | 196 |
typename std::list<ObserverBase*>::iterator _index; |
203 | 197 |
|
204 |
/// \brief The member function to notificate the observer about an |
|
205 |
/// item is added to the container. |
|
206 |
/// |
|
207 |
/// The add() member function notificates the observer about an item |
|
208 |
/// is added to the container. It have to be overrided in the |
|
209 |
/// subclasses. |
|
198 |
// \brief The member function to notificate the observer about an |
|
199 |
// item is added to the container. |
|
200 |
// |
|
201 |
// The add() member function notificates the observer about an item |
|
202 |
// is added to the container. It have to be overrided in the |
|
203 |
// subclasses. |
|
210 | 204 |
virtual void add(const Item&) = 0; |
211 | 205 |
|
212 |
/// \brief The member function to notificate the observer about |
|
213 |
/// more item is added to the container. |
|
214 |
/// |
|
215 |
/// The add() member function notificates the observer about more item |
|
216 |
/// is added to the container. It have to be overrided in the |
|
217 |
/// subclasses. |
|
206 |
// \brief The member function to notificate the observer about |
|
207 |
// more item is added to the container. |
|
208 |
// |
|
209 |
// The add() member function notificates the observer about more item |
|
210 |
// is added to the container. It have to be overrided in the |
|
211 |
// subclasses. |
|
218 | 212 |
virtual void add(const std::vector<Item>& items) = 0; |
219 | 213 |
|
220 |
/// \brief The member function to notificate the observer about an |
|
221 |
/// item is erased from the container. |
|
222 |
/// |
|
223 |
/// The erase() member function notificates the observer about an |
|
224 |
/// item is erased from the container. It have to be overrided in |
|
225 |
/// the subclasses. |
|
214 |
// \brief The member function to notificate the observer about an |
|
215 |
// item is erased from the container. |
|
216 |
// |
|
217 |
// The erase() member function notificates the observer about an |
|
218 |
// item is erased from the container. It have to be overrided in |
|
219 |
// the subclasses. |
|
226 | 220 |
virtual void erase(const Item&) = 0; |
227 | 221 |
|
228 |
/// \brief The member function to notificate the observer about |
|
229 |
/// more item is erased from the container. |
|
230 |
/// |
|
231 |
/// The erase() member function notificates the observer about more item |
|
232 |
/// is erased from the container. It have to be overrided in the |
|
233 |
/// subclasses. |
|
222 |
// \brief The member function to notificate the observer about |
|
223 |
// more item is erased from the container. |
|
224 |
// |
|
225 |
// The erase() member function notificates the observer about more item |
|
226 |
// is erased from the container. It have to be overrided in the |
|
227 |
// subclasses. |
|
234 | 228 |
virtual void erase(const std::vector<Item>& items) = 0; |
235 | 229 |
|
236 |
/// \brief The member function to notificate the observer about the |
|
237 |
/// container is built. |
|
238 |
/// |
|
239 |
/// The build() member function notificates the observer about the |
|
240 |
/// container is built from an empty container. It have to be |
|
241 |
/// overrided in the subclasses. |
|
242 |
|
|
230 |
// \brief The member function to notificate the observer about the |
|
231 |
// container is built. |
|
232 |
// |
|
233 |
// The build() member function notificates the observer about the |
|
234 |
// container is built from an empty container. It have to be |
|
235 |
// overrided in the subclasses. |
|
243 | 236 |
virtual void build() = 0; |
244 | 237 |
|
245 |
/// \brief The member function to notificate the observer about all |
|
246 |
/// items are erased from the container. |
|
247 |
/// |
|
248 |
/// The clear() member function notificates the observer about all |
|
249 |
/// items are erased from the container. It have to be overrided in |
|
250 |
/// the subclasses. |
|
238 |
// \brief The member function to notificate the observer about all |
|
239 |
// items are erased from the container. |
|
240 |
// |
|
241 |
// The clear() member function notificates the observer about all |
|
242 |
// items are erased from the container. It have to be overrided in |
|
243 |
// the subclasses. |
|
251 | 244 |
virtual void clear() = 0; |
252 | 245 |
|
253 | 246 |
}; |
254 | 247 |
|
255 | 248 |
protected: |
256 | 249 |
|
257 | 250 |
const Container* container; |
258 | 251 |
|
259 | 252 |
typedef std::list<ObserverBase*> Observers; |
260 | 253 |
Observers _observers; |
261 | 254 |
|
262 | 255 |
|
263 | 256 |
public: |
264 | 257 |
|
265 |
/// \brief Default constructor. |
|
266 |
/// |
|
267 |
/// The default constructor of the AlterationNotifier. |
|
268 |
/// It creates an empty notifier. |
|
258 |
// \brief Default constructor. |
|
259 |
// |
|
260 |
// The default constructor of the AlterationNotifier. |
|
261 |
// It creates an empty notifier. |
|
269 | 262 |
AlterationNotifier() |
270 | 263 |
: container(0) {} |
271 | 264 |
|
272 |
/// \brief Constructor. |
|
273 |
/// |
|
274 |
// |
|
265 |
// \brief Constructor. |
|
266 |
// |
|
267 |
// Constructor with the observed container parameter. |
|
275 | 268 |
AlterationNotifier(const Container& _container) |
276 | 269 |
: container(&_container) {} |
277 | 270 |
|
278 |
/// \brief Copy Constructor of the AlterationNotifier. |
|
279 |
/// |
|
280 |
/// Copy constructor of the AlterationNotifier. |
|
281 |
/// It creates only an empty notifier because the copiable |
|
282 |
// |
|
271 |
// \brief Copy Constructor of the AlterationNotifier. |
|
272 |
// |
|
273 |
// Copy constructor of the AlterationNotifier. |
|
274 |
// It creates only an empty notifier because the copiable |
|
275 |
// notifier's observers have to be registered still into that notifier. |
|
283 | 276 |
AlterationNotifier(const AlterationNotifier& _notifier) |
284 | 277 |
: container(_notifier.container) {} |
285 | 278 |
|
286 |
/// \brief Destructor. |
|
287 |
/// |
|
288 |
/// Destructor of the AlterationNotifier. |
|
289 |
/// |
|
279 |
// \brief Destructor. |
|
280 |
// |
|
281 |
// Destructor of the AlterationNotifier. |
|
290 | 282 |
~AlterationNotifier() { |
291 | 283 |
typename Observers::iterator it; |
292 | 284 |
for (it = _observers.begin(); it != _observers.end(); ++it) { |
293 | 285 |
(*it)->_notifier = 0; |
294 | 286 |
} |
295 | 287 |
} |
296 | 288 |
|
297 |
/// \brief Sets the container. |
|
298 |
/// |
|
299 |
// |
|
289 |
// \brief Sets the container. |
|
290 |
// |
|
291 |
// Sets the container. |
|
300 | 292 |
void setContainer(const Container& _container) { |
301 | 293 |
container = &_container; |
302 | 294 |
} |
303 | 295 |
|
304 | 296 |
protected: |
305 | 297 |
|
306 | 298 |
AlterationNotifier& operator=(const AlterationNotifier&); |
307 | 299 |
|
308 | 300 |
public: |
309 | 301 |
|
310 |
|
|
311 |
|
|
312 |
/// \brief First item in the container. |
|
313 |
/// |
|
314 |
/// Returns the first item in the container. It is |
|
315 |
/// for start the iteration on the container. |
|
302 |
// \brief First item in the container. |
|
303 |
// |
|
304 |
// Returns the first item in the container. It is |
|
305 |
// for start the iteration on the container. |
|
316 | 306 |
void first(Item& item) const { |
317 | 307 |
container->first(item); |
318 | 308 |
} |
319 | 309 |
|
320 |
/// \brief Next item in the container. |
|
321 |
/// |
|
322 |
/// Returns the next item in the container. It is |
|
323 |
/// for iterate on the container. |
|
310 |
// \brief Next item in the container. |
|
311 |
// |
|
312 |
// Returns the next item in the container. It is |
|
313 |
// for iterate on the container. |
|
324 | 314 |
void next(Item& item) const { |
325 | 315 |
container->next(item); |
326 | 316 |
} |
327 | 317 |
|
328 |
/// \brief Returns the id of the item. |
|
329 |
/// |
|
330 |
// |
|
318 |
// \brief Returns the id of the item. |
|
319 |
// |
|
320 |
// Returns the id of the item provided by the container. |
|
331 | 321 |
int id(const Item& item) const { |
332 | 322 |
return container->id(item); |
333 | 323 |
} |
334 | 324 |
|
335 |
/// \brief Returns the maximum id of the container. |
|
336 |
/// |
|
337 |
// |
|
325 |
// \brief Returns the maximum id of the container. |
|
326 |
// |
|
327 |
// Returns the maximum id of the container. |
|
338 | 328 |
int maxId() const { |
339 | 329 |
return container->maxId(Item()); |
340 | 330 |
} |
341 | 331 |
|
342 | 332 |
protected: |
343 | 333 |
|
344 | 334 |
void attach(ObserverBase& observer) { |
345 | 335 |
observer._index = _observers.insert(_observers.begin(), &observer); |
... | ... |
@@ -349,123 +339,119 @@ |
349 | 339 |
void detach(ObserverBase& observer) { |
350 | 340 |
_observers.erase(observer._index); |
351 | 341 |
observer._index = _observers.end(); |
352 | 342 |
observer._notifier = 0; |
353 | 343 |
} |
354 | 344 |
|
355 | 345 |
public: |
356 | 346 |
|
357 |
/// \brief Notifies all the registed observers about an item added to |
|
358 |
/// the container. |
|
359 |
/// |
|
360 |
/// It notifies all the registed observers about an item added to |
|
361 |
/// the container. |
|
362 |
/// |
|
347 |
// \brief Notifies all the registed observers about an item added to |
|
348 |
// the container. |
|
349 |
// |
|
350 |
// It notifies all the registed observers about an item added to |
|
351 |
// the container. |
|
363 | 352 |
void add(const Item& item) { |
364 | 353 |
typename Observers::reverse_iterator it; |
365 | 354 |
try { |
366 | 355 |
for (it = _observers.rbegin(); it != _observers.rend(); ++it) { |
367 | 356 |
(*it)->add(item); |
368 | 357 |
} |
369 | 358 |
} catch (...) { |
370 | 359 |
typename Observers::iterator jt; |
371 | 360 |
for (jt = it.base(); jt != _observers.end(); ++jt) { |
372 | 361 |
(*jt)->erase(item); |
373 | 362 |
} |
374 | 363 |
throw; |
375 | 364 |
} |
376 | 365 |
} |
377 | 366 |
|
378 |
/// \brief Notifies all the registed observers about more item added to |
|
379 |
/// the container. |
|
380 |
/// |
|
381 |
/// It notifies all the registed observers about more item added to |
|
382 |
/// the container. |
|
383 |
/// |
|
367 |
// \brief Notifies all the registed observers about more item added to |
|
368 |
// the container. |
|
369 |
// |
|
370 |
// It notifies all the registed observers about more item added to |
|
371 |
// the container. |
|
384 | 372 |
void add(const std::vector<Item>& items) { |
385 | 373 |
typename Observers::reverse_iterator it; |
386 | 374 |
try { |
387 | 375 |
for (it = _observers.rbegin(); it != _observers.rend(); ++it) { |
388 | 376 |
(*it)->add(items); |
389 | 377 |
} |
390 | 378 |
} catch (...) { |
391 | 379 |
typename Observers::iterator jt; |
392 | 380 |
for (jt = it.base(); jt != _observers.end(); ++jt) { |
393 | 381 |
(*jt)->erase(items); |
394 | 382 |
} |
395 | 383 |
throw; |
396 | 384 |
} |
397 | 385 |
} |
398 | 386 |
|
399 |
/// \brief Notifies all the registed observers about an item erased from |
|
400 |
/// the container. |
|
401 |
/// |
|
402 |
/// It notifies all the registed observers about an item erased from |
|
403 |
/// the container. |
|
404 |
/// |
|
387 |
// \brief Notifies all the registed observers about an item erased from |
|
388 |
// the container. |
|
389 |
// |
|
390 |
// It notifies all the registed observers about an item erased from |
|
391 |
// the container. |
|
405 | 392 |
void erase(const Item& item) throw() { |
406 | 393 |
typename Observers::iterator it = _observers.begin(); |
407 | 394 |
while (it != _observers.end()) { |
408 | 395 |
try { |
409 | 396 |
(*it)->erase(item); |
410 | 397 |
++it; |
411 | 398 |
} catch (const ImmediateDetach&) { |
412 | 399 |
(*it)->_index = _observers.end(); |
413 | 400 |
(*it)->_notifier = 0; |
414 | 401 |
it = _observers.erase(it); |
415 | 402 |
} |
416 | 403 |
} |
417 | 404 |
} |
418 | 405 |
|
419 |
/// \brief Notifies all the registed observers about more item erased |
|
420 |
/// from the container. |
|
421 |
/// |
|
422 |
/// It notifies all the registed observers about more item erased from |
|
423 |
/// the container. |
|
424 |
/// |
|
406 |
// \brief Notifies all the registed observers about more item erased |
|
407 |
// from the container. |
|
408 |
// |
|
409 |
// It notifies all the registed observers about more item erased from |
|
410 |
// the container. |
|
425 | 411 |
void erase(const std::vector<Item>& items) { |
426 | 412 |
typename Observers::iterator it = _observers.begin(); |
427 | 413 |
while (it != _observers.end()) { |
428 | 414 |
try { |
429 | 415 |
(*it)->erase(items); |
430 | 416 |
++it; |
431 | 417 |
} catch (const ImmediateDetach&) { |
432 | 418 |
(*it)->_index = _observers.end(); |
433 | 419 |
(*it)->_notifier = 0; |
434 | 420 |
it = _observers.erase(it); |
435 | 421 |
} |
436 | 422 |
} |
437 | 423 |
} |
438 | 424 |
|
439 |
/// \brief Notifies all the registed observers about the container is |
|
440 |
/// built. |
|
441 |
/// |
|
442 |
/// Notifies all the registed observers about the container is built |
|
443 |
// |
|
425 |
// \brief Notifies all the registed observers about the container is |
|
426 |
// built. |
|
427 |
// |
|
428 |
// Notifies all the registed observers about the container is built |
|
429 |
// from an empty container. |
|
444 | 430 |
void build() { |
445 | 431 |
typename Observers::reverse_iterator it; |
446 | 432 |
try { |
447 | 433 |
for (it = _observers.rbegin(); it != _observers.rend(); ++it) { |
448 | 434 |
(*it)->build(); |
449 | 435 |
} |
450 | 436 |
} catch (...) { |
451 | 437 |
typename Observers::iterator jt; |
452 | 438 |
for (jt = it.base(); jt != _observers.end(); ++jt) { |
453 | 439 |
(*jt)->clear(); |
454 | 440 |
} |
455 | 441 |
throw; |
456 | 442 |
} |
457 | 443 |
} |
458 | 444 |
|
459 |
/// \brief Notifies all the registed observers about all items are |
|
460 |
/// erased. |
|
461 |
/// |
|
462 |
/// Notifies all the registed observers about all items are erased |
|
463 |
// |
|
445 |
// \brief Notifies all the registed observers about all items are |
|
446 |
// erased. |
|
447 |
// |
|
448 |
// Notifies all the registed observers about all items are erased |
|
449 |
// from the container. |
|
464 | 450 |
void clear() { |
465 | 451 |
typename Observers::iterator it = _observers.begin(); |
466 | 452 |
while (it != _observers.end()) { |
467 | 453 |
try { |
468 | 454 |
(*it)->clear(); |
469 | 455 |
++it; |
470 | 456 |
} catch (const ImmediateDetach&) { |
471 | 457 |
(*it)->_index = _observers.end(); |
... | ... |
@@ -21,192 +21,192 @@ |
21 | 21 |
|
22 | 22 |
#include <memory> |
23 | 23 |
|
24 | 24 |
#include <lemon/bits/traits.h> |
25 | 25 |
#include <lemon/bits/alteration_notifier.h> |
26 | 26 |
#include <lemon/concept_check.h> |
27 | 27 |
#include <lemon/concepts/maps.h> |
28 | 28 |
|
29 |
/// \ingroup graphbits |
|
30 |
/// \file |
|
31 |
|
|
29 |
// \ingroup graphbits |
|
30 |
// \file |
|
31 |
// \brief Graph map based on the array storage. |
|
32 | 32 |
|
33 | 33 |
namespace lemon { |
34 | 34 |
|
35 |
/// \ingroup graphbits |
|
36 |
/// |
|
37 |
/// \brief Graph map based on the array storage. |
|
38 |
/// |
|
39 |
/// The ArrayMap template class is graph map structure what |
|
40 |
/// automatically updates the map when a key is added to or erased from |
|
41 |
/// the map. This map uses the allocators to implement |
|
42 |
/// the container functionality. |
|
43 |
/// |
|
44 |
/// The template parameters are the Graph the current Item type and |
|
45 |
// |
|
35 |
// \ingroup graphbits |
|
36 |
// |
|
37 |
// \brief Graph map based on the array storage. |
|
38 |
// |
|
39 |
// The ArrayMap template class is graph map structure what |
|
40 |
// automatically updates the map when a key is added to or erased from |
|
41 |
// the map. This map uses the allocators to implement |
|
42 |
// the container functionality. |
|
43 |
// |
|
44 |
// The template parameters are the Graph the current Item type and |
|
45 |
// the Value type of the map. |
|
46 | 46 |
template <typename _Graph, typename _Item, typename _Value> |
47 | 47 |
class ArrayMap |
48 | 48 |
: public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase { |
49 | 49 |
public: |
50 |
|
|
50 |
// The graph type of the maps. |
|
51 | 51 |
typedef _Graph Graph; |
52 |
|
|
52 |
// The item type of the map. |
|
53 | 53 |
typedef _Item Item; |
54 |
|
|
54 |
// The reference map tag. |
|
55 | 55 |
typedef True ReferenceMapTag; |
56 | 56 |
|
57 |
|
|
57 |
// The key type of the maps. |
|
58 | 58 |
typedef _Item Key; |
59 |
|
|
59 |
// The value type of the map. |
|
60 | 60 |
typedef _Value Value; |
61 | 61 |
|
62 |
|
|
62 |
// The const reference type of the map. |
|
63 | 63 |
typedef const _Value& ConstReference; |
64 |
|
|
64 |
// The reference type of the map. |
|
65 | 65 |
typedef _Value& Reference; |
66 | 66 |
|
67 |
|
|
67 |
// The notifier type. |
|
68 | 68 |
typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier; |
69 | 69 |
|
70 |
|
|
70 |
// The MapBase of the Map which imlements the core regisitry function. |
|
71 | 71 |
typedef typename Notifier::ObserverBase Parent; |
72 | 72 |
|
73 | 73 |
private: |
74 | 74 |
typedef std::allocator<Value> Allocator; |
75 | 75 |
|
76 | 76 |
public: |
77 | 77 |
|
78 |
/// \brief Graph initialized map constructor. |
|
79 |
/// |
|
80 |
// |
|
78 |
// \brief Graph initialized map constructor. |
|
79 |
// |
|
80 |
// Graph initialized map constructor. |
|
81 | 81 |
explicit ArrayMap(const Graph& graph) { |
82 | 82 |
Parent::attach(graph.notifier(Item())); |
83 | 83 |
allocate_memory(); |
84 | 84 |
Notifier* nf = Parent::notifier(); |
85 | 85 |
Item it; |
86 | 86 |
for (nf->first(it); it != INVALID; nf->next(it)) { |
87 | 87 |
int id = nf->id(it);; |
88 | 88 |
allocator.construct(&(values[id]), Value()); |
89 | 89 |
} |
90 | 90 |
} |
91 | 91 |
|
92 |
/// \brief Constructor to use default value to initialize the map. |
|
93 |
/// |
|
94 |
// |
|
92 |
// \brief Constructor to use default value to initialize the map. |
|
93 |
// |
|
94 |
// It constructs a map and initialize all of the the map. |
|
95 | 95 |
ArrayMap(const Graph& graph, const Value& value) { |
96 | 96 |
Parent::attach(graph.notifier(Item())); |
97 | 97 |
allocate_memory(); |
98 | 98 |
Notifier* nf = Parent::notifier(); |
99 | 99 |
Item it; |
100 | 100 |
for (nf->first(it); it != INVALID; nf->next(it)) { |
101 | 101 |
int id = nf->id(it);; |
102 | 102 |
allocator.construct(&(values[id]), value); |
103 | 103 |
} |
104 | 104 |
} |
105 | 105 |
|
106 | 106 |
private: |
107 |
/// \brief Constructor to copy a map of the same map type. |
|
108 |
/// |
|
109 |
// |
|
107 |
// \brief Constructor to copy a map of the same map type. |
|
108 |
// |
|
109 |
// Constructor to copy a map of the same map type. |
|
110 | 110 |
ArrayMap(const ArrayMap& copy) : Parent() { |
111 | 111 |
if (copy.attached()) { |
112 | 112 |
attach(*copy.notifier()); |
113 | 113 |
} |
114 | 114 |
capacity = copy.capacity; |
115 | 115 |
if (capacity == 0) return; |
116 | 116 |
values = allocator.allocate(capacity); |
117 | 117 |
Notifier* nf = Parent::notifier(); |
118 | 118 |
Item it; |
119 | 119 |
for (nf->first(it); it != INVALID; nf->next(it)) { |
120 | 120 |
int id = nf->id(it);; |
121 | 121 |
allocator.construct(&(values[id]), copy.values[id]); |
122 | 122 |
} |
123 | 123 |
} |
124 | 124 |
|
125 |
/// \brief Assign operator. |
|
126 |
/// |
|
127 |
/// This operator assigns for each item in the map the |
|
128 |
/// value mapped to the same item in the copied map. |
|
129 |
/// The parameter map should be indiced with the same |
|
130 |
/// itemset because this assign operator does not change |
|
131 |
// |
|
125 |
// \brief Assign operator. |
|
126 |
// |
|
127 |
// This operator assigns for each item in the map the |
|
128 |
// value mapped to the same item in the copied map. |
|
129 |
// The parameter map should be indiced with the same |
|
130 |
// itemset because this assign operator does not change |
|
131 |
// the container of the map. |
|
132 | 132 |
ArrayMap& operator=(const ArrayMap& cmap) { |
133 | 133 |
return operator=<ArrayMap>(cmap); |
134 | 134 |
} |
135 | 135 |
|
136 | 136 |
|
137 |
/// \brief Template assign operator. |
|
138 |
/// |
|
139 |
/// The given parameter should be conform to the ReadMap |
|
140 |
/// concecpt and could be indiced by the current item set of |
|
141 |
/// the NodeMap. In this case the value for each item |
|
142 |
/// is assigned by the value of the given ReadMap. |
|
137 |
// \brief Template assign operator. |
|
138 |
// |
|
139 |
// The given parameter should be conform to the ReadMap |
|
140 |
// concecpt and could be indiced by the current item set of |
|
141 |
// the NodeMap. In this case the value for each item |
|
142 |
// is assigned by the value of the given ReadMap. |
|
143 | 143 |
template <typename CMap> |
144 | 144 |
ArrayMap& operator=(const CMap& cmap) { |
145 | 145 |
checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); |
146 | 146 |
const typename Parent::Notifier* nf = Parent::notifier(); |
147 | 147 |
Item it; |
148 | 148 |
for (nf->first(it); it != INVALID; nf->next(it)) { |
149 | 149 |
set(it, cmap[it]); |
150 | 150 |
} |
151 | 151 |
return *this; |
152 | 152 |
} |
153 | 153 |
|
154 | 154 |
public: |
155 |
/// \brief The destructor of the map. |
|
156 |
/// |
|
157 |
// |
|
155 |
// \brief The destructor of the map. |
|
156 |
// |
|
157 |
// The destructor of the map. |
|
158 | 158 |
virtual ~ArrayMap() { |
159 | 159 |
if (attached()) { |
160 | 160 |
clear(); |
161 | 161 |
detach(); |
162 | 162 |
} |
163 | 163 |
} |
164 | 164 |
|
165 | 165 |
protected: |
166 | 166 |
|
167 | 167 |
using Parent::attach; |
168 | 168 |
using Parent::detach; |
169 | 169 |
using Parent::attached; |
170 | 170 |
|
171 | 171 |
public: |
172 | 172 |
|
173 |
/// \brief The subscript operator. |
|
174 |
/// |
|
175 |
/// The subscript operator. The map can be subscripted by the |
|
176 |
/// actual keys of the graph. |
|
173 |
// \brief The subscript operator. |
|
174 |
// |
|
175 |
// The subscript operator. The map can be subscripted by the |
|
176 |
// actual keys of the graph. |
|
177 | 177 |
Value& operator[](const Key& key) { |
178 | 178 |
int id = Parent::notifier()->id(key); |
179 | 179 |
return values[id]; |
180 | 180 |
} |
181 | 181 |
|
182 |
/// \brief The const subscript operator. |
|
183 |
/// |
|
184 |
/// The const subscript operator. The map can be subscripted by the |
|
185 |
/// actual keys of the graph. |
|
182 |
// \brief The const subscript operator. |
|
183 |
// |
|
184 |
// The const subscript operator. The map can be subscripted by the |
|
185 |
// actual keys of the graph. |
|
186 | 186 |
const Value& operator[](const Key& key) const { |
187 | 187 |
int id = Parent::notifier()->id(key); |
188 | 188 |
return values[id]; |
189 | 189 |
} |
190 | 190 |
|
191 |
/// \brief Setter function of the map. |
|
192 |
/// |
|
193 |
/// Setter function of the map. Equivalent with map[key] = val. |
|
194 |
/// This is a compatibility feature with the not dereferable maps. |
|
191 |
// \brief Setter function of the map. |
|
192 |
// |
|
193 |
// Setter function of the map. Equivalent with map[key] = val. |
|
194 |
// This is a compatibility feature with the not dereferable maps. |
|
195 | 195 |
void set(const Key& key, const Value& val) { |
196 | 196 |
(*this)[key] = val; |
197 | 197 |
} |
198 | 198 |
|
199 | 199 |
protected: |
200 | 200 |
|
201 |
/// \brief Adds a new key to the map. |
|
202 |
/// |
|
203 |
/// It adds a new key to the map. It called by the observer notifier |
|
204 |
/// and it overrides the add() member function of the observer base. |
|
201 |
// \brief Adds a new key to the map. |
|
202 |
// |
|
203 |
// It adds a new key to the map. It called by the observer notifier |
|
204 |
// and it overrides the add() member function of the observer base. |
|
205 | 205 |
virtual void add(const Key& key) { |
206 | 206 |
Notifier* nf = Parent::notifier(); |
207 | 207 |
int id = nf->id(key); |
208 | 208 |
if (id >= capacity) { |
209 | 209 |
int new_capacity = (capacity == 0 ? 1 : capacity); |
210 | 210 |
while (new_capacity <= id) { |
211 | 211 |
new_capacity <<= 1; |
212 | 212 |
} |
... | ... |
@@ -221,20 +221,20 @@ |
221 | 221 |
} |
222 | 222 |
if (capacity != 0) allocator.deallocate(values, capacity); |
223 | 223 |
values = new_values; |
224 | 224 |
capacity = new_capacity; |
225 | 225 |
} |
226 | 226 |
allocator.construct(&(values[id]), Value()); |
227 | 227 |
} |
228 | 228 |
|
229 |
/// \brief Adds more new keys to the map. |
|
230 |
/// |
|
231 |
/// It adds more new keys to the map. It called by the observer notifier |
|
232 |
/// and it overrides the add() member function of the observer base. |
|
229 |
// \brief Adds more new keys to the map. |
|
230 |
// |
|
231 |
// It adds more new keys to the map. It called by the observer notifier |
|
232 |
// and it overrides the add() member function of the observer base. |
|
233 | 233 |
virtual void add(const std::vector<Key>& keys) { |
234 | 234 |
Notifier* nf = Parent::notifier(); |
235 | 235 |
int max_id = -1; |
236 | 236 |
for (int i = 0; i < int(keys.size()); ++i) { |
237 | 237 |
int id = nf->id(keys[i]); |
238 | 238 |
if (id > max_id) { |
239 | 239 |
max_id = id; |
240 | 240 |
} |
... | ... |
@@ -265,54 +265,54 @@ |
265 | 265 |
capacity = new_capacity; |
266 | 266 |
} |
267 | 267 |
for (int i = 0; i < int(keys.size()); ++i) { |
268 | 268 |
int id = nf->id(keys[i]); |
269 | 269 |
allocator.construct(&(values[id]), Value()); |
270 | 270 |
} |
271 | 271 |
} |
272 | 272 |
|
273 |
/// \brief Erase a key from the map. |
|
274 |
/// |
|
275 |
/// Erase a key from the map. It called by the observer notifier |
|
276 |
/// and it overrides the erase() member function of the observer base. |
|
273 |
// \brief Erase a key from the map. |
|
274 |
// |
|
275 |
// Erase a key from the map. It called by the observer notifier |
|
276 |
// and it overrides the erase() member function of the observer base. |
|
277 | 277 |
virtual void erase(const Key& key) { |
278 | 278 |
int id = Parent::notifier()->id(key); |
279 | 279 |
allocator.destroy(&(values[id])); |
280 | 280 |
} |
281 | 281 |
|
282 |
/// \brief Erase more keys from the map. |
|
283 |
/// |
|
284 |
/// Erase more keys from the map. It called by the observer notifier |
|
285 |
/// and it overrides the erase() member function of the observer base. |
|
282 |
// \brief Erase more keys from the map. |
|
283 |
// |
|
284 |
// Erase more keys from the map. It called by the observer notifier |
|
285 |
// and it overrides the erase() member function of the observer base. |
|
286 | 286 |
virtual void erase(const std::vector<Key>& keys) { |
287 | 287 |
for (int i = 0; i < int(keys.size()); ++i) { |
288 | 288 |
int id = Parent::notifier()->id(keys[i]); |
289 | 289 |
allocator.destroy(&(values[id])); |
290 | 290 |
} |
291 | 291 |
} |
292 | 292 |
|
293 |
/// \brief Buildes the map. |
|
294 |
/// |
|
295 |
/// It buildes the map. It called by the observer notifier |
|
296 |
/// and it overrides the build() member function of the observer base. |
|
293 |
// \brief Buildes the map. |
|
294 |
// |
|
295 |
// It buildes the map. It called by the observer notifier |
|
296 |
// and it overrides the build() member function of the observer base. |
|
297 | 297 |
virtual void build() { |
298 | 298 |
Notifier* nf = Parent::notifier(); |
299 | 299 |
allocate_memory(); |
300 | 300 |
Item it; |
301 | 301 |
for (nf->first(it); it != INVALID; nf->next(it)) { |
302 | 302 |
int id = nf->id(it);; |
303 | 303 |
allocator.construct(&(values[id]), Value()); |
304 | 304 |
} |
305 | 305 |
} |
306 | 306 |
|
307 |
/// \brief Clear the map. |
|
308 |
/// |
|
309 |
/// It erase all items from the map. It called by the observer notifier |
|
310 |
/// and it overrides the clear() member function of the observer base. |
|
307 |
// \brief Clear the map. |
|
308 |
// |
|
309 |
// It erase all items from the map. It called by the observer notifier |
|
310 |
// and it overrides the clear() member function of the observer base. |
|
311 | 311 |
virtual void clear() { |
312 | 312 |
Notifier* nf = Parent::notifier(); |
313 | 313 |
if (capacity != 0) { |
314 | 314 |
Item it; |
315 | 315 |
for (nf->first(it); it != INVALID; nf->next(it)) { |
316 | 316 |
int id = nf->id(it); |
317 | 317 |
allocator.destroy(&(values[id])); |
318 | 318 |
} |
... | ... |
@@ -23,24 +23,24 @@ |
23 | 23 |
#include <lemon/error.h> |
24 | 24 |
|
25 | 25 |
#include <lemon/bits/map_extender.h> |
26 | 26 |
#include <lemon/bits/default_map.h> |
27 | 27 |
|
28 | 28 |
#include <lemon/concept_check.h> |
29 | 29 |
#include <lemon/concepts/maps.h> |
30 | 30 |
|
31 |
///\ingroup digraphbits |
|
32 |
///\file |
|
33 |
|
|
31 |
//\ingroup digraphbits |
|
32 |
//\file |
|
33 |
//\brief Extenders for the digraph types |
|
34 | 34 |
namespace lemon { |
35 | 35 |
|
36 |
/// \ingroup digraphbits |
|
37 |
/// |
|
38 |
// |
|
36 |
// \ingroup digraphbits |
|
37 |
// |
|
38 |
// \brief BaseDigraph to BaseGraph extender |
|
39 | 39 |
template <typename Base> |
40 | 40 |
class UndirDigraphExtender : public Base { |
41 | 41 |
|
42 | 42 |
public: |
43 | 43 |
|
44 | 44 |
typedef Base Parent; |
45 | 45 |
typedef typename Parent::Arc Edge; |
46 | 46 |
typedef typename Parent::Node Node; |
... | ... |
@@ -69,47 +69,47 @@ |
69 | 69 |
return forward!=that.forward || Edge(*this)!=Edge(that); |
70 | 70 |
} |
71 | 71 |
bool operator<(const Arc &that) const { |
72 | 72 |
return forward<that.forward || |
73 | 73 |
(!(that.forward<forward) && Edge(*this)<Edge(that)); |
74 | 74 |
} |
75 | 75 |
}; |
76 | 76 |
|
77 |
|
|
77 |
// First node of the edge |
|
78 | 78 |
Node u(const Edge &e) const { |
79 | 79 |
return Parent::source(e); |
80 | 80 |
} |
81 | 81 |
|
82 |
|
|
82 |
// Source of the given arc |
|
83 | 83 |
Node source(const Arc &e) const { |
84 | 84 |
return e.forward ? Parent::source(e) : Parent::target(e); |
85 | 85 |
} |
86 | 86 |
|
87 |
|
|
87 |
// Second node of the edge |
|
88 | 88 |
Node v(const Edge &e) const { |
89 | 89 |
return Parent::target(e); |
90 | 90 |
} |
91 | 91 |
|
92 |
|
|
92 |
// Target of the given arc |
|
93 | 93 |
Node target(const Arc &e) const { |
94 | 94 |
return e.forward ? Parent::target(e) : Parent::source(e); |
95 | 95 |
} |
96 | 96 |
|
97 |
/// \brief Directed arc from an edge. |
|
98 |
/// |
|
99 |
/// Returns a directed arc corresponding to the specified edge. |
|
100 |
/// If the given bool is true, the first node of the given edge and |
|
101 |
// |
|
97 |
// \brief Directed arc from an edge. |
|
98 |
// |
|
99 |
// Returns a directed arc corresponding to the specified edge. |
|
100 |
// If the given bool is true, the first node of the given edge and |
|
101 |
// the source node of the returned arc are the same. |
|
102 | 102 |
static Arc direct(const Edge &e, bool d) { |
103 | 103 |
return Arc(e, d); |
104 | 104 |
} |
105 | 105 |
|
106 |
/// Returns whether the given directed arc has the same orientation |
|
107 |
/// as the corresponding edge. |
|
106 |
// Returns whether the given directed arc has the same orientation |
|
107 |
// as the corresponding edge. |
|
108 | 108 |
static bool direction(const Arc &a) { return a.forward; } |
109 | 109 |
|
110 | 110 |
using Parent::first; |
111 | 111 |
using Parent::next; |
112 | 112 |
|
113 | 113 |
void first(Arc &e) const { |
114 | 114 |
Parent::first(e); |
115 | 115 |
e.forward=true; |
... | ... |
@@ -14,21 +14,21 @@ |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BEZIER_H |
20 | 20 |
#define LEMON_BEZIER_H |
21 | 21 |
|
22 |
///\ingroup misc |
|
23 |
///\file |
|
24 |
///\brief Classes to compute with Bezier curves. |
|
25 |
/// |
|
26 |
// |
|
22 |
//\ingroup misc |
|
23 |
//\file |
|
24 |
//\brief Classes to compute with Bezier curves. |
|
25 |
// |
|
26 |
//Up to now this file is used internally by \ref graph_to_eps.h |
|
27 | 27 |
|
28 | 28 |
#include<lemon/dim2.h> |
29 | 29 |
|
30 | 30 |
namespace lemon { |
31 | 31 |
namespace dim2 { |
32 | 32 |
|
33 | 33 |
class BezierBase { |
34 | 34 |
public: |
... | ... |
@@ -14,24 +14,23 @@ |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_DEFAULT_MAP_H |
20 | 20 |
#define LEMON_BITS_DEFAULT_MAP_H |
21 | 21 |
|
22 |
|
|
23 | 22 |
#include <lemon/bits/array_map.h> |
24 | 23 |
#include <lemon/bits/vector_map.h> |
25 | 24 |
//#include <lemon/bits/debug_map.h> |
26 | 25 |
|
27 |
///\ingroup graphbits |
|
28 |
///\file |
|
29 |
|
|
26 |
//\ingroup graphbits |
|
27 |
//\file |
|
28 |
//\brief Graph maps that construct and destruct their elements dynamically. |
|
30 | 29 |
|
31 | 30 |
namespace lemon { |
32 | 31 |
|
33 | 32 |
|
34 | 33 |
//#ifndef LEMON_USE_DEBUG_MAP |
35 | 34 |
|
36 | 35 |
template <typename _Graph, typename _Item, typename _Value> |
37 | 36 |
struct DefaultMapSelector { |
... | ... |
@@ -144,17 +143,17 @@ |
144 | 143 |
|
145 | 144 |
// template <typename _Graph, typename _Item, typename _Value> |
146 | 145 |
// struct DefaultMapSelector { |
147 | 146 |
// typedef DebugMap<_Graph, _Item, _Value> Map; |
148 | 147 |
// }; |
149 | 148 |
|
150 | 149 |
// #endif |
151 | 150 |
|
152 |
// |
|
151 |
// DefaultMap class |
|
153 | 152 |
template <typename _Graph, typename _Item, typename _Value> |
154 | 153 |
class DefaultMap |
155 | 154 |
: public DefaultMapSelector<_Graph, _Item, _Value>::Map { |
156 | 155 |
public: |
157 | 156 |
typedef typename DefaultMapSelector<_Graph, _Item, _Value>::Map Parent; |
158 | 157 |
typedef DefaultMap<_Graph, _Item, _Value> Map; |
159 | 158 |
|
160 | 159 |
typedef typename Parent::Graph Graph; |
... | ... |
@@ -30,39 +30,39 @@ |
30 | 30 |
// Authors: Jaakko Jarvi (jajarvi at osl.iu.edu) |
31 | 31 |
// Jeremiah Willcock (jewillco at osl.iu.edu) |
32 | 32 |
// Andrew Lumsdaine (lums at osl.iu.edu) |
33 | 33 |
|
34 | 34 |
|
35 | 35 |
#ifndef LEMON_BITS_ENABLE_IF_H |
36 | 36 |
#define LEMON_BITS_ENABLE_IF_H |
37 | 37 |
|
38 |
///\file |
|
39 |
///\brief Miscellaneous basic utilities |
|
38 |
//\file |
|
39 |
//\brief Miscellaneous basic utilities |
|
40 | 40 |
|
41 | 41 |
namespace lemon |
42 | 42 |
{ |
43 | 43 |
|
44 |
|
|
44 |
// Basic type for defining "tags". A "YES" condition for \c enable_if. |
|
45 | 45 |
|
46 |
/// Basic type for defining "tags". A "YES" condition for \c enable_if. |
|
47 |
/// |
|
48 |
// |
|
46 |
// Basic type for defining "tags". A "YES" condition for \c enable_if. |
|
47 |
// |
|
48 |
//\sa False |
|
49 | 49 |
struct True { |
50 |
// |
|
50 |
//\e |
|
51 | 51 |
static const bool value = true; |
52 | 52 |
}; |
53 | 53 |
|
54 |
|
|
54 |
// Basic type for defining "tags". A "NO" condition for \c enable_if. |
|
55 | 55 |
|
56 |
/// Basic type for defining "tags". A "NO" condition for \c enable_if. |
|
57 |
/// |
|
58 |
// |
|
56 |
// Basic type for defining "tags". A "NO" condition for \c enable_if. |
|
57 |
// |
|
58 |
//\sa True |
|
59 | 59 |
struct False { |
60 |
// |
|
60 |
//\e |
|
61 | 61 |
static const bool value = false; |
62 | 62 |
}; |
63 | 63 |
|
64 | 64 |
|
65 | 65 |
|
66 | 66 |
template <typename T> |
67 | 67 |
struct Wrap { |
68 | 68 |
const T &value; |
... | ... |
@@ -22,24 +22,24 @@ |
22 | 22 |
#include <lemon/core.h> |
23 | 23 |
|
24 | 24 |
#include <lemon/bits/map_extender.h> |
25 | 25 |
#include <lemon/bits/default_map.h> |
26 | 26 |
|
27 | 27 |
#include <lemon/concept_check.h> |
28 | 28 |
#include <lemon/concepts/maps.h> |
29 | 29 |
|
30 |
///\ingroup graphbits |
|
31 |
///\file |
|
32 |
|
|
30 |
//\ingroup graphbits |
|
31 |
//\file |
|
32 |
//\brief Extenders for the digraph types |
|
33 | 33 |
namespace lemon { |
34 | 34 |
|
35 |
/// \ingroup graphbits |
|
36 |
/// |
|
37 |
// |
|
35 |
// \ingroup graphbits |
|
36 |
// |
|
37 |
// \brief Extender for the Digraphs |
|
38 | 38 |
template <typename Base> |
39 | 39 |
class DigraphExtender : public Base { |
40 | 40 |
public: |
41 | 41 |
|
42 | 42 |
typedef Base Parent; |
43 | 43 |
typedef DigraphExtender Digraph; |
44 | 44 |
|
45 | 45 |
// Base extensions |
... | ... |
@@ -181,40 +181,40 @@ |
181 | 181 |
|
182 | 182 |
InArcIt& operator++() { |
183 | 183 |
_digraph->nextIn(*this); |
184 | 184 |
return *this; |
185 | 185 |
} |
186 | 186 |
|
187 | 187 |
}; |
188 | 188 |
|
189 |
/// \brief Base node of the iterator |
|
190 |
/// |
|
191 |
// |
|
189 |
// \brief Base node of the iterator |
|
190 |
// |
|
191 |
// Returns the base node (i.e. the source in this case) of the iterator |
|
192 | 192 |
Node baseNode(const OutArcIt &arc) const { |
193 | 193 |
return Parent::source(arc); |
194 | 194 |
} |
195 |
/// \brief Running node of the iterator |
|
196 |
/// |
|
197 |
/// Returns the running node (i.e. the target in this case) of the |
|
198 |
/// iterator |
|
195 |
// \brief Running node of the iterator |
|
196 |
// |
|
197 |
// Returns the running node (i.e. the target in this case) of the |
|
198 |
// iterator |
|
199 | 199 |
Node runningNode(const OutArcIt &arc) const { |
200 | 200 |
return Parent::target(arc); |
201 | 201 |
} |
202 | 202 |
|
203 |
/// \brief Base node of the iterator |
|
204 |
/// |
|
205 |
// |
|
203 |
// \brief Base node of the iterator |
|
204 |
// |
|
205 |
// Returns the base node (i.e. the target in this case) of the iterator |
|
206 | 206 |
Node baseNode(const InArcIt &arc) const { |
207 | 207 |
return Parent::target(arc); |
208 | 208 |
} |
209 |
/// \brief Running node of the iterator |
|
210 |
/// |
|
211 |
/// Returns the running node (i.e. the source in this case) of the |
|
212 |
/// iterator |
|
209 |
// \brief Running node of the iterator |
|
210 |
// |
|
211 |
// Returns the running node (i.e. the source in this case) of the |
|
212 |
// iterator |
|
213 | 213 |
Node runningNode(const InArcIt &arc) const { |
214 | 214 |
return Parent::source(arc); |
215 | 215 |
} |
216 | 216 |
|
217 | 217 |
|
218 | 218 |
template <typename _Value> |
219 | 219 |
class NodeMap |
220 | 220 |
: public MapExtender<DefaultMap<Digraph, Node, _Value> > { |
... | ... |
@@ -320,19 +320,19 @@ |
320 | 320 |
|
321 | 321 |
|
322 | 322 |
~DigraphExtender() { |
323 | 323 |
arc_notifier.clear(); |
324 | 324 |
node_notifier.clear(); |
325 | 325 |
} |
326 | 326 |
}; |
327 | 327 |
|
328 |
/// \ingroup _graphbits |
|
329 |
/// |
|
330 |
// |
|
328 |
// \ingroup _graphbits |
|
329 |
// |
|
330 |
// \brief Extender for the Graphs |
|
331 | 331 |
template <typename Base> |
332 | 332 |
class GraphExtender : public Base { |
333 | 333 |
public: |
334 | 334 |
|
335 | 335 |
typedef Base Parent; |
336 | 336 |
typedef GraphExtender Graph; |
337 | 337 |
|
338 | 338 |
typedef True UndirectedTag; |
... | ... |
@@ -550,53 +550,53 @@ |
550 | 550 |
} |
551 | 551 |
|
552 | 552 |
IncEdgeIt& operator++() { |
553 | 553 |
_graph->nextInc(*this, _direction); |
554 | 554 |
return *this; |
555 | 555 |
} |
556 | 556 |
}; |
557 | 557 |
|
558 |
/// \brief Base node of the iterator |
|
559 |
/// |
|
560 |
// |
|
558 |
// \brief Base node of the iterator |
|
559 |
// |
|
560 |
// Returns the base node (ie. the source in this case) of the iterator |
|
561 | 561 |
Node baseNode(const OutArcIt &arc) const { |
562 | 562 |
return Parent::source(static_cast<const Arc&>(arc)); |
563 | 563 |
} |
564 |
/// \brief Running node of the iterator |
|
565 |
/// |
|
566 |
/// Returns the running node (ie. the target in this case) of the |
|
567 |
/// iterator |
|
564 |
// \brief Running node of the iterator |
|
565 |
// |
|
566 |
// Returns the running node (ie. the target in this case) of the |
|
567 |
// iterator |
|
568 | 568 |
Node runningNode(const OutArcIt &arc) const { |
569 | 569 |
return Parent::target(static_cast<const Arc&>(arc)); |
570 | 570 |
} |
571 | 571 |
|
572 |
/// \brief Base node of the iterator |
|
573 |
/// |
|
574 |
// |
|
572 |
// \brief Base node of the iterator |
|
573 |
// |
|
574 |
// Returns the base node (ie. the target in this case) of the iterator |
|
575 | 575 |
Node baseNode(const InArcIt &arc) const { |
576 | 576 |
return Parent::target(static_cast<const Arc&>(arc)); |
577 | 577 |
} |
578 |
/// \brief Running node of the iterator |
|
579 |
/// |
|
580 |
/// Returns the running node (ie. the source in this case) of the |
|
581 |
/// iterator |
|
578 |
// \brief Running node of the iterator |
|
579 |
// |
|
580 |
// Returns the running node (ie. the source in this case) of the |
|
581 |
// iterator |
|
582 | 582 |
Node runningNode(const InArcIt &arc) const { |
583 | 583 |
return Parent::source(static_cast<const Arc&>(arc)); |
584 | 584 |
} |
585 | 585 |
|
586 |
/// Base node of the iterator |
|
587 |
/// |
|
588 |
// |
|
586 |
// Base node of the iterator |
|
587 |
// |
|
588 |
// Returns the base node of the iterator |
|
589 | 589 |
Node baseNode(const IncEdgeIt &edge) const { |
590 | 590 |
return edge._direction ? u(edge) : v(edge); |
591 | 591 |
} |
592 |
/// Running node of the iterator |
|
593 |
/// |
|
594 |
// |
|
592 |
// Running node of the iterator |
|
593 |
// |
|
594 |
// Returns the running node of the iterator |
|
595 | 595 |
Node runningNode(const IncEdgeIt &edge) const { |
596 | 596 |
return edge._direction ? v(edge) : u(edge); |
597 | 597 |
} |
598 | 598 |
|
599 | 599 |
// Mappable extension |
600 | 600 |
|
601 | 601 |
template <typename _Value> |
602 | 602 |
class NodeMap |
... | ... |
@@ -21,24 +21,24 @@ |
21 | 21 |
|
22 | 22 |
#include <iterator> |
23 | 23 |
|
24 | 24 |
#include <lemon/bits/traits.h> |
25 | 25 |
|
26 | 26 |
#include <lemon/concept_check.h> |
27 | 27 |
#include <lemon/concepts/maps.h> |
28 | 28 |
|
29 |
///\file |
|
30 |
///\brief Extenders for iterable maps. |
|
29 |
//\file |
|
30 |
//\brief Extenders for iterable maps. |
|
31 | 31 |
|
32 | 32 |
namespace lemon { |
33 | 33 |
|
34 |
/// \ingroup graphbits |
|
35 |
/// |
|
36 |
// |
|
34 |
// \ingroup graphbits |
|
35 |
// |
|
36 |
// \brief Extender for maps |
|
37 | 37 |
template <typename _Map> |
38 | 38 |
class MapExtender : public _Map { |
39 | 39 |
public: |
40 | 40 |
|
41 | 41 |
typedef _Map Parent; |
42 | 42 |
typedef MapExtender Map; |
43 | 43 |
|
44 | 44 |
|
... | ... |
@@ -166,19 +166,19 @@ |
166 | 166 |
} |
167 | 167 |
|
168 | 168 |
protected: |
169 | 169 |
const Map& map; |
170 | 170 |
|
171 | 171 |
}; |
172 | 172 |
}; |
173 | 173 |
|
174 |
/// \ingroup graphbits |
|
175 |
/// |
|
176 |
// |
|
174 |
// \ingroup graphbits |
|
175 |
// |
|
176 |
// \brief Extender for maps which use a subset of the items. |
|
177 | 177 |
template <typename _Graph, typename _Map> |
178 | 178 |
class SubMapExtender : public _Map { |
179 | 179 |
public: |
180 | 180 |
|
181 | 181 |
typedef _Map Parent; |
182 | 182 |
typedef SubMapExtender Map; |
183 | 183 |
|
184 | 184 |
typedef _Graph Graph; |
... | ... |
@@ -14,19 +14,19 @@ |
14 | 14 |
* express or implied, and with no claim as to its suitability for any |
15 | 15 |
* purpose. |
16 | 16 |
* |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_BITS_TRAITS_H |
20 | 20 |
#define LEMON_BITS_TRAITS_H |
21 | 21 |
|
22 |
///\file |
|
23 |
///\brief Traits for graphs and maps |
|
24 |
// |
|
22 |
//\file |
|
23 |
//\brief Traits for graphs and maps |
|
24 |
// |
|
25 | 25 |
|
26 | 26 |
#include <lemon/bits/enable_if.h> |
27 | 27 |
|
28 | 28 |
namespace lemon { |
29 | 29 |
|
30 | 30 |
struct InvalidType {}; |
31 | 31 |
|
32 | 32 |
template <typename _Graph, typename _Item> |
... | ... |
@@ -23,213 +23,213 @@ |
23 | 23 |
#include <algorithm> |
24 | 24 |
|
25 | 25 |
#include <lemon/core.h> |
26 | 26 |
#include <lemon/bits/alteration_notifier.h> |
27 | 27 |
|
28 | 28 |
#include <lemon/concept_check.h> |
29 | 29 |
#include <lemon/concepts/maps.h> |
30 | 30 |
|
31 |
///\ingroup graphbits |
|
32 |
/// |
|
33 |
///\file |
|
34 |
///\brief Vector based graph maps. |
|
31 |
//\ingroup graphbits |
|
32 |
// |
|
33 |
//\file |
|
34 |
//\brief Vector based graph maps. |
|
35 | 35 |
namespace lemon { |
36 | 36 |
|
37 |
/// \ingroup graphbits |
|
38 |
/// |
|
39 |
/// \brief Graph map based on the std::vector storage. |
|
40 |
/// |
|
41 |
/// The VectorMap template class is graph map structure what |
|
42 |
/// automatically updates the map when a key is added to or erased from |
|
43 |
/// the map. This map type uses the std::vector to store the values. |
|
44 |
/// |
|
45 |
/// \tparam _Graph The graph this map is attached to. |
|
46 |
/// \tparam _Item The item type of the graph items. |
|
47 |
// |
|
37 |
// \ingroup graphbits |
|
38 |
// |
|
39 |
// \brief Graph map based on the std::vector storage. |
|
40 |
// |
|
41 |
// The VectorMap template class is graph map structure what |
|
42 |
// automatically updates the map when a key is added to or erased from |
|
43 |
// the map. This map type uses the std::vector to store the values. |
|
44 |
// |
|
45 |
// \tparam _Graph The graph this map is attached to. |
|
46 |
// \tparam _Item The item type of the graph items. |
|
47 |
// \tparam _Value The value type of the map. |
|
48 | 48 |
template <typename _Graph, typename _Item, typename _Value> |
49 | 49 |
class VectorMap |
50 | 50 |
: public ItemSetTraits<_Graph, _Item>::ItemNotifier::ObserverBase { |
51 | 51 |
private: |
52 | 52 |
|
53 |
|
|
53 |
// The container type of the map. |
|
54 | 54 |
typedef std::vector<_Value> Container; |
55 | 55 |
|
56 | 56 |
public: |
57 | 57 |
|
58 |
|
|
58 |
// The graph type of the map. |
|
59 | 59 |
typedef _Graph Graph; |
60 |
|
|
60 |
// The item type of the map. |
|
61 | 61 |
typedef _Item Item; |
62 |
|
|
62 |
// The reference map tag. |
|
63 | 63 |
typedef True ReferenceMapTag; |
64 | 64 |
|
65 |
|
|
65 |
// The key type of the map. |
|
66 | 66 |
typedef _Item Key; |
67 |
|
|
67 |
// The value type of the map. |
|
68 | 68 |
typedef _Value Value; |
69 | 69 |
|
70 |
|
|
70 |
// The notifier type. |
|
71 | 71 |
typedef typename ItemSetTraits<_Graph, _Item>::ItemNotifier Notifier; |
72 | 72 |
|
73 |
|
|
73 |
// The map type. |
|
74 | 74 |
typedef VectorMap Map; |
75 |
|
|
75 |
// The base class of the map. |
|
76 | 76 |
typedef typename Notifier::ObserverBase Parent; |
77 | 77 |
|
78 |
|
|
78 |
// The reference type of the map; |
|
79 | 79 |
typedef typename Container::reference Reference; |
80 |
|
|
80 |
// The const reference type of the map; |
|
81 | 81 |
typedef typename Container::const_reference ConstReference; |
82 | 82 |
|
83 | 83 |
|
84 |
/// \brief Constructor to attach the new map into the notifier. |
|
85 |
/// |
|
86 |
/// It constructs a map and attachs it into the notifier. |
|
87 |
/// It adds all the items of the graph to the map. |
|
84 |
// \brief Constructor to attach the new map into the notifier. |
|
85 |
// |
|
86 |
// It constructs a map and attachs it into the notifier. |
|
87 |
// It adds all the items of the graph to the map. |
|
88 | 88 |
VectorMap(const Graph& graph) { |
89 | 89 |
Parent::attach(graph.notifier(Item())); |
90 | 90 |
container.resize(Parent::notifier()->maxId() + 1); |
91 | 91 |
} |
92 | 92 |
|
93 |
/// \brief Constructor uses given value to initialize the map. |
|
94 |
/// |
|
95 |
/// It constructs a map uses a given value to initialize the map. |
|
96 |
/// It adds all the items of the graph to the map. |
|
93 |
// \brief Constructor uses given value to initialize the map. |
|
94 |
// |
|
95 |
// It constructs a map uses a given value to initialize the map. |
|
96 |
// It adds all the items of the graph to the map. |
|
97 | 97 |
VectorMap(const Graph& graph, const Value& value) { |
98 | 98 |
Parent::attach(graph.notifier(Item())); |
99 | 99 |
container.resize(Parent::notifier()->maxId() + 1, value); |
100 | 100 |
} |
101 | 101 |
|
102 | 102 |
private: |
103 |
/// \brief Copy constructor |
|
104 |
/// |
|
105 |
// |
|
103 |
// \brief Copy constructor |
|
104 |
// |
|
105 |
// Copy constructor. |
|
106 | 106 |
VectorMap(const VectorMap& _copy) : Parent() { |
107 | 107 |
if (_copy.attached()) { |
108 | 108 |
Parent::attach(*_copy.notifier()); |
109 | 109 |
container = _copy.container; |
110 | 110 |
} |
111 | 111 |
} |
112 | 112 |
|
113 |
/// \brief Assign operator. |
|
114 |
/// |
|
115 |
/// This operator assigns for each item in the map the |
|
116 |
/// value mapped to the same item in the copied map. |
|
117 |
/// The parameter map should be indiced with the same |
|
118 |
/// itemset because this assign operator does not change |
|
119 |
// |
|
113 |
// \brief Assign operator. |
|
114 |
// |
|
115 |
// This operator assigns for each item in the map the |
|
116 |
// value mapped to the same item in the copied map. |
|
117 |
// The parameter map should be indiced with the same |
|
118 |
// itemset because this assign operator does not change |
|
119 |
// the container of the map. |
|
120 | 120 |
VectorMap& operator=(const VectorMap& cmap) { |
121 | 121 |
return operator=<VectorMap>(cmap); |
122 | 122 |
} |
123 | 123 |
|
124 | 124 |
|
125 |
/// \brief Template assign operator. |
|
126 |
/// |
|
127 |
/// The given parameter should be conform to the ReadMap |
|
128 |
/// concecpt and could be indiced by the current item set of |
|
129 |
/// the NodeMap. In this case the value for each item |
|
130 |
/// is assigned by the value of the given ReadMap. |
|
125 |
// \brief Template assign operator. |
|
126 |
// |
|
127 |
// The given parameter should be conform to the ReadMap |
|
128 |
// concecpt and could be indiced by the current item set of |
|
129 |
// the NodeMap. In this case the value for each item |
|
130 |
// is assigned by the value of the given ReadMap. |
|
131 | 131 |
template <typename CMap> |
132 | 132 |
VectorMap& operator=(const CMap& cmap) { |
133 | 133 |
checkConcept<concepts::ReadMap<Key, _Value>, CMap>(); |
134 | 134 |
const typename Parent::Notifier* nf = Parent::notifier(); |
135 | 135 |
Item it; |
136 | 136 |
for (nf->first(it); it != INVALID; nf->next(it)) { |
137 | 137 |
set(it, cmap[it]); |
138 | 138 |
} |
139 | 139 |
return *this; |
140 | 140 |
} |
141 | 141 |
|
142 | 142 |
public: |
143 | 143 |
|
144 |
/// \brief The subcript operator. |
|
145 |
/// |
|
146 |
/// The subscript operator. The map can be subscripted by the |
|
147 |
/// actual items of the graph. |
|
144 |
// \brief The subcript operator. |
|
145 |
// |
|
146 |
// The subscript operator. The map can be subscripted by the |
|
147 |
// actual items of the graph. |
|
148 | 148 |
Reference operator[](const Key& key) { |
149 | 149 |
return container[Parent::notifier()->id(key)]; |
150 | 150 |
} |
151 | 151 |
|
152 |
/// \brief The const subcript operator. |
|
153 |
/// |
|
154 |
/// The const subscript operator. The map can be subscripted by the |
|
155 |
/// actual items of the graph. |
|
152 |
// \brief The const subcript operator. |
|
153 |
// |
|
154 |
// The const subscript operator. The map can be subscripted by the |
|
155 |
// actual items of the graph. |
|
156 | 156 |
ConstReference operator[](const Key& key) const { |
157 | 157 |
return container[Parent::notifier()->id(key)]; |
158 | 158 |
} |
159 | 159 |
|
160 | 160 |
|
161 |
/// \brief The setter function of the map. |
|
162 |
/// |
|
163 |
// |
|
161 |
// \brief The setter function of the map. |
|
162 |
// |
|
163 |
// It the same as operator[](key) = value expression. |
|
164 | 164 |
void set(const Key& key, const Value& value) { |
165 | 165 |
(*this)[key] = value; |
166 | 166 |
} |
167 | 167 |
|
168 | 168 |
protected: |
169 | 169 |
|
170 |
/// \brief Adds a new key to the map. |
|
171 |
/// |
|
172 |
/// It adds a new key to the map. It called by the observer notifier |
|
173 |
/// and it overrides the add() member function of the observer base. |
|
170 |
// \brief Adds a new key to the map. |
|
171 |
// |
|
172 |
// It adds a new key to the map. It called by the observer notifier |
|
173 |
// and it overrides the add() member function of the observer base. |
|
174 | 174 |
virtual void add(const Key& key) { |
175 | 175 |
int id = Parent::notifier()->id(key); |
176 | 176 |
if (id >= int(container.size())) { |
177 | 177 |
container.resize(id + 1); |
178 | 178 |
} |
179 | 179 |
} |
180 | 180 |
|
181 |
/// \brief Adds more new keys to the map. |
|
182 |
/// |
|
183 |
/// It adds more new keys to the map. It called by the observer notifier |
|
184 |
/// and it overrides the add() member function of the observer base. |
|
181 |
// \brief Adds more new keys to the map. |
|
182 |
// |
|
183 |
// It adds more new keys to the map. It called by the observer notifier |
|
184 |
// and it overrides the add() member function of the observer base. |
|
185 | 185 |
virtual void add(const std::vector<Key>& keys) { |
186 | 186 |
int max = container.size() - 1; |
187 | 187 |
for (int i = 0; i < int(keys.size()); ++i) { |
188 | 188 |
int id = Parent::notifier()->id(keys[i]); |
189 | 189 |
if (id >= max) { |
190 | 190 |
max = id; |
191 | 191 |
} |
192 | 192 |
} |
193 | 193 |
container.resize(max + 1); |
194 | 194 |
} |
195 | 195 |
|
196 |
/// \brief Erase a key from the map. |
|
197 |
/// |
|
198 |
/// Erase a key from the map. It called by the observer notifier |
|
199 |
/// and it overrides the erase() member function of the observer base. |
|
196 |
// \brief Erase a key from the map. |
|
197 |
// |
|
198 |
// Erase a key from the map. It called by the observer notifier |
|
199 |
// and it overrides the erase() member function of the observer base. |
|
200 | 200 |
virtual void erase(const Key& key) { |
201 | 201 |
container[Parent::notifier()->id(key)] = Value(); |
202 | 202 |
} |
203 | 203 |
|
204 |
/// \brief Erase more keys from the map. |
|
205 |
/// |
|
206 |
/// Erase more keys from the map. It called by the observer notifier |
|
207 |
/// and it overrides the erase() member function of the observer base. |
|
204 |
// \brief Erase more keys from the map. |
|
205 |
// |
|
206 |
// Erase more keys from the map. It called by the observer notifier |
|
207 |
// and it overrides the erase() member function of the observer base. |
|
208 | 208 |
virtual void erase(const std::vector<Key>& keys) { |
209 | 209 |
for (int i = 0; i < int(keys.size()); ++i) { |
210 | 210 |
container[Parent::notifier()->id(keys[i])] = Value(); |
211 | 211 |
} |
212 | 212 |
} |
213 | 213 |
|
214 |
/// \brief Buildes the map. |
|
215 |
/// |
|
216 |
/// It buildes the map. It called by the observer notifier |
|
217 |
/// and it overrides the build() member function of the observer base. |
|
214 |
// \brief Buildes the map. |
|
215 |
// |
|
216 |
// It buildes the map. It called by the observer notifier |
|
217 |
// and it overrides the build() member function of the observer base. |
|
218 | 218 |
virtual void build() { |
219 | 219 |
int size = Parent::notifier()->maxId() + 1; |
220 | 220 |
container.reserve(size); |
221 | 221 |
container.resize(size); |
222 | 222 |
} |
223 | 223 |
|
224 |
/// \brief Clear the map. |
|
225 |
/// |
|
226 |
/// It erase all items from the map. It called by the observer notifier |
|
227 |
/// and it overrides the clear() member function of the observer base. |
|
224 |
// \brief Clear the map. |
|
225 |
// |
|
226 |
// It erase all items from the map. It called by the observer notifier |
|
227 |
// and it overrides the clear() member function of the observer base. |
|
228 | 228 |
virtual void clear() { |
229 | 229 |
container.clear(); |
230 | 230 |
} |
231 | 231 |
|
232 | 232 |
private: |
233 | 233 |
|
234 | 234 |
Container container; |
235 | 235 |
... | ... |
@@ -87,17 +87,17 @@ |
87 | 87 |
extern const Color DARK_BLUE; |
88 | 88 |
/// Dark yellow color constant |
89 | 89 |
extern const Color DARK_YELLOW; |
90 | 90 |
/// Dark magenta color constant |
91 | 91 |
extern const Color DARK_MAGENTA; |
92 | 92 |
/// Dark cyan color constant |
93 | 93 |
extern const Color DARK_CYAN; |
94 | 94 |
|
95 |
///Map <tt>int</tt>s to different |
|
95 |
///Map <tt>int</tt>s to different <tt>Color</tt>s |
|
96 | 96 |
|
97 | 97 |
///This map assigns one of the predefined \ref Color "Color"s to |
98 | 98 |
///each <tt>int</tt>. It is possible to change the colors as well as |
99 | 99 |
///their number. The integer range is cyclically mapped to the |
100 | 100 |
///provided set of colors. |
101 | 101 |
/// |
102 | 102 |
///This is a true \ref concepts::ReferenceMap "reference map", so |
103 | 103 |
///you can also change the actual colors. |
... | ... |
@@ -977,17 +977,17 @@ |
977 | 977 |
|
978 | 978 |
}; |
979 | 979 |
|
980 | 980 |
}; |
981 | 981 |
|
982 | 982 |
/// \brief Class describing the concept of graph maps |
983 | 983 |
/// |
984 | 984 |
/// This class describes the common interface of the graph maps |
985 |
/// (NodeMap, ArcMap), that is |
|
985 |
/// (NodeMap, ArcMap), that is maps that can be used to |
|
986 | 986 |
/// associate data to graph descriptors (nodes or arcs). |
987 | 987 |
template <typename _Graph, typename _Item, typename _Value> |
988 | 988 |
class GraphMap : public ReadWriteMap<_Item, _Value> { |
989 | 989 |
public: |
990 | 990 |
|
991 | 991 |
typedef ReadWriteMap<_Item, _Value> Parent; |
992 | 992 |
|
993 | 993 |
/// The graph type of the map. |
... | ... |
@@ -17,25 +17,25 @@ |
17 | 17 |
*/ |
18 | 18 |
|
19 | 19 |
#ifndef LEMON_CONCEPT_MAPS_H |
20 | 20 |
#define LEMON_CONCEPT_MAPS_H |
21 | 21 |
|
22 | 22 |
#include <lemon/core.h> |
23 | 23 |
#include <lemon/concept_check.h> |
24 | 24 |
|
25 |
///\ingroup |
|
25 |
///\ingroup map_concepts |
|
26 | 26 |
///\file |
27 | 27 |
///\brief The concept of maps. |
28 | 28 |
|
29 | 29 |
namespace lemon { |
30 | 30 |
|
31 | 31 |
namespace concepts { |
32 | 32 |
|
33 |
/// \addtogroup |
|
33 |
/// \addtogroup map_concepts |
|
34 | 34 |
/// @{ |
35 | 35 |
|
36 | 36 |
/// Readable map concept |
37 | 37 |
|
38 | 38 |
/// Readable map concept. |
39 | 39 |
/// |
40 | 40 |
template<typename K, typename T> |
41 | 41 |
class ReadMap |
... | ... |
@@ -53,17 +53,17 @@ |
53 | 53 |
const Invalid INVALID = Invalid(); |
54 | 54 |
#else |
55 | 55 |
extern const Invalid INVALID; |
56 | 56 |
#endif |
57 | 57 |
|
58 | 58 |
/// \addtogroup gutils |
59 | 59 |
/// @{ |
60 | 60 |
|
61 |
///Create |
|
61 |
///Create convenience typedefs for the digraph types and iterators |
|
62 | 62 |
|
63 | 63 |
///This \c \#define creates convenient type definitions for the following |
64 | 64 |
///types of \c Digraph: \c Node, \c NodeIt, \c Arc, \c ArcIt, \c InArcIt, |
65 | 65 |
///\c OutArcIt, \c BoolNodeMap, \c IntNodeMap, \c DoubleNodeMap, |
66 | 66 |
///\c BoolArcMap, \c IntArcMap, \c DoubleArcMap. |
67 | 67 |
/// |
68 | 68 |
///\note If the graph type is a dependent type, ie. the graph type depend |
69 | 69 |
///on a template parameter, then use \c TEMPLATE_DIGRAPH_TYPEDEFS() |
... | ... |
@@ -75,19 +75,19 @@ |
75 | 75 |
typedef Digraph::ArcIt ArcIt; \ |
76 | 76 |
typedef Digraph::InArcIt InArcIt; \ |
77 | 77 |
typedef Digraph::OutArcIt OutArcIt; \ |
78 | 78 |
typedef Digraph::NodeMap<bool> BoolNodeMap; \ |
79 | 79 |
typedef Digraph::NodeMap<int> IntNodeMap; \ |
80 | 80 |
typedef Digraph::NodeMap<double> DoubleNodeMap; \ |
81 | 81 |
typedef Digraph::ArcMap<bool> BoolArcMap; \ |
82 | 82 |
typedef Digraph::ArcMap<int> IntArcMap; \ |
83 |
typedef Digraph::ArcMap<double> DoubleArcMap |
|
83 |
typedef Digraph::ArcMap<double> DoubleArcMap |
|
84 | 84 |
|
85 |
///Create |
|
85 |
///Create convenience typedefs for the digraph types and iterators |
|
86 | 86 |
|
87 | 87 |
///\see DIGRAPH_TYPEDEFS |
88 | 88 |
/// |
89 | 89 |
///\note Use this macro, if the graph type is a dependent type, |
90 | 90 |
///ie. the graph type depend on a template parameter. |
91 | 91 |
#define TEMPLATE_DIGRAPH_TYPEDEFS(Digraph) \ |
92 | 92 |
typedef typename Digraph::Node Node; \ |
93 | 93 |
typedef typename Digraph::NodeIt NodeIt; \ |
... | ... |
@@ -95,51 +95,51 @@ |
95 | 95 |
typedef typename Digraph::ArcIt ArcIt; \ |
96 | 96 |
typedef typename Digraph::InArcIt InArcIt; \ |
97 | 97 |
typedef typename Digraph::OutArcIt OutArcIt; \ |
98 | 98 |
typedef typename Digraph::template NodeMap<bool> BoolNodeMap; \ |
99 | 99 |
typedef typename Digraph::template NodeMap<int> IntNodeMap; \ |
100 | 100 |
typedef typename Digraph::template NodeMap<double> DoubleNodeMap; \ |
101 | 101 |
typedef typename Digraph::template ArcMap<bool> BoolArcMap; \ |
102 | 102 |
typedef typename Digraph::template ArcMap<int> IntArcMap; \ |
103 |
typedef typename Digraph::template ArcMap<double> DoubleArcMap |
|
103 |
typedef typename Digraph::template ArcMap<double> DoubleArcMap |
|
104 | 104 |
|
105 |
///Create |
|
105 |
///Create convenience typedefs for the graph types and iterators |
|
106 | 106 |
|
107 | 107 |
///This \c \#define creates the same convenient type definitions as defined |
108 | 108 |
///by \ref DIGRAPH_TYPEDEFS(Graph) and six more, namely it creates |
109 | 109 |
///\c Edge, \c EdgeIt, \c IncEdgeIt, \c BoolEdgeMap, \c IntEdgeMap, |
110 | 110 |
///\c DoubleEdgeMap. |
111 | 111 |
/// |
112 | 112 |
///\note If the graph type is a dependent type, ie. the graph type depend |
113 | 113 |
///on a template parameter, then use \c TEMPLATE_GRAPH_TYPEDEFS() |
114 | 114 |
///macro. |
115 | 115 |
#define GRAPH_TYPEDEFS(Graph) \ |
116 | 116 |
DIGRAPH_TYPEDEFS(Graph); \ |
117 | 117 |
typedef Graph::Edge Edge; \ |
118 | 118 |
typedef Graph::EdgeIt EdgeIt; \ |
119 | 119 |
typedef Graph::IncEdgeIt IncEdgeIt; \ |
120 | 120 |
typedef Graph::EdgeMap<bool> BoolEdgeMap; \ |
121 | 121 |
typedef Graph::EdgeMap<int> IntEdgeMap; \ |
122 |
typedef Graph::EdgeMap<double> DoubleEdgeMap |
|
122 |
typedef Graph::EdgeMap<double> DoubleEdgeMap |
|
123 | 123 |
|
124 |
///Create |
|
124 |
///Create convenience typedefs for the graph types and iterators |
|
125 | 125 |
|
126 | 126 |
///\see GRAPH_TYPEDEFS |
127 | 127 |
/// |
128 | 128 |
///\note Use this macro, if the graph type is a dependent type, |
129 | 129 |
///ie. the graph type depend on a template parameter. |
130 | 130 |
#define TEMPLATE_GRAPH_TYPEDEFS(Graph) \ |
131 | 131 |
TEMPLATE_DIGRAPH_TYPEDEFS(Graph); \ |
132 | 132 |
typedef typename Graph::Edge Edge; \ |
133 | 133 |
typedef typename Graph::EdgeIt EdgeIt; \ |
134 | 134 |
typedef typename Graph::IncEdgeIt IncEdgeIt; \ |
135 | 135 |
typedef typename Graph::template EdgeMap<bool> BoolEdgeMap; \ |
136 | 136 |
typedef typename Graph::template EdgeMap<int> IntEdgeMap; \ |
137 |
typedef typename Graph::template EdgeMap<double> DoubleEdgeMap |
|
137 |
typedef typename Graph::template EdgeMap<double> DoubleEdgeMap |
|
138 | 138 |
|
139 | 139 |
/// \brief Function to count the items in a graph. |
140 | 140 |
/// |
141 | 141 |
/// This function counts the items (nodes, arcs etc.) in a graph. |
142 | 142 |
/// The complexity of the function is linear because |
143 | 143 |
/// it iterates on all of the items. |
144 | 144 |
template <typename Graph, typename Item> |
145 | 145 |
inline int countItems(const Graph& g) { |
... | ... |
@@ -1549,17 +1549,17 @@ |
1549 | 1549 |
///Finding the arcs take at most <em>O</em>(log<em>d</em>) |
1550 | 1550 |
///amortized time, specifically, the time complexity of the lookups |
1551 | 1551 |
///is equal to the optimal search tree implementation for the |
1552 | 1552 |
///current query distribution in a constant factor. |
1553 | 1553 |
/// |
1554 | 1554 |
///\note This is a dynamic data structure, therefore the data |
1555 | 1555 |
///structure is updated after each graph alteration. Thus although |
1556 | 1556 |
///this data structure is theoretically faster than \ref ArcLookUp |
1557 |
///and \ref |
|
1557 |
///and \ref AllArcLookUp, it often provides worse performance than |
|
1558 | 1558 |
///them. |
1559 | 1559 |
Arc operator()(Node s, Node t, Arc p = INVALID) const { |
1560 | 1560 |
if (p == INVALID) { |
1561 | 1561 |
Arc a = _head[s]; |
1562 | 1562 |
if (a == INVALID) return INVALID; |
1563 | 1563 |
Arc r = INVALID; |
1564 | 1564 |
while (true) { |
1565 | 1565 |
if (_g.target(a) < t) { |
... | ... |
@@ -1694,18 +1694,18 @@ |
1694 | 1694 |
///out-degree of the digraph. |
1695 | 1695 |
void refresh() |
1696 | 1696 |
{ |
1697 | 1697 |
for(NodeIt n(_g);n!=INVALID;++n) refresh(n); |
1698 | 1698 |
} |
1699 | 1699 |
|
1700 | 1700 |
///Find an arc between two nodes. |
1701 | 1701 |
|
1702 |
///Find an arc between two nodes in time <em>O</em>(log<em>d</em>), where |
|
1703 |
///<em>d</em> is the number of outgoing arcs of \c s. |
|
1702 |
///Find an arc between two nodes in time <em>O</em>(log<em>d</em>), |
|
1703 |
///where <em>d</em> is the number of outgoing arcs of \c s. |
|
1704 | 1704 |
///\param s The source node. |
1705 | 1705 |
///\param t The target node. |
1706 | 1706 |
///\return An arc from \c s to \c t if there exists, |
1707 | 1707 |
///\ref INVALID otherwise. |
1708 | 1708 |
/// |
1709 | 1709 |
///\warning If you change the digraph, refresh() must be called before using |
1710 | 1710 |
///this operator. If you change the outgoing arcs of |
1711 | 1711 |
///a single node \c n, then \ref refresh(Node) "refresh(n)" is enough. |
... | ... |
@@ -1812,18 +1812,18 @@ |
1812 | 1812 |
///following way. |
1813 | 1813 |
///\code |
1814 | 1814 |
///AllArcLookUp<ListDigraph> ae(g); |
1815 | 1815 |
///... |
1816 | 1816 |
///int n = 0; |
1817 | 1817 |
///for(Arc a = ae(u,v); a != INVALID; a=ae(u,v,a)) n++; |
1818 | 1818 |
///\endcode |
1819 | 1819 |
/// |
1820 |
///Finding the first arc take <em>O</em>(log<em>d</em>) time, where |
|
1821 |
///<em>d</em> is the number of outgoing arcs of \c s. Then, the |
|
1820 |
///Finding the first arc take <em>O</em>(log<em>d</em>) time, |
|
1821 |
///where <em>d</em> is the number of outgoing arcs of \c s. Then the |
|
1822 | 1822 |
///consecutive arcs are found in constant time. |
1823 | 1823 |
/// |
1824 | 1824 |
///\warning If you change the digraph, refresh() must be called before using |
1825 | 1825 |
///this operator. If you change the outgoing arcs of |
1826 | 1826 |
///a single node \c n, then \ref refresh(Node) "refresh(n)" is enough. |
1827 | 1827 |
/// |
1828 | 1828 |
#ifdef DOXYGEN |
1829 | 1829 |
Arc operator()(Node s, Node t, Arc prev=INVALID) const {} |
... | ... |
@@ -45,70 +45,70 @@ |
45 | 45 |
|
46 | 46 |
///\brief The type of the map that stores the predecessor |
47 | 47 |
///arcs of the %DFS paths. |
48 | 48 |
/// |
49 | 49 |
///The type of the map that stores the predecessor |
50 | 50 |
///arcs of the %DFS paths. |
51 | 51 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
52 | 52 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
53 |
///Instantiates a |
|
53 |
///Instantiates a PredMap. |
|
54 | 54 |
|
55 |
///This function instantiates a |
|
55 |
///This function instantiates a PredMap. |
|
56 | 56 |
///\param g is the digraph, to which we would like to define the |
57 |
/// |
|
57 |
///PredMap. |
|
58 | 58 |
static PredMap *createPredMap(const Digraph &g) |
59 | 59 |
{ |
60 | 60 |
return new PredMap(g); |
61 | 61 |
} |
62 | 62 |
|
63 | 63 |
///The type of the map that indicates which nodes are processed. |
64 | 64 |
|
65 | 65 |
///The type of the map that indicates which nodes are processed. |
66 | 66 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
67 | 67 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
68 |
///Instantiates a |
|
68 |
///Instantiates a ProcessedMap. |
|
69 | 69 |
|
70 |
///This function instantiates a |
|
70 |
///This function instantiates a ProcessedMap. |
|
71 | 71 |
///\param g is the digraph, to which |
72 |
///we would like to define the |
|
72 |
///we would like to define the ProcessedMap |
|
73 | 73 |
#ifdef DOXYGEN |
74 | 74 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
75 | 75 |
#else |
76 | 76 |
static ProcessedMap *createProcessedMap(const Digraph &) |
77 | 77 |
#endif |
78 | 78 |
{ |
79 | 79 |
return new ProcessedMap(); |
80 | 80 |
} |
81 | 81 |
|
82 | 82 |
///The type of the map that indicates which nodes are reached. |
83 | 83 |
|
84 | 84 |
///The type of the map that indicates which nodes are reached. |
85 | 85 |
///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
86 | 86 |
typedef typename Digraph::template NodeMap<bool> ReachedMap; |
87 |
///Instantiates a |
|
87 |
///Instantiates a ReachedMap. |
|
88 | 88 |
|
89 |
///This function instantiates a |
|
89 |
///This function instantiates a ReachedMap. |
|
90 | 90 |
///\param g is the digraph, to which |
91 |
///we would like to define the |
|
91 |
///we would like to define the ReachedMap. |
|
92 | 92 |
static ReachedMap *createReachedMap(const Digraph &g) |
93 | 93 |
{ |
94 | 94 |
return new ReachedMap(g); |
95 | 95 |
} |
96 | 96 |
|
97 | 97 |
///The type of the map that stores the distances of the nodes. |
98 | 98 |
|
99 | 99 |
///The type of the map that stores the distances of the nodes. |
100 | 100 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
101 | 101 |
typedef typename Digraph::template NodeMap<int> DistMap; |
102 |
///Instantiates a |
|
102 |
///Instantiates a DistMap. |
|
103 | 103 |
|
104 |
///This function instantiates a |
|
104 |
///This function instantiates a DistMap. |
|
105 | 105 |
///\param g is the digraph, to which we would like to define the |
106 |
/// |
|
106 |
///DistMap. |
|
107 | 107 |
static DistMap *createDistMap(const Digraph &g) |
108 | 108 |
{ |
109 | 109 |
return new DistMap(g); |
110 | 110 |
} |
111 | 111 |
}; |
112 | 112 |
|
113 | 113 |
///%DFS algorithm class. |
114 | 114 |
|
... | ... |
@@ -222,94 +222,94 @@ |
222 | 222 |
typedef T PredMap; |
223 | 223 |
static PredMap *createPredMap(const Digraph &) |
224 | 224 |
{ |
225 | 225 |
LEMON_ASSERT(false, "PredMap is not initialized"); |
226 | 226 |
return 0; // ignore warnings |
227 | 227 |
} |
228 | 228 |
}; |
229 | 229 |
///\brief \ref named-templ-param "Named parameter" for setting |
230 |
/// |
|
230 |
///PredMap type. |
|
231 | 231 |
/// |
232 | 232 |
///\ref named-templ-param "Named parameter" for setting |
233 |
/// |
|
233 |
///PredMap type. |
|
234 | 234 |
template <class T> |
235 | 235 |
struct SetPredMap : public Dfs<Digraph, SetPredMapTraits<T> > { |
236 | 236 |
typedef Dfs<Digraph, SetPredMapTraits<T> > Create; |
237 | 237 |
}; |
238 | 238 |
|
239 | 239 |
template <class T> |
240 | 240 |
struct SetDistMapTraits : public Traits { |
241 | 241 |
typedef T DistMap; |
242 | 242 |
static DistMap *createDistMap(const Digraph &) |
243 | 243 |
{ |
244 | 244 |
LEMON_ASSERT(false, "DistMap is not initialized"); |
245 | 245 |
return 0; // ignore warnings |
246 | 246 |
} |
247 | 247 |
}; |
248 | 248 |
///\brief \ref named-templ-param "Named parameter" for setting |
249 |
/// |
|
249 |
///DistMap type. |
|
250 | 250 |
/// |
251 | 251 |
///\ref named-templ-param "Named parameter" for setting |
252 |
/// |
|
252 |
///DistMap type. |
|
253 | 253 |
template <class T> |
254 | 254 |
struct SetDistMap : public Dfs< Digraph, SetDistMapTraits<T> > { |
255 | 255 |
typedef Dfs<Digraph, SetDistMapTraits<T> > Create; |
256 | 256 |
}; |
257 | 257 |
|
258 | 258 |
template <class T> |
259 | 259 |
struct SetReachedMapTraits : public Traits { |
260 | 260 |
typedef T ReachedMap; |
261 | 261 |
static ReachedMap *createReachedMap(const Digraph &) |
262 | 262 |
{ |
263 | 263 |
LEMON_ASSERT(false, "ReachedMap is not initialized"); |
264 | 264 |
return 0; // ignore warnings |
265 | 265 |
} |
266 | 266 |
}; |
267 | 267 |
///\brief \ref named-templ-param "Named parameter" for setting |
268 |
/// |
|
268 |
///ReachedMap type. |
|
269 | 269 |
/// |
270 | 270 |
///\ref named-templ-param "Named parameter" for setting |
271 |
/// |
|
271 |
///ReachedMap type. |
|
272 | 272 |
template <class T> |
273 | 273 |
struct SetReachedMap : public Dfs< Digraph, SetReachedMapTraits<T> > { |
274 | 274 |
typedef Dfs< Digraph, SetReachedMapTraits<T> > Create; |
275 | 275 |
}; |
276 | 276 |
|
277 | 277 |
template <class T> |
278 | 278 |
struct SetProcessedMapTraits : public Traits { |
279 | 279 |
typedef T ProcessedMap; |
280 | 280 |
static ProcessedMap *createProcessedMap(const Digraph &) |
281 | 281 |
{ |
282 | 282 |
LEMON_ASSERT(false, "ProcessedMap is not initialized"); |
283 | 283 |
return 0; // ignore warnings |
284 | 284 |
} |
285 | 285 |
}; |
286 | 286 |
///\brief \ref named-templ-param "Named parameter" for setting |
287 |
/// |
|
287 |
///ProcessedMap type. |
|
288 | 288 |
/// |
289 | 289 |
///\ref named-templ-param "Named parameter" for setting |
290 |
/// |
|
290 |
///ProcessedMap type. |
|
291 | 291 |
template <class T> |
292 | 292 |
struct SetProcessedMap : public Dfs< Digraph, SetProcessedMapTraits<T> > { |
293 | 293 |
typedef Dfs< Digraph, SetProcessedMapTraits<T> > Create; |
294 | 294 |
}; |
295 | 295 |
|
296 | 296 |
struct SetStandardProcessedMapTraits : public Traits { |
297 | 297 |
typedef typename Digraph::template NodeMap<bool> ProcessedMap; |
298 | 298 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
299 | 299 |
{ |
300 | 300 |
return new ProcessedMap(g); |
301 | 301 |
} |
302 | 302 |
}; |
303 | 303 |
///\brief \ref named-templ-param "Named parameter" for setting |
304 |
/// |
|
304 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
305 | 305 |
/// |
306 | 306 |
///\ref named-templ-param "Named parameter" for setting |
307 |
/// |
|
307 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
308 | 308 |
///If you don't set it explicitly, it will be automatically allocated. |
309 | 309 |
struct SetStandardProcessedMap : |
310 | 310 |
public Dfs< Digraph, SetStandardProcessedMapTraits > { |
311 | 311 |
typedef Dfs< Digraph, SetStandardProcessedMapTraits > Create; |
312 | 312 |
}; |
313 | 313 |
|
314 | 314 |
///@} |
315 | 315 |
|
... | ... |
@@ -763,84 +763,84 @@ |
763 | 763 |
|
764 | 764 |
///\brief The type of the map that stores the predecessor |
765 | 765 |
///arcs of the %DFS paths. |
766 | 766 |
/// |
767 | 767 |
///The type of the map that stores the predecessor |
768 | 768 |
///arcs of the %DFS paths. |
769 | 769 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
770 | 770 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
771 |
///Instantiates a |
|
771 |
///Instantiates a PredMap. |
|
772 | 772 |
|
773 |
///This function instantiates a |
|
773 |
///This function instantiates a PredMap. |
|
774 | 774 |
///\param g is the digraph, to which we would like to define the |
775 |
/// |
|
775 |
///PredMap. |
|
776 | 776 |
static PredMap *createPredMap(const Digraph &g) |
777 | 777 |
{ |
778 | 778 |
return new PredMap(g); |
779 | 779 |
} |
780 | 780 |
|
781 | 781 |
///The type of the map that indicates which nodes are processed. |
782 | 782 |
|
783 | 783 |
///The type of the map that indicates which nodes are processed. |
784 | 784 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
785 | 785 |
///By default it is a NullMap. |
786 | 786 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
787 |
///Instantiates a |
|
787 |
///Instantiates a ProcessedMap. |
|
788 | 788 |
|
789 |
///This function instantiates a |
|
789 |
///This function instantiates a ProcessedMap. |
|
790 | 790 |
///\param g is the digraph, to which |
791 |
///we would like to define the |
|
791 |
///we would like to define the ProcessedMap. |
|
792 | 792 |
#ifdef DOXYGEN |
793 | 793 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
794 | 794 |
#else |
795 | 795 |
static ProcessedMap *createProcessedMap(const Digraph &) |
796 | 796 |
#endif |
797 | 797 |
{ |
798 | 798 |
return new ProcessedMap(); |
799 | 799 |
} |
800 | 800 |
|
801 | 801 |
///The type of the map that indicates which nodes are reached. |
802 | 802 |
|
803 | 803 |
///The type of the map that indicates which nodes are reached. |
804 | 804 |
///It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
805 | 805 |
typedef typename Digraph::template NodeMap<bool> ReachedMap; |
806 |
///Instantiates a |
|
806 |
///Instantiates a ReachedMap. |
|
807 | 807 |
|
808 |
///This function instantiates a |
|
808 |
///This function instantiates a ReachedMap. |
|
809 | 809 |
///\param g is the digraph, to which |
810 |
///we would like to define the |
|
810 |
///we would like to define the ReachedMap. |
|
811 | 811 |
static ReachedMap *createReachedMap(const Digraph &g) |
812 | 812 |
{ |
813 | 813 |
return new ReachedMap(g); |
814 | 814 |
} |
815 | 815 |
|
816 | 816 |
///The type of the map that stores the distances of the nodes. |
817 | 817 |
|
818 | 818 |
///The type of the map that stores the distances of the nodes. |
819 | 819 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
820 | 820 |
typedef typename Digraph::template NodeMap<int> DistMap; |
821 |
///Instantiates a |
|
821 |
///Instantiates a DistMap. |
|
822 | 822 |
|
823 |
///This function instantiates a |
|
823 |
///This function instantiates a DistMap. |
|
824 | 824 |
///\param g is the digraph, to which we would like to define |
825 |
///the |
|
825 |
///the DistMap |
|
826 | 826 |
static DistMap *createDistMap(const Digraph &g) |
827 | 827 |
{ |
828 | 828 |
return new DistMap(g); |
829 | 829 |
} |
830 | 830 |
|
831 | 831 |
///The type of the DFS paths. |
832 | 832 |
|
833 | 833 |
///The type of the DFS paths. |
834 | 834 |
///It must meet the \ref concepts::Path "Path" concept. |
835 | 835 |
typedef lemon::Path<Digraph> Path; |
836 | 836 |
}; |
837 | 837 |
|
838 |
/// Default traits class used by |
|
838 |
/// Default traits class used by DfsWizard |
|
839 | 839 |
|
840 | 840 |
/// To make it easier to use Dfs algorithm |
841 | 841 |
/// we have created a wizard class. |
842 | 842 |
/// This \ref DfsWizard class needs default traits, |
843 | 843 |
/// as well as the \ref Dfs class. |
844 | 844 |
/// The \ref DfsWizardBase is a class to be the default traits of the |
845 | 845 |
/// \ref DfsWizard class. |
846 | 846 |
template<class GR> |
... | ... |
@@ -996,74 +996,74 @@ |
996 | 996 |
|
997 | 997 |
template<class T> |
998 | 998 |
struct SetPredMapBase : public Base { |
999 | 999 |
typedef T PredMap; |
1000 | 1000 |
static PredMap *createPredMap(const Digraph &) { return 0; }; |
1001 | 1001 |
SetPredMapBase(const TR &b) : TR(b) {} |
1002 | 1002 |
}; |
1003 | 1003 |
///\brief \ref named-func-param "Named parameter" |
1004 |
///for setting |
|
1004 |
///for setting PredMap object. |
|
1005 | 1005 |
/// |
1006 | 1006 |
///\ref named-func-param "Named parameter" |
1007 |
///for setting |
|
1007 |
///for setting PredMap object. |
|
1008 | 1008 |
template<class T> |
1009 | 1009 |
DfsWizard<SetPredMapBase<T> > predMap(const T &t) |
1010 | 1010 |
{ |
1011 | 1011 |
Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); |
1012 | 1012 |
return DfsWizard<SetPredMapBase<T> >(*this); |
1013 | 1013 |
} |
1014 | 1014 |
|
1015 | 1015 |
template<class T> |
1016 | 1016 |
struct SetReachedMapBase : public Base { |
1017 | 1017 |
typedef T ReachedMap; |
1018 | 1018 |
static ReachedMap *createReachedMap(const Digraph &) { return 0; }; |
1019 | 1019 |
SetReachedMapBase(const TR &b) : TR(b) {} |
1020 | 1020 |
}; |
1021 | 1021 |
///\brief \ref named-func-param "Named parameter" |
1022 |
///for setting |
|
1022 |
///for setting ReachedMap object. |
|
1023 | 1023 |
/// |
1024 | 1024 |
/// \ref named-func-param "Named parameter" |
1025 |
///for setting |
|
1025 |
///for setting ReachedMap object. |
|
1026 | 1026 |
template<class T> |
1027 | 1027 |
DfsWizard<SetReachedMapBase<T> > reachedMap(const T &t) |
1028 | 1028 |
{ |
1029 | 1029 |
Base::_reached=reinterpret_cast<void*>(const_cast<T*>(&t)); |
1030 | 1030 |
return DfsWizard<SetReachedMapBase<T> >(*this); |
1031 | 1031 |
} |
1032 | 1032 |
|
1033 | 1033 |
template<class T> |
1034 | 1034 |
struct SetDistMapBase : public Base { |
1035 | 1035 |
typedef T DistMap; |
1036 | 1036 |
static DistMap *createDistMap(const Digraph &) { return 0; }; |
1037 | 1037 |
SetDistMapBase(const TR &b) : TR(b) {} |
1038 | 1038 |
}; |
1039 | 1039 |
///\brief \ref named-func-param "Named parameter" |
1040 |
///for setting |
|
1040 |
///for setting DistMap object. |
|
1041 | 1041 |
/// |
1042 | 1042 |
/// \ref named-func-param "Named parameter" |
1043 |
///for setting |
|
1043 |
///for setting DistMap object. |
|
1044 | 1044 |
template<class T> |
1045 | 1045 |
DfsWizard<SetDistMapBase<T> > distMap(const T &t) |
1046 | 1046 |
{ |
1047 | 1047 |
Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t)); |
1048 | 1048 |
return DfsWizard<SetDistMapBase<T> >(*this); |
1049 | 1049 |
} |
1050 | 1050 |
|
1051 | 1051 |
template<class T> |
1052 | 1052 |
struct SetProcessedMapBase : public Base { |
1053 | 1053 |
typedef T ProcessedMap; |
1054 | 1054 |
static ProcessedMap *createProcessedMap(const Digraph &) { return 0; }; |
1055 | 1055 |
SetProcessedMapBase(const TR &b) : TR(b) {} |
1056 | 1056 |
}; |
1057 | 1057 |
///\brief \ref named-func-param "Named parameter" |
1058 |
///for setting |
|
1058 |
///for setting ProcessedMap object. |
|
1059 | 1059 |
/// |
1060 | 1060 |
/// \ref named-func-param "Named parameter" |
1061 |
///for setting |
|
1061 |
///for setting ProcessedMap object. |
|
1062 | 1062 |
template<class T> |
1063 | 1063 |
DfsWizard<SetProcessedMapBase<T> > processedMap(const T &t) |
1064 | 1064 |
{ |
1065 | 1065 |
Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t)); |
1066 | 1066 |
return DfsWizard<SetProcessedMapBase<T> >(*this); |
1067 | 1067 |
} |
1068 | 1068 |
|
1069 | 1069 |
template<class T> |
... | ... |
@@ -1208,21 +1208,21 @@ |
1208 | 1208 |
typedef _Digraph Digraph; |
1209 | 1209 |
|
1210 | 1210 |
/// \brief The type of the map that indicates which nodes are reached. |
1211 | 1211 |
/// |
1212 | 1212 |
/// The type of the map that indicates which nodes are reached. |
1213 | 1213 |
/// It must meet the \ref concepts::ReadWriteMap "ReadWriteMap" concept. |
1214 | 1214 |
typedef typename Digraph::template NodeMap<bool> ReachedMap; |
1215 | 1215 |
|
1216 |
/// \brief Instantiates a |
|
1216 |
/// \brief Instantiates a ReachedMap. |
|
1217 | 1217 |
/// |
1218 |
/// This function instantiates a |
|
1218 |
/// This function instantiates a ReachedMap. |
|
1219 | 1219 |
/// \param digraph is the digraph, to which |
1220 |
/// we would like to define the |
|
1220 |
/// we would like to define the ReachedMap. |
|
1221 | 1221 |
static ReachedMap *createReachedMap(const Digraph &digraph) { |
1222 | 1222 |
return new ReachedMap(digraph); |
1223 | 1223 |
} |
1224 | 1224 |
|
1225 | 1225 |
}; |
1226 | 1226 |
|
1227 | 1227 |
/// \ingroup search |
1228 | 1228 |
/// |
... | ... |
@@ -134,56 +134,56 @@ |
134 | 134 |
|
135 | 135 |
///\brief The type of the map that stores the predecessor |
136 | 136 |
///arcs of the shortest paths. |
137 | 137 |
/// |
138 | 138 |
///The type of the map that stores the predecessor |
139 | 139 |
///arcs of the shortest paths. |
140 | 140 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
141 | 141 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
142 |
///Instantiates a |
|
142 |
///Instantiates a PredMap. |
|
143 | 143 |
|
144 |
///This function instantiates a |
|
144 |
///This function instantiates a PredMap. |
|
145 | 145 |
///\param g is the digraph, to which we would like to define the |
146 |
/// |
|
146 |
///PredMap. |
|
147 | 147 |
static PredMap *createPredMap(const Digraph &g) |
148 | 148 |
{ |
149 | 149 |
return new PredMap(g); |
150 | 150 |
} |
151 | 151 |
|
152 | 152 |
///The type of the map that indicates which nodes are processed. |
153 | 153 |
|
154 | 154 |
///The type of the map that indicates which nodes are processed. |
155 | 155 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
156 | 156 |
///By default it is a NullMap. |
157 | 157 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
158 |
///Instantiates a |
|
158 |
///Instantiates a ProcessedMap. |
|
159 | 159 |
|
160 |
///This function instantiates a |
|
160 |
///This function instantiates a ProcessedMap. |
|
161 | 161 |
///\param g is the digraph, to which |
162 |
///we would like to define the |
|
162 |
///we would like to define the ProcessedMap |
|
163 | 163 |
#ifdef DOXYGEN |
164 | 164 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
165 | 165 |
#else |
166 | 166 |
static ProcessedMap *createProcessedMap(const Digraph &) |
167 | 167 |
#endif |
168 | 168 |
{ |
169 | 169 |
return new ProcessedMap(); |
170 | 170 |
} |
171 | 171 |
|
172 | 172 |
///The type of the map that stores the distances of the nodes. |
173 | 173 |
|
174 | 174 |
///The type of the map that stores the distances of the nodes. |
175 | 175 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
176 | 176 |
typedef typename Digraph::template NodeMap<typename LM::Value> DistMap; |
177 |
///Instantiates a |
|
177 |
///Instantiates a DistMap. |
|
178 | 178 |
|
179 |
///This function instantiates a |
|
179 |
///This function instantiates a DistMap. |
|
180 | 180 |
///\param g is the digraph, to which we would like to define |
181 |
///the |
|
181 |
///the DistMap |
|
182 | 182 |
static DistMap *createDistMap(const Digraph &g) |
183 | 183 |
{ |
184 | 184 |
return new DistMap(g); |
185 | 185 |
} |
186 | 186 |
}; |
187 | 187 |
|
188 | 188 |
///%Dijkstra algorithm class. |
189 | 189 |
|
... | ... |
@@ -322,78 +322,78 @@ |
322 | 322 |
typedef T PredMap; |
323 | 323 |
static PredMap *createPredMap(const Digraph &) |
324 | 324 |
{ |
325 | 325 |
LEMON_ASSERT(false, "PredMap is not initialized"); |
326 | 326 |
return 0; // ignore warnings |
327 | 327 |
} |
328 | 328 |
}; |
329 | 329 |
///\brief \ref named-templ-param "Named parameter" for setting |
330 |
/// |
|
330 |
///PredMap type. |
|
331 | 331 |
/// |
332 | 332 |
///\ref named-templ-param "Named parameter" for setting |
333 |
/// |
|
333 |
///PredMap type. |
|
334 | 334 |
template <class T> |
335 | 335 |
struct SetPredMap |
336 | 336 |
: public Dijkstra< Digraph, LengthMap, SetPredMapTraits<T> > { |
337 | 337 |
typedef Dijkstra< Digraph, LengthMap, SetPredMapTraits<T> > Create; |
338 | 338 |
}; |
339 | 339 |
|
340 | 340 |
template <class T> |
341 | 341 |
struct SetDistMapTraits : public Traits { |
342 | 342 |
typedef T DistMap; |
343 | 343 |
static DistMap *createDistMap(const Digraph &) |
344 | 344 |
{ |
345 | 345 |
LEMON_ASSERT(false, "DistMap is not initialized"); |
346 | 346 |
return 0; // ignore warnings |
347 | 347 |
} |
348 | 348 |
}; |
349 | 349 |
///\brief \ref named-templ-param "Named parameter" for setting |
350 |
/// |
|
350 |
///DistMap type. |
|
351 | 351 |
/// |
352 | 352 |
///\ref named-templ-param "Named parameter" for setting |
353 |
/// |
|
353 |
///DistMap type. |
|
354 | 354 |
template <class T> |
355 | 355 |
struct SetDistMap |
356 | 356 |
: public Dijkstra< Digraph, LengthMap, SetDistMapTraits<T> > { |
357 | 357 |
typedef Dijkstra< Digraph, LengthMap, SetDistMapTraits<T> > Create; |
358 | 358 |
}; |
359 | 359 |
|
360 | 360 |
template <class T> |
361 | 361 |
struct SetProcessedMapTraits : public Traits { |
362 | 362 |
typedef T ProcessedMap; |
363 | 363 |
static ProcessedMap *createProcessedMap(const Digraph &) |
364 | 364 |
{ |
365 | 365 |
LEMON_ASSERT(false, "ProcessedMap is not initialized"); |
366 | 366 |
return 0; // ignore warnings |
367 | 367 |
} |
368 | 368 |
}; |
369 | 369 |
///\brief \ref named-templ-param "Named parameter" for setting |
370 |
/// |
|
370 |
///ProcessedMap type. |
|
371 | 371 |
/// |
372 | 372 |
///\ref named-templ-param "Named parameter" for setting |
373 |
/// |
|
373 |
///ProcessedMap type. |
|
374 | 374 |
template <class T> |
375 | 375 |
struct SetProcessedMap |
376 | 376 |
: public Dijkstra< Digraph, LengthMap, SetProcessedMapTraits<T> > { |
377 | 377 |
typedef Dijkstra< Digraph, LengthMap, SetProcessedMapTraits<T> > Create; |
378 | 378 |
}; |
379 | 379 |
|
380 | 380 |
struct SetStandardProcessedMapTraits : public Traits { |
381 | 381 |
typedef typename Digraph::template NodeMap<bool> ProcessedMap; |
382 | 382 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
383 | 383 |
{ |
384 | 384 |
return new ProcessedMap(g); |
385 | 385 |
} |
386 | 386 |
}; |
387 | 387 |
///\brief \ref named-templ-param "Named parameter" for setting |
388 |
/// |
|
388 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
389 | 389 |
/// |
390 | 390 |
///\ref named-templ-param "Named parameter" for setting |
391 |
/// |
|
391 |
///ProcessedMap type to be <tt>Digraph::NodeMap<bool></tt>. |
|
392 | 392 |
///If you don't set it explicitly, it will be automatically allocated. |
393 | 393 |
struct SetStandardProcessedMap |
394 | 394 |
: public Dijkstra< Digraph, LengthMap, SetStandardProcessedMapTraits > { |
395 | 395 |
typedef Dijkstra< Digraph, LengthMap, SetStandardProcessedMapTraits > |
396 | 396 |
Create; |
397 | 397 |
}; |
398 | 398 |
|
399 | 399 |
template <class H, class CR> |
... | ... |
@@ -448,17 +448,17 @@ |
448 | 448 |
}; |
449 | 449 |
|
450 | 450 |
template <class T> |
451 | 451 |
struct SetOperationTraitsTraits : public Traits { |
452 | 452 |
typedef T OperationTraits; |
453 | 453 |
}; |
454 | 454 |
|
455 | 455 |
/// \brief \ref named-templ-param "Named parameter" for setting |
456 |
///\ |
|
456 |
///\c OperationTraits type |
|
457 | 457 |
/// |
458 | 458 |
///\ref named-templ-param "Named parameter" for setting |
459 | 459 |
///\ref OperationTraits type. |
460 | 460 |
template <class T> |
461 | 461 |
struct SetOperationTraits |
462 | 462 |
: public Dijkstra<Digraph, LengthMap, SetOperationTraitsTraits<T> > { |
463 | 463 |
typedef Dijkstra<Digraph, LengthMap, SetOperationTraitsTraits<T> > |
464 | 464 |
Create; |
... | ... |
@@ -981,69 +981,69 @@ |
981 | 981 |
|
982 | 982 |
///\brief The type of the map that stores the predecessor |
983 | 983 |
///arcs of the shortest paths. |
984 | 984 |
/// |
985 | 985 |
///The type of the map that stores the predecessor |
986 | 986 |
///arcs of the shortest paths. |
987 | 987 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
988 | 988 |
typedef typename Digraph::template NodeMap<typename Digraph::Arc> PredMap; |
989 |
///Instantiates a |
|
989 |
///Instantiates a PredMap. |
|
990 | 990 |
|
991 |
///This function instantiates a |
|
991 |
///This function instantiates a PredMap. |
|
992 | 992 |
///\param g is the digraph, to which we would like to define the |
993 |
/// |
|
993 |
///PredMap. |
|
994 | 994 |
static PredMap *createPredMap(const Digraph &g) |
995 | 995 |
{ |
996 | 996 |
return new PredMap(g); |
997 | 997 |
} |
998 | 998 |
|
999 | 999 |
///The type of the map that indicates which nodes are processed. |
1000 | 1000 |
|
1001 | 1001 |
///The type of the map that indicates which nodes are processed. |
1002 | 1002 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
1003 | 1003 |
///By default it is a NullMap. |
1004 | 1004 |
typedef NullMap<typename Digraph::Node,bool> ProcessedMap; |
1005 |
///Instantiates a |
|
1005 |
///Instantiates a ProcessedMap. |
|
1006 | 1006 |
|
1007 |
///This function instantiates a |
|
1007 |
///This function instantiates a ProcessedMap. |
|
1008 | 1008 |
///\param g is the digraph, to which |
1009 |
///we would like to define the |
|
1009 |
///we would like to define the ProcessedMap. |
|
1010 | 1010 |
#ifdef DOXYGEN |
1011 | 1011 |
static ProcessedMap *createProcessedMap(const Digraph &g) |
1012 | 1012 |
#else |
1013 | 1013 |
static ProcessedMap *createProcessedMap(const Digraph &) |
1014 | 1014 |
#endif |
1015 | 1015 |
{ |
1016 | 1016 |
return new ProcessedMap(); |
1017 | 1017 |
} |
1018 | 1018 |
|
1019 | 1019 |
///The type of the map that stores the distances of the nodes. |
1020 | 1020 |
|
1021 | 1021 |
///The type of the map that stores the distances of the nodes. |
1022 | 1022 |
///It must meet the \ref concepts::WriteMap "WriteMap" concept. |
1023 | 1023 |
typedef typename Digraph::template NodeMap<typename LM::Value> DistMap; |
1024 |
///Instantiates a |
|
1024 |
///Instantiates a DistMap. |
|
1025 | 1025 |
|
1026 |
///This function instantiates a |
|
1026 |
///This function instantiates a DistMap. |
|
1027 | 1027 |
///\param g is the digraph, to which we would like to define |
1028 |
///the |
|
1028 |
///the DistMap |
|
1029 | 1029 |
static DistMap *createDistMap(const Digraph &g) |
1030 | 1030 |
{ |
1031 | 1031 |
return new DistMap(g); |
1032 | 1032 |
} |
1033 | 1033 |
|
1034 | 1034 |
///The type of the shortest paths. |
1035 | 1035 |
|
1036 | 1036 |
///The type of the shortest paths. |
1037 | 1037 |
///It must meet the \ref concepts::Path "Path" concept. |
1038 | 1038 |
typedef lemon::Path<Digraph> Path; |
1039 | 1039 |
}; |
1040 | 1040 |
|
1041 |
/// Default traits class used by |
|
1041 |
/// Default traits class used by DijkstraWizard |
|
1042 | 1042 |
|
1043 | 1043 |
/// To make it easier to use Dijkstra algorithm |
1044 | 1044 |
/// we have created a wizard class. |
1045 | 1045 |
/// This \ref DijkstraWizard class needs default traits, |
1046 | 1046 |
/// as well as the \ref Dijkstra class. |
1047 | 1047 |
/// The \ref DijkstraWizardBase is a class to be the default traits of the |
1048 | 1048 |
/// \ref DijkstraWizard class. |
1049 | 1049 |
template<class GR,class LM> |
... | ... |
@@ -1193,56 +1193,56 @@ |
1193 | 1193 |
|
1194 | 1194 |
template<class T> |
1195 | 1195 |
struct SetPredMapBase : public Base { |
1196 | 1196 |
typedef T PredMap; |
1197 | 1197 |
static PredMap *createPredMap(const Digraph &) { return 0; }; |
1198 | 1198 |
SetPredMapBase(const TR &b) : TR(b) {} |
1199 | 1199 |
}; |
1200 | 1200 |
///\brief \ref named-func-param "Named parameter" |
1201 |
///for setting |
|
1201 |
///for setting PredMap object. |
|
1202 | 1202 |
/// |
1203 | 1203 |
///\ref named-func-param "Named parameter" |
1204 |
///for setting |
|
1204 |
///for setting PredMap object. |
|
1205 | 1205 |
template<class T> |
1206 | 1206 |
DijkstraWizard<SetPredMapBase<T> > predMap(const T &t) |
1207 | 1207 |
{ |
1208 | 1208 |
Base::_pred=reinterpret_cast<void*>(const_cast<T*>(&t)); |
1209 | 1209 |
return DijkstraWizard<SetPredMapBase<T> >(*this); |
1210 | 1210 |
} |
1211 | 1211 |
|
1212 | 1212 |
template<class T> |
1213 | 1213 |
struct SetDistMapBase : public Base { |
1214 | 1214 |
typedef T DistMap; |
1215 | 1215 |
static DistMap *createDistMap(const Digraph &) { return 0; }; |
1216 | 1216 |
SetDistMapBase(const TR &b) : TR(b) {} |
1217 | 1217 |
}; |
1218 | 1218 |
///\brief \ref named-func-param "Named parameter" |
1219 |
///for setting |
|
1219 |
///for setting DistMap object. |
|
1220 | 1220 |
/// |
1221 | 1221 |
///\ref named-func-param "Named parameter" |
1222 |
///for setting |
|
1222 |
///for setting DistMap object. |
|
1223 | 1223 |
template<class T> |
1224 | 1224 |
DijkstraWizard<SetDistMapBase<T> > distMap(const T &t) |
1225 | 1225 |
{ |
1226 | 1226 |
Base::_dist=reinterpret_cast<void*>(const_cast<T*>(&t)); |
1227 | 1227 |
return DijkstraWizard<SetDistMapBase<T> >(*this); |
1228 | 1228 |
} |
1229 | 1229 |
|
1230 | 1230 |
template<class T> |
1231 | 1231 |
struct SetProcessedMapBase : public Base { |
1232 | 1232 |
typedef T ProcessedMap; |
1233 | 1233 |
static ProcessedMap *createProcessedMap(const Digraph &) { return 0; }; |
1234 | 1234 |
SetProcessedMapBase(const TR &b) : TR(b) {} |
1235 | 1235 |
}; |
1236 | 1236 |
///\brief \ref named-func-param "Named parameter" |
1237 |
///for setting |
|
1237 |
///for setting ProcessedMap object. |
|
1238 | 1238 |
/// |
1239 | 1239 |
/// \ref named-func-param "Named parameter" |
1240 |
///for setting |
|
1240 |
///for setting ProcessedMap object. |
|
1241 | 1241 |
template<class T> |
1242 | 1242 |
DijkstraWizard<SetProcessedMapBase<T> > processedMap(const T &t) |
1243 | 1243 |
{ |
1244 | 1244 |
Base::_processed=reinterpret_cast<void*>(const_cast<T*>(&t)); |
1245 | 1245 |
return DijkstraWizard<SetProcessedMapBase<T> >(*this); |
1246 | 1246 |
} |
1247 | 1247 |
|
1248 | 1248 |
template<class T> |
... | ... |
@@ -254,20 +254,20 @@ |
254 | 254 |
template<typename T> |
255 | 255 |
inline Point<T> rot270(const Point<T> &z) |
256 | 256 |
{ |
257 | 257 |
return Point<T>(z.y,-z.x); |
258 | 258 |
} |
259 | 259 |
|
260 | 260 |
|
261 | 261 |
|
262 |
/// Bounding box of plain vectors ( |
|
262 |
/// Bounding box of plain vectors (points). |
|
263 | 263 |
|
264 | 264 |
/// A class to calculate or store the bounding box of plain vectors |
265 |
/// (\ref Point points). |
|
265 |
/// (\ref Point "points"). |
|
266 | 266 |
template<typename T> |
267 | 267 |
class Box { |
268 | 268 |
Point<T> _bottom_left, _top_right; |
269 | 269 |
bool _empty; |
270 | 270 |
public: |
271 | 271 |
|
272 | 272 |
///Default constructor: creates an empty box |
273 | 273 |
Box() { _empty = true; } |
... | ... |
@@ -568,175 +568,159 @@ |
568 | 568 |
///\relates Box |
569 | 569 |
template<typename T> |
570 | 570 |
inline std::ostream& operator<<(std::ostream &os, const Box<T>& b) |
571 | 571 |
{ |
572 | 572 |
os << "(" << b.bottomLeft() << "," << b.topRight() << ")"; |
573 | 573 |
return os; |
574 | 574 |
} |
575 | 575 |
|
576 |
///Map of x-coordinates of a |
|
576 |
///Map of x-coordinates of a <tt>Point</tt>-map |
|
577 | 577 |
|
578 |
///\ingroup maps |
|
579 | 578 |
///Map of x-coordinates of a \ref Point "Point"-map. |
580 | 579 |
/// |
581 | 580 |
template<class M> |
582 | 581 |
class XMap |
583 | 582 |
{ |
584 | 583 |
M& _map; |
585 | 584 |
public: |
586 | 585 |
|
587 | 586 |
typedef typename M::Value::Value Value; |
588 | 587 |
typedef typename M::Key Key; |
589 | 588 |
///\e |
590 | 589 |
XMap(M& map) : _map(map) {} |
591 | 590 |
Value operator[](Key k) const {return _map[k].x;} |
592 | 591 |
void set(Key k,Value v) {_map.set(k,typename M::Value(v,_map[k].y));} |
593 | 592 |
}; |
594 | 593 |
|
595 |
///Returns an |
|
594 |
///Returns an XMap class |
|
596 | 595 |
|
597 |
///This function just returns an \ref XMap class. |
|
598 |
/// |
|
599 |
/// |
|
596 |
///This function just returns an XMap class. |
|
600 | 597 |
///\relates XMap |
601 | 598 |
template<class M> |
602 | 599 |
inline XMap<M> xMap(M &m) |
603 | 600 |
{ |
604 | 601 |
return XMap<M>(m); |
605 | 602 |
} |
606 | 603 |
|
607 | 604 |
template<class M> |
608 | 605 |
inline XMap<M> xMap(const M &m) |
609 | 606 |
{ |
610 | 607 |
return XMap<M>(m); |
611 | 608 |
} |
612 | 609 |
|
613 |
///Constant (read only) version of |
|
610 |
///Constant (read only) version of XMap |
|
614 | 611 |
|
615 |
///\ingroup maps |
|
616 |
///Constant (read only) version of \ref XMap |
|
612 |
///Constant (read only) version of XMap. |
|
617 | 613 |
/// |
618 | 614 |
template<class M> |
619 | 615 |
class ConstXMap |
620 | 616 |
{ |
621 | 617 |
const M& _map; |
622 | 618 |
public: |
623 | 619 |
|
624 | 620 |
typedef typename M::Value::Value Value; |
625 | 621 |
typedef typename M::Key Key; |
626 | 622 |
///\e |
627 | 623 |
ConstXMap(const M &map) : _map(map) {} |
628 | 624 |
Value operator[](Key k) const {return _map[k].x;} |
629 | 625 |
}; |
630 | 626 |
|
631 |
///Returns a |
|
627 |
///Returns a ConstXMap class |
|
632 | 628 |
|
633 |
///This function just returns a \ref ConstXMap class. |
|
634 |
/// |
|
635 |
/// |
|
629 |
///This function just returns a ConstXMap class. |
|
636 | 630 |
///\relates ConstXMap |
637 | 631 |
template<class M> |
638 | 632 |
inline ConstXMap<M> xMap(const M &m) |
639 | 633 |
{ |
640 | 634 |
return ConstXMap<M>(m); |
641 | 635 |
} |
642 | 636 |
|
643 |
///Map of y-coordinates of a |
|
637 |
///Map of y-coordinates of a <tt>Point</tt>-map |
|
644 | 638 |
|
645 |
///\ingroup maps |
|
646 | 639 |
///Map of y-coordinates of a \ref Point "Point"-map. |
647 | 640 |
/// |
648 | 641 |
template<class M> |
649 | 642 |
class YMap |
650 | 643 |
{ |
651 | 644 |
M& _map; |
652 | 645 |
public: |
653 | 646 |
|
654 | 647 |
typedef typename M::Value::Value Value; |
655 | 648 |
typedef typename M::Key Key; |
656 | 649 |
///\e |
657 | 650 |
YMap(M& map) : _map(map) {} |
658 | 651 |
Value operator[](Key k) const {return _map[k].y;} |
659 | 652 |
void set(Key k,Value v) {_map.set(k,typename M::Value(_map[k].x,v));} |
660 | 653 |
}; |
661 | 654 |
|
662 |
///Returns a |
|
655 |
///Returns a YMap class |
|
663 | 656 |
|
664 |
///This function just returns a \ref YMap class. |
|
665 |
/// |
|
666 |
/// |
|
657 |
///This function just returns a YMap class. |
|
667 | 658 |
///\relates YMap |
668 | 659 |
template<class M> |
669 | 660 |
inline YMap<M> yMap(M &m) |
670 | 661 |
{ |
671 | 662 |
return YMap<M>(m); |
672 | 663 |
} |
673 | 664 |
|
674 | 665 |
template<class M> |
675 | 666 |
inline YMap<M> yMap(const M &m) |
676 | 667 |
{ |
677 | 668 |
return YMap<M>(m); |
678 | 669 |
} |
679 | 670 |
|
680 |
///Constant (read only) version of |
|
671 |
///Constant (read only) version of YMap |
|
681 | 672 |
|
682 |
///\ingroup maps |
|
683 |
///Constant (read only) version of \ref YMap |
|
673 |
///Constant (read only) version of YMap. |
|
684 | 674 |
/// |
685 | 675 |
template<class M> |
686 | 676 |
class ConstYMap |
687 | 677 |
{ |
688 | 678 |
const M& _map; |
689 | 679 |
public: |
690 | 680 |
|
691 | 681 |
typedef typename M::Value::Value Value; |
692 | 682 |
typedef typename M::Key Key; |
693 | 683 |
///\e |
694 | 684 |
ConstYMap(const M &map) : _map(map) {} |
695 | 685 |
Value operator[](Key k) const {return _map[k].y;} |
696 | 686 |
}; |
697 | 687 |
|
698 |
///Returns a |
|
688 |
///Returns a ConstYMap class |
|
699 | 689 |
|
700 |
///This function just returns a \ref ConstYMap class. |
|
701 |
/// |
|
702 |
/// |
|
690 |
///This function just returns a ConstYMap class. |
|
703 | 691 |
///\relates ConstYMap |
704 | 692 |
template<class M> |
705 | 693 |
inline ConstYMap<M> yMap(const M &m) |
706 | 694 |
{ |
707 | 695 |
return ConstYMap<M>(m); |
708 | 696 |
} |
709 | 697 |
|
710 | 698 |
|
711 |
///\brief Map of the \ref Point::normSquare() "normSquare()" |
|
712 |
///of a \ref Point "Point"-map |
|
699 |
///\brief Map of the normSquare() of a <tt>Point</tt>-map |
|
713 | 700 |
/// |
714 | 701 |
///Map of the \ref Point::normSquare() "normSquare()" |
715 | 702 |
///of a \ref Point "Point"-map. |
716 |
///\ingroup maps |
|
717 | 703 |
template<class M> |
718 | 704 |
class NormSquareMap |
719 | 705 |
{ |
720 | 706 |
const M& _map; |
721 | 707 |
public: |
722 | 708 |
|
723 | 709 |
typedef typename M::Value::Value Value; |
724 | 710 |
typedef typename M::Key Key; |
725 | 711 |
///\e |
726 | 712 |
NormSquareMap(const M &map) : _map(map) {} |
727 | 713 |
Value operator[](Key k) const {return _map[k].normSquare();} |
728 | 714 |
}; |
729 | 715 |
|
730 |
///Returns a |
|
716 |
///Returns a NormSquareMap class |
|
731 | 717 |
|
732 |
///This function just returns a \ref NormSquareMap class. |
|
733 |
/// |
|
734 |
/// |
|
718 |
///This function just returns a NormSquareMap class. |
|
735 | 719 |
///\relates NormSquareMap |
736 | 720 |
template<class M> |
737 | 721 |
inline NormSquareMap<M> normSquareMap(const M &m) |
738 | 722 |
{ |
739 | 723 |
return NormSquareMap<M>(m); |
740 | 724 |
} |
741 | 725 |
|
742 | 726 |
/// @} |
... | ... |
@@ -57,17 +57,17 @@ |
57 | 57 |
typedef typename MT::Value Value; |
58 | 58 |
const MT ↦ |
59 | 59 |
int yscale; |
60 | 60 |
_NegY(const MT &m,bool b) : map(m), yscale(1-b*2) {} |
61 | 61 |
Value operator[](Key n) { return Value(map[n].x,map[n].y*yscale);} |
62 | 62 |
}; |
63 | 63 |
} |
64 | 64 |
|
65 |
///Default traits class of |
|
65 |
///Default traits class of GraphToEps |
|
66 | 66 |
|
67 | 67 |
///Default traits class of \ref GraphToEps. |
68 | 68 |
/// |
69 | 69 |
///\c G is the type of the underlying graph. |
70 | 70 |
template<class G> |
71 | 71 |
struct DefaultGraphToEpsTraits |
72 | 72 |
{ |
73 | 73 |
typedef G Graph; |
... | ... |
@@ -386,25 +386,47 @@ |
386 | 386 |
} |
387 | 387 |
}; |
388 | 388 |
|
389 | 389 |
} |
390 | 390 |
|
391 | 391 |
template <typename Digraph> |
392 | 392 |
class DigraphReader; |
393 | 393 |
|
394 |
/// \brief Return a \ref DigraphReader class |
|
395 |
/// |
|
396 |
/// This function just returns a \ref DigraphReader class. |
|
397 |
/// \relates DigraphReader |
|
394 | 398 |
template <typename Digraph> |
395 | 399 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, |
396 |
std::istream& is = std::cin); |
|
397 |
|
|
400 |
std::istream& is = std::cin) { |
|
401 |
DigraphReader<Digraph> tmp(digraph, is); |
|
402 |
return tmp; |
|
403 |
} |
|
404 |
|
|
405 |
/// \brief Return a \ref DigraphReader class |
|
406 |
/// |
|
407 |
/// This function just returns a \ref DigraphReader class. |
|
408 |
/// \relates DigraphReader |
|
398 | 409 |
template <typename Digraph> |
399 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, const std::string& fn); |
|
400 |
|
|
410 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, |
|
411 |
const std::string& fn) { |
|
412 |
DigraphReader<Digraph> tmp(digraph, fn); |
|
413 |
return tmp; |
|
414 |
} |
|
415 |
|
|
416 |
/// \brief Return a \ref DigraphReader class |
|
417 |
/// |
|
418 |
/// This function just returns a \ref DigraphReader class. |
|
419 |
/// \relates DigraphReader |
|
401 | 420 |
template <typename Digraph> |
402 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, const char |
|
421 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) { |
|
422 |
DigraphReader<Digraph> tmp(digraph, fn); |
|
423 |
return tmp; |
|
424 |
} |
|
403 | 425 |
|
404 | 426 |
/// \ingroup lemon_io |
405 | 427 |
/// |
406 | 428 |
/// \brief \ref lgf-format "LGF" reader for directed graphs |
407 | 429 |
/// |
408 | 430 |
/// This utility reads an \ref lgf-format "LGF" file. |
409 | 431 |
/// |
410 | 432 |
/// The reading method does a batch processing. The user creates a |
... | ... |
@@ -1184,61 +1206,49 @@ |
1184 | 1206 |
} |
1185 | 1207 |
|
1186 | 1208 |
} |
1187 | 1209 |
|
1188 | 1210 |
/// @} |
1189 | 1211 |
|
1190 | 1212 |
}; |
1191 | 1213 |
|
1192 |
|
|
1214 |
template <typename Graph> |
|
1215 |
class GraphReader; |
|
1216 |
|
|
1217 |
/// \brief Return a \ref GraphReader class |
|
1193 | 1218 |
/// |
1194 |
/// This function just returns a \ref DigraphReader class. |
|
1195 |
/// \relates DigraphReader |
|
1196 |
template <typename Digraph> |
|
1197 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, |
|
1198 |
std::istream& is = std::cin) { |
|
1199 |
DigraphReader<Digraph> tmp(digraph, is); |
|
1219 |
/// This function just returns a \ref GraphReader class. |
|
1220 |
/// \relates GraphReader |
|
1221 |
template <typename Graph> |
|
1222 |
GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) { |
|
1223 |
GraphReader<Graph> tmp(graph, is); |
|
1200 | 1224 |
return tmp; |
1201 | 1225 |
} |
1202 | 1226 |
|
1203 |
/// \brief Return a \ref |
|
1227 |
/// \brief Return a \ref GraphReader class |
|
1204 | 1228 |
/// |
1205 |
/// This function just returns a \ref DigraphReader class. |
|
1206 |
/// \relates DigraphReader |
|
1207 |
template <typename Digraph> |
|
1208 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, |
|
1209 |
const std::string& fn) { |
|
1210 |
DigraphReader<Digraph> tmp(digraph, fn); |
|
1229 |
/// This function just returns a \ref GraphReader class. |
|
1230 |
/// \relates GraphReader |
|
1231 |
template <typename Graph> |
|
1232 |
GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) { |
|
1233 |
GraphReader<Graph> tmp(graph, fn); |
|
1211 | 1234 |
return tmp; |
1212 | 1235 |
} |
1213 | 1236 |
|
1214 |
/// \brief Return a \ref |
|
1237 |
/// \brief Return a \ref GraphReader class |
|
1215 | 1238 |
/// |
1216 |
/// This function just returns a \ref DigraphReader class. |
|
1217 |
/// \relates DigraphReader |
|
1218 |
template <typename Digraph> |
|
1219 |
DigraphReader<Digraph> digraphReader(Digraph& digraph, const char* fn) { |
|
1220 |
|
|
1239 |
/// This function just returns a \ref GraphReader class. |
|
1240 |
/// \relates GraphReader |
|
1241 |
template <typename Graph> |
|
1242 |
GraphReader<Graph> graphReader(Graph& graph, const char* fn) { |
|
1243 |
GraphReader<Graph> tmp(graph, fn); |
|
1221 | 1244 |
return tmp; |
1222 | 1245 |
} |
1223 | 1246 |
|
1224 |
template <typename Graph> |
|
1225 |
class GraphReader; |
|
1226 |
|
|
1227 |
template <typename Graph> |
|
1228 |
GraphReader<Graph> graphReader(Graph& graph, |
|
1229 |
std::istream& is = std::cin); |
|
1230 |
|
|
1231 |
template <typename Graph> |
|
1232 |
GraphReader<Graph> graphReader(Graph& graph, const std::string& fn); |
|
1233 |
|
|
1234 |
template <typename Graph> |
|
1235 |
GraphReader<Graph> graphReader(Graph& graph, const char *fn); |
|
1236 |
|
|
1237 | 1247 |
/// \ingroup lemon_io |
1238 | 1248 |
/// |
1239 | 1249 |
/// \brief \ref lgf-format "LGF" reader for undirected graphs |
1240 | 1250 |
/// |
1241 | 1251 |
/// This utility reads an \ref lgf-format "LGF" file. |
1242 | 1252 |
/// |
1243 | 1253 |
/// It can be used almost the same way as \c DigraphReader. |
1244 | 1254 |
/// The only difference is that this class can handle edges and |
... | ... |
@@ -2026,46 +2036,16 @@ |
2026 | 2036 |
} |
2027 | 2037 |
|
2028 | 2038 |
} |
2029 | 2039 |
|
2030 | 2040 |
/// @} |
2031 | 2041 |
|
2032 | 2042 |
}; |
2033 | 2043 |
|
2034 |
/// \brief Return a \ref GraphReader class |
|
2035 |
/// |
|
2036 |
/// This function just returns a \ref GraphReader class. |
|
2037 |
/// \relates GraphReader |
|
2038 |
template <typename Graph> |
|
2039 |
GraphReader<Graph> graphReader(Graph& graph, std::istream& is = std::cin) { |
|
2040 |
GraphReader<Graph> tmp(graph, is); |
|
2041 |
return tmp; |
|
2042 |
} |
|
2043 |
|
|
2044 |
/// \brief Return a \ref GraphReader class |
|
2045 |
/// |
|
2046 |
/// This function just returns a \ref GraphReader class. |
|
2047 |
/// \relates GraphReader |
|
2048 |
template <typename Graph> |
|
2049 |
GraphReader<Graph> graphReader(Graph& graph, const std::string& fn) { |
|
2050 |
GraphReader<Graph> tmp(graph, fn); |
|
2051 |
return tmp; |
|
2052 |
} |
|
2053 |
|
|
2054 |
/// \brief Return a \ref GraphReader class |
|
2055 |
/// |
|
2056 |
/// This function just returns a \ref GraphReader class. |
|
2057 |
/// \relates GraphReader |
|
2058 |
template <typename Graph> |
|
2059 |
GraphReader<Graph> graphReader(Graph& graph, const char* fn) { |
|
2060 |
GraphReader<Graph> tmp(graph, fn); |
|
2061 |
return tmp; |
|
2062 |
} |
|
2063 |
|
|
2064 | 2044 |
class SectionReader; |
2065 | 2045 |
|
2066 | 2046 |
SectionReader sectionReader(std::istream& is); |
2067 | 2047 |
SectionReader sectionReader(const std::string& fn); |
2068 | 2048 |
SectionReader sectionReader(const char* fn); |
2069 | 2049 |
|
2070 | 2050 |
/// \ingroup lemon_io |
2071 | 2051 |
/// |
... | ... |
@@ -346,27 +346,48 @@ |
346 | 346 |
} |
347 | 347 |
}; |
348 | 348 |
|
349 | 349 |
} |
350 | 350 |
|
351 | 351 |
template <typename Digraph> |
352 | 352 |
class DigraphWriter; |
353 | 353 |
|
354 |
/// \brief Return a \ref DigraphWriter class |
|
355 |
/// |
|
356 |
/// This function just returns a \ref DigraphWriter class. |
|
357 |
/// \relates DigraphWriter |
|
354 | 358 |
template <typename Digraph> |
355 | 359 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
356 |
std::ostream& os = std::cout) |
|
360 |
std::ostream& os = std::cout) { |
|
361 |
DigraphWriter<Digraph> tmp(digraph, os); |
|
362 |
return tmp; |
|
363 |
} |
|
357 | 364 |
|
365 |
/// \brief Return a \ref DigraphWriter class |
|
366 |
/// |
|
367 |
/// This function just returns a \ref DigraphWriter class. |
|
368 |
/// \relates DigraphWriter |
|
358 | 369 |
template <typename Digraph> |
359 | 370 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
360 |
const std::string& fn) |
|
371 |
const std::string& fn) { |
|
372 |
DigraphWriter<Digraph> tmp(digraph, fn); |
|
373 |
return tmp; |
|
374 |
} |
|
361 | 375 |
|
376 |
/// \brief Return a \ref DigraphWriter class |
|
377 |
/// |
|
378 |
/// This function just returns a \ref DigraphWriter class. |
|
379 |
/// \relates DigraphWriter |
|
362 | 380 |
template <typename Digraph> |
363 | 381 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
364 |
const char |
|
382 |
const char* fn) { |
|
383 |
DigraphWriter<Digraph> tmp(digraph, fn); |
|
384 |
return tmp; |
|
385 |
} |
|
365 | 386 |
|
366 | 387 |
/// \ingroup lemon_io |
367 | 388 |
/// |
368 | 389 |
/// \brief \ref lgf-format "LGF" writer for directed graphs |
369 | 390 |
/// |
370 | 391 |
/// This utility writes an \ref lgf-format "LGF" file. |
371 | 392 |
/// |
372 | 393 |
/// The writing method does a batch processing. The user creates a |
... | ... |
@@ -908,62 +929,50 @@ |
908 | 929 |
/// Give back the stream of the writer. |
909 | 930 |
std::ostream& ostream() { |
910 | 931 |
return *_os; |
911 | 932 |
} |
912 | 933 |
|
913 | 934 |
/// @} |
914 | 935 |
}; |
915 | 936 |
|
916 |
|
|
937 |
template <typename Graph> |
|
938 |
class GraphWriter; |
|
939 |
|
|
940 |
/// \brief Return a \ref GraphWriter class |
|
917 | 941 |
/// |
918 |
/// This function just returns a \ref DigraphWriter class. |
|
919 |
/// \relates DigraphWriter |
|
920 |
template <typename Digraph> |
|
921 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
922 |
std::ostream& os = std::cout) { |
|
923 |
DigraphWriter<Digraph> tmp(digraph, os); |
|
942 |
/// This function just returns a \ref GraphWriter class. |
|
943 |
/// \relates GraphWriter |
|
944 |
template <typename Graph> |
|
945 |
GraphWriter<Graph> graphWriter(const Graph& graph, |
|
946 |
std::ostream& os = std::cout) { |
|
947 |
GraphWriter<Graph> tmp(graph, os); |
|
924 | 948 |
return tmp; |
925 | 949 |
} |
926 | 950 |
|
927 |
/// \brief Return a \ref |
|
951 |
/// \brief Return a \ref GraphWriter class |
|
928 | 952 |
/// |
929 |
/// This function just returns a \ref DigraphWriter class. |
|
930 |
/// \relates DigraphWriter |
|
931 |
template <typename Digraph> |
|
932 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
933 |
const std::string& fn) { |
|
934 |
DigraphWriter<Digraph> tmp(digraph, fn); |
|
953 |
/// This function just returns a \ref GraphWriter class. |
|
954 |
/// \relates GraphWriter |
|
955 |
template <typename Graph> |
|
956 |
GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) { |
|
957 |
GraphWriter<Graph> tmp(graph, fn); |
|
935 | 958 |
return tmp; |
936 | 959 |
} |
937 | 960 |
|
938 |
/// \brief Return a \ref |
|
961 |
/// \brief Return a \ref GraphWriter class |
|
939 | 962 |
/// |
940 |
/// This function just returns a \ref DigraphWriter class. |
|
941 |
/// \relates DigraphWriter |
|
942 |
template <typename Digraph> |
|
943 |
DigraphWriter<Digraph> digraphWriter(const Digraph& digraph, |
|
944 |
const char* fn) { |
|
945 |
DigraphWriter<Digraph> tmp(digraph, fn); |
|
963 |
/// This function just returns a \ref GraphWriter class. |
|
964 |
/// \relates GraphWriter |
|
965 |
template <typename Graph> |
|
966 |
GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) { |
|
967 |
GraphWriter<Graph> tmp(graph, fn); |
|
946 | 968 |
return tmp; |
947 | 969 |
} |
948 | 970 |
|
949 |
template <typename Graph> |
|
950 |
class GraphWriter; |
|
951 |
|
|
952 |
template <typename Graph> |
|
953 |
GraphWriter<Graph> graphWriter(const Graph& graph, |
|
954 |
std::ostream& os = std::cout); |
|
955 |
|
|
956 |
template <typename Graph> |
|
957 |
GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn); |
|
958 |
|
|
959 |
template <typename Graph> |
|
960 |
GraphWriter<Graph> graphWriter(const Graph& graph, const char *fn); |
|
961 |
|
|
962 | 971 |
/// \ingroup lemon_io |
963 | 972 |
/// |
964 | 973 |
/// \brief \ref lgf-format "LGF" writer for directed graphs |
965 | 974 |
/// |
966 | 975 |
/// This utility writes an \ref lgf-format "LGF" file. |
967 | 976 |
/// |
968 | 977 |
/// It can be used almost the same way as \c DigraphWriter. |
969 | 978 |
/// The only difference is that this class can handle edges and |
... | ... |
@@ -1521,47 +1530,16 @@ |
1521 | 1530 |
/// Give back the stream of the writer |
1522 | 1531 |
std::ostream& ostream() { |
1523 | 1532 |
return *_os; |
1524 | 1533 |
} |
1525 | 1534 |
|
1526 | 1535 |
/// @} |
1527 | 1536 |
}; |
1528 | 1537 |
|
1529 |
/// \brief Return a \ref GraphWriter class |
|
1530 |
/// |
|
1531 |
/// This function just returns a \ref GraphWriter class. |
|
1532 |
/// \relates GraphWriter |
|
1533 |
template <typename Graph> |
|
1534 |
GraphWriter<Graph> graphWriter(const Graph& graph, |
|
1535 |
std::ostream& os = std::cout) { |
|
1536 |
GraphWriter<Graph> tmp(graph, os); |
|
1537 |
return tmp; |
|
1538 |
} |
|
1539 |
|
|
1540 |
/// \brief Return a \ref GraphWriter class |
|
1541 |
/// |
|
1542 |
/// This function just returns a \ref GraphWriter class. |
|
1543 |
/// \relates GraphWriter |
|
1544 |
template <typename Graph> |
|
1545 |
GraphWriter<Graph> graphWriter(const Graph& graph, const std::string& fn) { |
|
1546 |
GraphWriter<Graph> tmp(graph, fn); |
|
1547 |
return tmp; |
|
1548 |
} |
|
1549 |
|
|
1550 |
/// \brief Return a \ref GraphWriter class |
|
1551 |
/// |
|
1552 |
/// This function just returns a \ref GraphWriter class. |
|
1553 |
/// \relates GraphWriter |
|
1554 |
template <typename Graph> |
|
1555 |
GraphWriter<Graph> graphWriter(const Graph& graph, const char* fn) { |
|
1556 |
GraphWriter<Graph> tmp(graph, fn); |
|
1557 |
return tmp; |
|
1558 |
} |
|
1559 |
|
|
1560 | 1538 |
class SectionWriter; |
1561 | 1539 |
|
1562 | 1540 |
SectionWriter sectionWriter(std::istream& is); |
1563 | 1541 |
SectionWriter sectionWriter(const std::string& fn); |
1564 | 1542 |
SectionWriter sectionWriter(const char* fn); |
1565 | 1543 |
|
1566 | 1544 |
/// \ingroup lemon_io |
1567 | 1545 |
/// |
... | ... |
@@ -408,17 +408,17 @@ |
408 | 408 |
void changeTarget(Arc a, Node n) { |
409 | 409 |
Parent::changeTarget(a,n); |
410 | 410 |
} |
411 | 411 |
/// Change the source of \c a to \c n |
412 | 412 |
|
413 | 413 |
/// Change the source of \c a to \c n |
414 | 414 |
/// |
415 | 415 |
///\note The <tt>InArcIt</tt>s referencing the changed arc remain |
416 |
///valid. However the <tt>ArcIt<tt>s and <tt>OutArcIt</tt>s are |
|
416 |
///valid. However the <tt>ArcIt</tt>s and <tt>OutArcIt</tt>s are |
|
417 | 417 |
///invalidated. |
418 | 418 |
/// |
419 | 419 |
///\warning This functionality cannot be used together with the Snapshot |
420 | 420 |
///feature. |
421 | 421 |
void changeSource(Arc a, Node n) { |
422 | 422 |
Parent::changeSource(a,n); |
423 | 423 |
} |
424 | 424 |
... | ... |
@@ -38,17 +38,17 @@ |
38 | 38 |
|
39 | 39 |
/// Base class of maps. |
40 | 40 |
|
41 | 41 |
/// Base class of maps. It provides the necessary type definitions |
42 | 42 |
/// required by the map %concepts. |
43 | 43 |
template<typename K, typename V> |
44 | 44 |
class MapBase { |
45 | 45 |
public: |
46 |
/// \ |
|
46 |
/// \brief The key type of the map. |
|
47 | 47 |
typedef K Key; |
48 | 48 |
/// \brief The value type of the map. |
49 | 49 |
/// (The type of objects associated with the keys). |
50 | 50 |
typedef V Value; |
51 | 51 |
}; |
52 | 52 |
|
53 | 53 |
|
54 | 54 |
/// Null map. (a.k.a. DoNothingMap) |
... | ... |
@@ -68,32 +68,32 @@ |
68 | 68 |
typedef typename Parent::Value Value; |
69 | 69 |
|
70 | 70 |
/// Gives back a default constructed element. |
71 | 71 |
Value operator[](const Key&) const { return Value(); } |
72 | 72 |
/// Absorbs the value. |
73 | 73 |
void set(const Key&, const Value&) {} |
74 | 74 |
}; |
75 | 75 |
|
76 |
/// Returns a \ |
|
76 |
/// Returns a \c NullMap class |
|
77 | 77 |
|
78 |
/// This function just returns a \ |
|
78 |
/// This function just returns a \c NullMap class. |
|
79 | 79 |
/// \relates NullMap |
80 | 80 |
template <typename K, typename V> |
81 | 81 |
NullMap<K, V> nullMap() { |
82 | 82 |
return NullMap<K, V>(); |
83 | 83 |
} |
84 | 84 |
|
85 | 85 |
|
86 | 86 |
/// Constant map. |
87 | 87 |
|
88 | 88 |
/// This \ref concepts::ReadMap "readable map" assigns a specified |
89 | 89 |
/// value to each key. |
90 | 90 |
/// |
91 |
/// In other aspects it is equivalent to \ |
|
91 |
/// In other aspects it is equivalent to \c NullMap. |
|
92 | 92 |
/// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap" |
93 | 93 |
/// concept, but it absorbs the data written to it. |
94 | 94 |
/// |
95 | 95 |
/// The simplest way of using this map is through the constMap() |
96 | 96 |
/// function. |
97 | 97 |
/// |
98 | 98 |
/// \sa NullMap |
99 | 99 |
/// \sa IdentityMap |
... | ... |
@@ -128,19 +128,19 @@ |
128 | 128 |
void setAll(const Value &v) { |
129 | 129 |
_value = v; |
130 | 130 |
} |
131 | 131 |
|
132 | 132 |
template<typename V1> |
133 | 133 |
ConstMap(const ConstMap<K, V1> &, const Value &v) : _value(v) {} |
134 | 134 |
}; |
135 | 135 |
|
136 |
/// Returns a \ |
|
136 |
/// Returns a \c ConstMap class |
|
137 | 137 |
|
138 |
/// This function just returns a \ |
|
138 |
/// This function just returns a \c ConstMap class. |
|
139 | 139 |
/// \relates ConstMap |
140 | 140 |
template<typename K, typename V> |
141 | 141 |
inline ConstMap<K, V> constMap(const V &v) { |
142 | 142 |
return ConstMap<K, V>(v); |
143 | 143 |
} |
144 | 144 |
|
145 | 145 |
template<typename K, typename V> |
146 | 146 |
inline ConstMap<K, V> constMap() { |
... | ... |
@@ -151,17 +151,17 @@ |
151 | 151 |
template<typename T, T v> |
152 | 152 |
struct Const {}; |
153 | 153 |
|
154 | 154 |
/// Constant map with inlined constant value. |
155 | 155 |
|
156 | 156 |
/// This \ref concepts::ReadMap "readable map" assigns a specified |
157 | 157 |
/// value to each key. |
158 | 158 |
/// |
159 |
/// In other aspects it is equivalent to \ |
|
159 |
/// In other aspects it is equivalent to \c NullMap. |
|
160 | 160 |
/// So it conforms the \ref concepts::ReadWriteMap "ReadWriteMap" |
161 | 161 |
/// concept, but it absorbs the data written to it. |
162 | 162 |
/// |
163 | 163 |
/// The simplest way of using this map is through the constMap() |
164 | 164 |
/// function. |
165 | 165 |
/// |
166 | 166 |
/// \sa NullMap |
167 | 167 |
/// \sa IdentityMap |
... | ... |
@@ -177,19 +177,19 @@ |
177 | 177 |
|
178 | 178 |
/// Gives back the specified value. |
179 | 179 |
Value operator[](const Key&) const { return v; } |
180 | 180 |
|
181 | 181 |
/// Absorbs the value. |
182 | 182 |
void set(const Key&, const Value&) {} |
183 | 183 |
}; |
184 | 184 |
|
185 |
/// Returns a \ |
|
185 |
/// Returns a \c ConstMap class with inlined constant value |
|
186 | 186 |
|
187 |
/// This function just returns a \ |
|
187 |
/// This function just returns a \c ConstMap class with inlined |
|
188 | 188 |
/// constant value. |
189 | 189 |
/// \relates ConstMap |
190 | 190 |
template<typename K, typename V, V v> |
191 | 191 |
inline ConstMap<K, Const<V, v> > constMap() { |
192 | 192 |
return ConstMap<K, Const<V, v> >(); |
193 | 193 |
} |
194 | 194 |
|
195 | 195 |
|
... | ... |
@@ -207,33 +207,33 @@ |
207 | 207 |
typedef typename Parent::Value Value; |
208 | 208 |
|
209 | 209 |
/// Gives back the given value without any modification. |
210 | 210 |
Value operator[](const Key &k) const { |
211 | 211 |
return k; |
212 | 212 |
} |
213 | 213 |
}; |
214 | 214 |
|
215 |
/// Returns an \ |
|
215 |
/// Returns an \c IdentityMap class |
|
216 | 216 |
|
217 |
/// This function just returns an \ |
|
217 |
/// This function just returns an \c IdentityMap class. |
|
218 | 218 |
/// \relates IdentityMap |
219 | 219 |
template<typename T> |
220 | 220 |
inline IdentityMap<T> identityMap() { |
221 | 221 |
return IdentityMap<T>(); |
222 | 222 |
} |
223 | 223 |
|
224 | 224 |
|
225 | 225 |
/// \brief Map for storing values for integer keys from the range |
226 | 226 |
/// <tt>[0..size-1]</tt>. |
227 | 227 |
/// |
228 | 228 |
/// This map is essentially a wrapper for \c std::vector. It assigns |
229 | 229 |
/// values to integer keys from the range <tt>[0..size-1]</tt>. |
230 | 230 |
/// It can be used with some data structures, for example |
231 |
/// \ |
|
231 |
/// \c UnionFind, \c BinHeap, when the used items are small |
|
232 | 232 |
/// integers. This map conforms the \ref concepts::ReferenceMap |
233 | 233 |
/// "ReferenceMap" concept. |
234 | 234 |
/// |
235 | 235 |
/// The simplest way of using this map is through the rangeMap() |
236 | 236 |
/// function. |
237 | 237 |
template <typename V> |
238 | 238 |
class RangeMap : public MapBase<int, V> { |
239 | 239 |
template <typename V1> |
... | ... |
@@ -263,17 +263,17 @@ |
263 | 263 |
RangeMap(int size = 0, const Value &value = Value()) |
264 | 264 |
: _vector(size, value) {} |
265 | 265 |
|
266 | 266 |
/// Constructs the map from an appropriate \c std::vector. |
267 | 267 |
template <typename V1> |
268 | 268 |
RangeMap(const std::vector<V1>& vector) |
269 | 269 |
: _vector(vector.begin(), vector.end()) {} |
270 | 270 |
|
271 |
/// Constructs the map from another \ |
|
271 |
/// Constructs the map from another \c RangeMap. |
|
272 | 272 |
template <typename V1> |
273 | 273 |
RangeMap(const RangeMap<V1> &c) |
274 | 274 |
: _vector(c._vector.begin(), c._vector.end()) {} |
275 | 275 |
|
276 | 276 |
/// Returns the size of the map. |
277 | 277 |
int size() { |
278 | 278 |
return _vector.size(); |
279 | 279 |
} |
... | ... |
@@ -306,29 +306,29 @@ |
306 | 306 |
} |
307 | 307 |
|
308 | 308 |
///\e |
309 | 309 |
void set(const Key &k, const Value &v) { |
310 | 310 |
_vector[k] = v; |
311 | 311 |
} |
312 | 312 |
}; |
313 | 313 |
|
314 |
/// Returns a \ |
|
314 |
/// Returns a \c RangeMap class |
|
315 | 315 |
|
316 |
/// This function just returns a \ |
|
316 |
/// This function just returns a \c RangeMap class. |
|
317 | 317 |
/// \relates RangeMap |
318 | 318 |
template<typename V> |
319 | 319 |
inline RangeMap<V> rangeMap(int size = 0, const V &value = V()) { |
320 | 320 |
return RangeMap<V>(size, value); |
321 | 321 |
} |
322 | 322 |
|
323 |
/// \brief Returns a \ |
|
323 |
/// \brief Returns a \c RangeMap class created from an appropriate |
|
324 | 324 |
/// \c std::vector |
325 | 325 |
|
326 |
/// This function just returns a \ |
|
326 |
/// This function just returns a \c RangeMap class created from an |
|
327 | 327 |
/// appropriate \c std::vector. |
328 | 328 |
/// \relates RangeMap |
329 | 329 |
template<typename V> |
330 | 330 |
inline RangeMap<V> rangeMap(const std::vector<V> &vector) { |
331 | 331 |
return RangeMap<V>(vector); |
332 | 332 |
} |
333 | 333 |
|
334 | 334 |
|
... | ... |
@@ -383,17 +383,17 @@ |
383 | 383 |
SparseMap(const Value &value = Value()) : _value(value) {} |
384 | 384 |
/// \brief Constructs the map from an appropriate \c std::map, and |
385 | 385 |
/// explicitly specifies a default value. |
386 | 386 |
template <typename V1, typename Comp1> |
387 | 387 |
SparseMap(const std::map<Key, V1, Comp1> &map, |
388 | 388 |
const Value &value = Value()) |
389 | 389 |
: _map(map.begin(), map.end()), _value(value) {} |
390 | 390 |
|
391 |
/// \brief Constructs the map from another \ |
|
391 |
/// \brief Constructs the map from another \c SparseMap. |
|
392 | 392 |
template<typename V1, typename Comp1> |
393 | 393 |
SparseMap(const SparseMap<Key, V1, Comp1> &c) |
394 | 394 |
: _map(c._map.begin(), c._map.end()), _value(c._value) {} |
395 | 395 |
|
396 | 396 |
private: |
397 | 397 |
|
398 | 398 |
SparseMap& operator=(const SparseMap&); |
399 | 399 |
|
... | ... |
@@ -428,35 +428,35 @@ |
428 | 428 |
|
429 | 429 |
///\e |
430 | 430 |
void setAll(const Value &v) { |
431 | 431 |
_value = v; |
432 | 432 |
_map.clear(); |
433 | 433 |
} |
434 | 434 |
}; |
435 | 435 |
|
436 |
/// Returns a \ |
|
436 |
/// Returns a \c SparseMap class |
|
437 | 437 |
|
438 |
/// This function just returns a \ |
|
438 |
/// This function just returns a \c SparseMap class with specified |
|
439 | 439 |
/// default value. |
440 | 440 |
/// \relates SparseMap |
441 | 441 |
template<typename K, typename V, typename Compare> |
442 | 442 |
inline SparseMap<K, V, Compare> sparseMap(const V& value = V()) { |
443 | 443 |
return SparseMap<K, V, Compare>(value); |
444 | 444 |
} |
445 | 445 |
|
446 | 446 |
template<typename K, typename V> |
447 | 447 |
inline SparseMap<K, V, std::less<K> > sparseMap(const V& value = V()) { |
448 | 448 |
return SparseMap<K, V, std::less<K> >(value); |
449 | 449 |
} |
450 | 450 |
|
451 |
/// \brief Returns a \ |
|
451 |
/// \brief Returns a \c SparseMap class created from an appropriate |
|
452 | 452 |
/// \c std::map |
453 | 453 |
|
454 |
/// This function just returns a \ |
|
454 |
/// This function just returns a \c SparseMap class created from an |
|
455 | 455 |
/// appropriate \c std::map. |
456 | 456 |
/// \relates SparseMap |
457 | 457 |
template<typename K, typename V, typename Compare> |
458 | 458 |
inline SparseMap<K, V, Compare> |
459 | 459 |
sparseMap(const std::map<K, V, Compare> &map, const V& value = V()) |
460 | 460 |
{ |
461 | 461 |
return SparseMap<K, V, Compare>(map, value); |
462 | 462 |
} |
... | ... |
@@ -496,19 +496,19 @@ |
496 | 496 |
/// Constructor |
497 | 497 |
ComposeMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} |
498 | 498 |
|
499 | 499 |
/// \e |
500 | 500 |
typename MapTraits<M1>::ConstReturnValue |
501 | 501 |
operator[](const Key &k) const { return _m1[_m2[k]]; } |
502 | 502 |
}; |
503 | 503 |
|
504 |
/// Returns a \ |
|
504 |
/// Returns a \c ComposeMap class |
|
505 | 505 |
|
506 |
/// This function just returns a \ |
|
506 |
/// This function just returns a \c ComposeMap class. |
|
507 | 507 |
/// |
508 | 508 |
/// If \c m1 and \c m2 are maps and the \c Value type of \c m2 is |
509 | 509 |
/// convertible to the \c Key of \c m1, then <tt>composeMap(m1,m2)[x]</tt> |
510 | 510 |
/// will be equal to <tt>m1[m2[x]]</tt>. |
511 | 511 |
/// |
512 | 512 |
/// \relates ComposeMap |
513 | 513 |
template <typename M1, typename M2> |
514 | 514 |
inline ComposeMap<M1, M2> composeMap(const M1 &m1, const M2 &m2) { |
... | ... |
@@ -551,19 +551,19 @@ |
551 | 551 |
|
552 | 552 |
/// Constructor |
553 | 553 |
CombineMap(const M1 &m1, const M2 &m2, const F &f = F()) |
554 | 554 |
: _m1(m1), _m2(m2), _f(f) {} |
555 | 555 |
/// \e |
556 | 556 |
Value operator[](const Key &k) const { return _f(_m1[k],_m2[k]); } |
557 | 557 |
}; |
558 | 558 |
|
559 |
/// Returns a \ |
|
559 |
/// Returns a \c CombineMap class |
|
560 | 560 |
|
561 |
/// This function just returns a \ |
|
561 |
/// This function just returns a \c CombineMap class. |
|
562 | 562 |
/// |
563 | 563 |
/// For example, if \c m1 and \c m2 are both maps with \c double |
564 | 564 |
/// values, then |
565 | 565 |
/// \code |
566 | 566 |
/// combineMap(m1,m2,std::plus<double>()) |
567 | 567 |
/// \endcode |
568 | 568 |
/// is equivalent to |
569 | 569 |
/// \code |
... | ... |
@@ -620,19 +620,19 @@ |
620 | 620 |
typedef typename Parent::Value Value; |
621 | 621 |
|
622 | 622 |
/// Constructor |
623 | 623 |
FunctorToMap(const F &f = F()) : _f(f) {} |
624 | 624 |
/// \e |
625 | 625 |
Value operator[](const Key &k) const { return _f(k); } |
626 | 626 |
}; |
627 | 627 |
|
628 |
/// Returns a \ |
|
628 |
/// Returns a \c FunctorToMap class |
|
629 | 629 |
|
630 |
/// This function just returns a \ |
|
630 |
/// This function just returns a \c FunctorToMap class. |
|
631 | 631 |
/// |
632 | 632 |
/// This function is specialized for adaptable binary function |
633 | 633 |
/// classes and C++ functions. |
634 | 634 |
/// |
635 | 635 |
/// \relates FunctorToMap |
636 | 636 |
template<typename K, typename V, typename F> |
637 | 637 |
inline FunctorToMap<F, K, V> functorToMap(const F &f) { |
638 | 638 |
return FunctorToMap<F, K, V>(f); |
... | ... |
@@ -679,19 +679,19 @@ |
679 | 679 |
/// Constructor |
680 | 680 |
MapToFunctor(const M &m) : _m(m) {} |
681 | 681 |
/// \e |
682 | 682 |
Value operator()(const Key &k) const { return _m[k]; } |
683 | 683 |
/// \e |
684 | 684 |
Value operator[](const Key &k) const { return _m[k]; } |
685 | 685 |
}; |
686 | 686 |
|
687 |
/// Returns a \ |
|
687 |
/// Returns a \c MapToFunctor class |
|
688 | 688 |
|
689 |
/// This function just returns a \ |
|
689 |
/// This function just returns a \c MapToFunctor class. |
|
690 | 690 |
/// \relates MapToFunctor |
691 | 691 |
template<typename M> |
692 | 692 |
inline MapToFunctor<M> mapToFunctor(const M &m) { |
693 | 693 |
return MapToFunctor<M>(m); |
694 | 694 |
} |
695 | 695 |
|
696 | 696 |
|
697 | 697 |
/// \brief Map adaptor to convert the \c Value type of a map to |
... | ... |
@@ -718,19 +718,19 @@ |
718 | 718 |
/// Constructor. |
719 | 719 |
/// \param m The underlying map. |
720 | 720 |
ConvertMap(const M &m) : _m(m) {} |
721 | 721 |
|
722 | 722 |
/// \e |
723 | 723 |
Value operator[](const Key &k) const { return _m[k]; } |
724 | 724 |
}; |
725 | 725 |
|
726 |
/// Returns a \ |
|
726 |
/// Returns a \c ConvertMap class |
|
727 | 727 |
|
728 |
/// This function just returns a \ |
|
728 |
/// This function just returns a \c ConvertMap class. |
|
729 | 729 |
/// \relates ConvertMap |
730 | 730 |
template<typename V, typename M> |
731 | 731 |
inline ConvertMap<M, V> convertMap(const M &map) { |
732 | 732 |
return ConvertMap<M, V>(map); |
733 | 733 |
} |
734 | 734 |
|
735 | 735 |
|
736 | 736 |
/// Applies all map setting operations to two maps |
... | ... |
@@ -758,19 +758,19 @@ |
758 | 758 |
/// Constructor |
759 | 759 |
ForkMap(M1 &m1, M2 &m2) : _m1(m1), _m2(m2) {} |
760 | 760 |
/// Returns the value associated with the given key in the first map. |
761 | 761 |
Value operator[](const Key &k) const { return _m1[k]; } |
762 | 762 |
/// Sets the value associated with the given key in both maps. |
763 | 763 |
void set(const Key &k, const Value &v) { _m1.set(k,v); _m2.set(k,v); } |
764 | 764 |
}; |
765 | 765 |
|
766 |
/// Returns a \ |
|
766 |
/// Returns a \c ForkMap class |
|
767 | 767 |
|
768 |
/// This function just returns a \ |
|
768 |
/// This function just returns a \c ForkMap class. |
|
769 | 769 |
/// \relates ForkMap |
770 | 770 |
template <typename M1, typename M2> |
771 | 771 |
inline ForkMap<M1,M2> forkMap(M1 &m1, M2 &m2) { |
772 | 772 |
return ForkMap<M1,M2>(m1,m2); |
773 | 773 |
} |
774 | 774 |
|
775 | 775 |
|
776 | 776 |
/// Sum of two maps |
... | ... |
@@ -802,19 +802,19 @@ |
802 | 802 |
typedef typename Parent::Value Value; |
803 | 803 |
|
804 | 804 |
/// Constructor |
805 | 805 |
AddMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} |
806 | 806 |
/// \e |
807 | 807 |
Value operator[](const Key &k) const { return _m1[k]+_m2[k]; } |
808 | 808 |
}; |
809 | 809 |
|
810 |
/// Returns an \ |
|
810 |
/// Returns an \c AddMap class |
|
811 | 811 |
|
812 |
/// This function just returns an \ |
|
812 |
/// This function just returns an \c AddMap class. |
|
813 | 813 |
/// |
814 | 814 |
/// For example, if \c m1 and \c m2 are both maps with \c double |
815 | 815 |
/// values, then <tt>addMap(m1,m2)[x]</tt> will be equal to |
816 | 816 |
/// <tt>m1[x]+m2[x]</tt>. |
817 | 817 |
/// |
818 | 818 |
/// \relates AddMap |
819 | 819 |
template<typename M1, typename M2> |
820 | 820 |
inline AddMap<M1, M2> addMap(const M1 &m1, const M2 &m2) { |
... | ... |
@@ -850,19 +850,19 @@ |
850 | 850 |
typedef typename Parent::Value Value; |
851 | 851 |
|
852 | 852 |
/// Constructor |
853 | 853 |
SubMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} |
854 | 854 |
/// \e |
855 | 855 |
Value operator[](const Key &k) const { return _m1[k]-_m2[k]; } |
856 | 856 |
}; |
857 | 857 |
|
858 |
/// Returns a \ |
|
858 |
/// Returns a \c SubMap class |
|
859 | 859 |
|
860 |
/// This function just returns a \ |
|
860 |
/// This function just returns a \c SubMap class. |
|
861 | 861 |
/// |
862 | 862 |
/// For example, if \c m1 and \c m2 are both maps with \c double |
863 | 863 |
/// values, then <tt>subMap(m1,m2)[x]</tt> will be equal to |
864 | 864 |
/// <tt>m1[x]-m2[x]</tt>. |
865 | 865 |
/// |
866 | 866 |
/// \relates SubMap |
867 | 867 |
template<typename M1, typename M2> |
868 | 868 |
inline SubMap<M1, M2> subMap(const M1 &m1, const M2 &m2) { |
... | ... |
@@ -899,19 +899,19 @@ |
899 | 899 |
typedef typename Parent::Value Value; |
900 | 900 |
|
901 | 901 |
/// Constructor |
902 | 902 |
MulMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {} |
903 | 903 |
/// \e |
904 | 904 |
Value operator[](const Key &k) const { return _m1[k]*_m2[k]; } |
905 | 905 |
}; |
906 | 906 |
|
907 |
/// Returns a \ |
|
907 |
/// Returns a \c MulMap class |
|
908 | 908 |
|
909 |
/// This function just returns a \ |
|
909 |
/// This function just returns a \c MulMap class. |
|
910 | 910 |
/// |
911 | 911 |
/// For example, if \c m1 and \c m2 are both maps with \c double |
912 | 912 |
/// values, then <tt>mulMap(m1,m2)[x]</tt> will be equal to |
913 | 913 |
/// <tt>m1[x]*m2[x]</tt>. |
914 | 914 |
/// |
915 | 915 |
/// \relates MulMap |
916 | 916 |
template<typename M1, typename M2> |
917 | 917 |
inline MulMap<M1, M2> mulMap(const M1 &m1,const M2 &m2) { |
... | ... |
@@ -947,19 +947,19 @@ |
947 | 947 |
typedef typename Parent::Value Value; |
948 | 948 |
|
949 | 949 |
/// Constructor |
950 | 950 |
DivMap(const M1 &m1,const M2 &m2) : _m1(m1), _m2(m2) {} |
951 | 951 |
/// \e |
952 | 952 |
Value operator[](const Key &k) const { return _m1[k]/_m2[k]; } |
953 | 953 |
}; |
954 | 954 |
|
955 |
/// Returns a \ |
|
955 |
/// Returns a \c DivMap class |
|
956 | 956 |
|
957 |
/// This function just returns a \ |
|
957 |
/// This function just returns a \c DivMap class. |
|
958 | 958 |
/// |
959 | 959 |
/// For example, if \c m1 and \c m2 are both maps with \c double |
960 | 960 |
/// values, then <tt>divMap(m1,m2)[x]</tt> will be equal to |
961 | 961 |
/// <tt>m1[x]/m2[x]</tt>. |
962 | 962 |
/// |
963 | 963 |
/// \relates DivMap |
964 | 964 |
template<typename M1, typename M2> |
965 | 965 |
inline DivMap<M1, M2> divMap(const M1 &m1,const M2 &m2) { |
... | ... |
@@ -1033,33 +1033,33 @@ |
1033 | 1033 |
/// \param v The constant value. |
1034 | 1034 |
ShiftWriteMap(M &m, const C &v) : _m(m), _v(v) {} |
1035 | 1035 |
/// \e |
1036 | 1036 |
Value operator[](const Key &k) const { return _m[k]+_v; } |
1037 | 1037 |
/// \e |
1038 | 1038 |
void set(const Key &k, const Value &v) { _m.set(k, v-_v); } |
1039 | 1039 |
}; |
1040 | 1040 |
|
1041 |
/// Returns a \ |
|
1041 |
/// Returns a \c ShiftMap class |
|
1042 | 1042 |
|
1043 |
/// This function just returns a \ |
|
1043 |
/// This function just returns a \c ShiftMap class. |
|
1044 | 1044 |
/// |
1045 | 1045 |
/// For example, if \c m is a map with \c double values and \c v is |
1046 | 1046 |
/// \c double, then <tt>shiftMap(m,v)[x]</tt> will be equal to |
1047 | 1047 |
/// <tt>m[x]+v</tt>. |
1048 | 1048 |
/// |
1049 | 1049 |
/// \relates ShiftMap |
1050 | 1050 |
template<typename M, typename C> |
1051 | 1051 |
inline ShiftMap<M, C> shiftMap(const M &m, const C &v) { |
1052 | 1052 |
return ShiftMap<M, C>(m,v); |
1053 | 1053 |
} |
1054 | 1054 |
|
1055 |
/// Returns a \ |
|
1055 |
/// Returns a \c ShiftWriteMap class |
|
1056 | 1056 |
|
1057 |
/// This function just returns a \ |
|
1057 |
/// This function just returns a \c ShiftWriteMap class. |
|
1058 | 1058 |
/// |
1059 | 1059 |
/// For example, if \c m is a map with \c double values and \c v is |
1060 | 1060 |
/// \c double, then <tt>shiftWriteMap(m,v)[x]</tt> will be equal to |
1061 | 1061 |
/// <tt>m[x]+v</tt>. |
1062 | 1062 |
/// Moreover it makes also possible to write the map. |
1063 | 1063 |
/// |
1064 | 1064 |
/// \relates ShiftWriteMap |
1065 | 1065 |
template<typename M, typename C> |
... | ... |
@@ -1135,33 +1135,33 @@ |
1135 | 1135 |
/// \param v The constant value. |
1136 | 1136 |
ScaleWriteMap(M &m, const C &v) : _m(m), _v(v) {} |
1137 | 1137 |
/// \e |
1138 | 1138 |
Value operator[](const Key &k) const { return _v*_m[k]; } |
1139 | 1139 |
/// \e |
1140 | 1140 |
void set(const Key &k, const Value &v) { _m.set(k, v/_v); } |
1141 | 1141 |
}; |
1142 | 1142 |
|
1143 |
/// Returns a \ |
|
1143 |
/// Returns a \c ScaleMap class |
|
1144 | 1144 |
|
1145 |
/// This function just returns a \ |
|
1145 |
/// This function just returns a \c ScaleMap class. |
|
1146 | 1146 |
/// |
1147 | 1147 |
/// For example, if \c m is a map with \c double values and \c v is |
1148 | 1148 |
/// \c double, then <tt>scaleMap(m,v)[x]</tt> will be equal to |
1149 | 1149 |
/// <tt>v*m[x]</tt>. |
1150 | 1150 |
/// |
1151 | 1151 |
/// \relates ScaleMap |
1152 | 1152 |
template<typename M, typename C> |
1153 | 1153 |
inline ScaleMap<M, C> scaleMap(const M &m, const C &v) { |
1154 | 1154 |
return ScaleMap<M, C>(m,v); |
1155 | 1155 |
} |
1156 | 1156 |
|
1157 |
/// Returns a \ |
|
1157 |
/// Returns a \c ScaleWriteMap class |
|
1158 | 1158 |
|
1159 |
/// This function just returns a \ |
|
1159 |
/// This function just returns a \c ScaleWriteMap class. |
|
1160 | 1160 |
/// |
1161 | 1161 |
/// For example, if \c m is a map with \c double values and \c v is |
1162 | 1162 |
/// \c double, then <tt>scaleWriteMap(m,v)[x]</tt> will be equal to |
1163 | 1163 |
/// <tt>v*m[x]</tt>. |
1164 | 1164 |
/// Moreover it makes also possible to write the map. |
1165 | 1165 |
/// |
1166 | 1166 |
/// \relates ScaleWriteMap |
1167 | 1167 |
template<typename M, typename C> |
... | ... |
@@ -1235,32 +1235,32 @@ |
1235 | 1235 |
/// Constructor |
1236 | 1236 |
NegWriteMap(M &m) : _m(m) {} |
1237 | 1237 |
/// \e |
1238 | 1238 |
Value operator[](const Key &k) const { return -_m[k]; } |
1239 | 1239 |
/// \e |
1240 | 1240 |
void set(const Key &k, const Value &v) { _m.set(k, -v); } |
1241 | 1241 |
}; |
1242 | 1242 |
|
1243 |
/// Returns a \ |
|
1243 |
/// Returns a \c NegMap class |
|
1244 | 1244 |
|
1245 |
/// This function just returns a \ |
|
1245 |
/// This function just returns a \c NegMap class. |
|
1246 | 1246 |
/// |
1247 | 1247 |
/// For example, if \c m is a map with \c double values, then |
1248 | 1248 |
/// <tt>negMap(m)[x]</tt> will be equal to <tt>-m[x]</tt>. |
1249 | 1249 |
/// |
1250 | 1250 |
/// \relates NegMap |
1251 | 1251 |
template <typename M> |
1252 | 1252 |
inline NegMap<M> negMap(const M &m) { |
1253 | 1253 |
return NegMap<M>(m); |
1254 | 1254 |
} |
1255 | 1255 |
|
1256 |
/// Returns a \ |
|
1256 |
/// Returns a \c NegWriteMap class |
|
1257 | 1257 |
|
1258 |
/// This function just returns a \ |
|
1258 |
/// This function just returns a \c NegWriteMap class. |
|
1259 | 1259 |
/// |
1260 | 1260 |
/// For example, if \c m is a map with \c double values, then |
1261 | 1261 |
/// <tt>negWriteMap(m)[x]</tt> will be equal to <tt>-m[x]</tt>. |
1262 | 1262 |
/// Moreover it makes also possible to write the map. |
1263 | 1263 |
/// |
1264 | 1264 |
/// \relates NegWriteMap |
1265 | 1265 |
template <typename M> |
1266 | 1266 |
inline NegWriteMap<M> negWriteMap(M &m) { |
... | ... |
@@ -1291,19 +1291,19 @@ |
1291 | 1291 |
/// \e |
1292 | 1292 |
Value operator[](const Key &k) const { |
1293 | 1293 |
Value tmp = _m[k]; |
1294 | 1294 |
return tmp >= 0 ? tmp : -tmp; |
1295 | 1295 |
} |
1296 | 1296 |
|
1297 | 1297 |
}; |
1298 | 1298 |
|
1299 |
/// Returns an \ |
|
1299 |
/// Returns an \c AbsMap class |
|
1300 | 1300 |
|
1301 |
/// This function just returns an \ |
|
1301 |
/// This function just returns an \c AbsMap class. |
|
1302 | 1302 |
/// |
1303 | 1303 |
/// For example, if \c m is a map with \c double values, then |
1304 | 1304 |
/// <tt>absMap(m)[x]</tt> will be equal to <tt>m[x]</tt> if |
1305 | 1305 |
/// it is positive or zero and <tt>-m[x]</tt> if <tt>m[x]</tt> is |
1306 | 1306 |
/// negative. |
1307 | 1307 |
/// |
1308 | 1308 |
/// \relates AbsMap |
1309 | 1309 |
template<typename M> |
... | ... |
@@ -1340,19 +1340,19 @@ |
1340 | 1340 |
typedef MapBase<K, bool> Parent; |
1341 | 1341 |
typedef typename Parent::Key Key; |
1342 | 1342 |
typedef typename Parent::Value Value; |
1343 | 1343 |
|
1344 | 1344 |
/// Gives back \c true. |
1345 | 1345 |
Value operator[](const Key&) const { return true; } |
1346 | 1346 |
}; |
1347 | 1347 |
|
1348 |
/// Returns a \ |
|
1348 |
/// Returns a \c TrueMap class |
|
1349 | 1349 |
|
1350 |
/// This function just returns a \ |
|
1350 |
/// This function just returns a \c TrueMap class. |
|
1351 | 1351 |
/// \relates TrueMap |
1352 | 1352 |
template<typename K> |
1353 | 1353 |
inline TrueMap<K> trueMap() { |
1354 | 1354 |
return TrueMap<K>(); |
1355 | 1355 |
} |
1356 | 1356 |
|
1357 | 1357 |
|
1358 | 1358 |
/// Constant \c false map. |
... | ... |
@@ -1377,19 +1377,19 @@ |
1377 | 1377 |
typedef MapBase<K, bool> Parent; |
1378 | 1378 |
typedef typename Parent::Key Key; |
1379 | 1379 |
typedef typename Parent::Value Value; |
1380 | 1380 |
|
1381 | 1381 |
/// Gives back \c false. |
1382 | 1382 |
Value operator[](const Key&) const { return false; } |
1383 | 1383 |
}; |
1384 | 1384 |
|
1385 |
/// Returns a \ |
|
1385 |
/// Returns a \c FalseMap class |
|
1386 | 1386 |
|
1387 |
/// This function just returns a \ |
|
1387 |
/// This function just returns a \c FalseMap class. |
|
1388 | 1388 |
/// \relates FalseMap |
1389 | 1389 |
template<typename K> |
1390 | 1390 |
inline FalseMap<K> falseMap() { |
1391 | 1391 |
return FalseMap<K>(); |
1392 | 1392 |
} |
1393 | 1393 |
|
1394 | 1394 |
/// @} |
1395 | 1395 |
|
... | ... |
@@ -1424,19 +1424,19 @@ |
1424 | 1424 |
typedef typename Parent::Value Value; |
1425 | 1425 |
|
1426 | 1426 |
/// Constructor |
1427 | 1427 |
AndMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} |
1428 | 1428 |
/// \e |
1429 | 1429 |
Value operator[](const Key &k) const { return _m1[k]&&_m2[k]; } |
1430 | 1430 |
}; |
1431 | 1431 |
|
1432 |
/// Returns an \ |
|
1432 |
/// Returns an \c AndMap class |
|
1433 | 1433 |
|
1434 |
/// This function just returns an \ |
|
1434 |
/// This function just returns an \c AndMap class. |
|
1435 | 1435 |
/// |
1436 | 1436 |
/// For example, if \c m1 and \c m2 are both maps with \c bool values, |
1437 | 1437 |
/// then <tt>andMap(m1,m2)[x]</tt> will be equal to |
1438 | 1438 |
/// <tt>m1[x]&&m2[x]</tt>. |
1439 | 1439 |
/// |
1440 | 1440 |
/// \relates AndMap |
1441 | 1441 |
template<typename M1, typename M2> |
1442 | 1442 |
inline AndMap<M1, M2> andMap(const M1 &m1, const M2 &m2) { |
... | ... |
@@ -1472,19 +1472,19 @@ |
1472 | 1472 |
typedef typename Parent::Value Value; |
1473 | 1473 |
|
1474 | 1474 |
/// Constructor |
1475 | 1475 |
OrMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} |
1476 | 1476 |
/// \e |
1477 | 1477 |
Value operator[](const Key &k) const { return _m1[k]||_m2[k]; } |
1478 | 1478 |
}; |
1479 | 1479 |
|
1480 |
/// Returns an \ |
|
1480 |
/// Returns an \c OrMap class |
|
1481 | 1481 |
|
1482 |
/// This function just returns an \ |
|
1482 |
/// This function just returns an \c OrMap class. |
|
1483 | 1483 |
/// |
1484 | 1484 |
/// For example, if \c m1 and \c m2 are both maps with \c bool values, |
1485 | 1485 |
/// then <tt>orMap(m1,m2)[x]</tt> will be equal to |
1486 | 1486 |
/// <tt>m1[x]||m2[x]</tt>. |
1487 | 1487 |
/// |
1488 | 1488 |
/// \relates OrMap |
1489 | 1489 |
template<typename M1, typename M2> |
1490 | 1490 |
inline OrMap<M1, M2> orMap(const M1 &m1, const M2 &m2) { |
... | ... |
@@ -1539,32 +1539,32 @@ |
1539 | 1539 |
/// Constructor |
1540 | 1540 |
NotWriteMap(M &m) : _m(m) {} |
1541 | 1541 |
/// \e |
1542 | 1542 |
Value operator[](const Key &k) const { return !_m[k]; } |
1543 | 1543 |
/// \e |
1544 | 1544 |
void set(const Key &k, bool v) { _m.set(k, !v); } |
1545 | 1545 |
}; |
1546 | 1546 |
|
1547 |
/// Returns a \ |
|
1547 |
/// Returns a \c NotMap class |
|
1548 | 1548 |
|
1549 |
/// This function just returns a \ |
|
1549 |
/// This function just returns a \c NotMap class. |
|
1550 | 1550 |
/// |
1551 | 1551 |
/// For example, if \c m is a map with \c bool values, then |
1552 | 1552 |
/// <tt>notMap(m)[x]</tt> will be equal to <tt>!m[x]</tt>. |
1553 | 1553 |
/// |
1554 | 1554 |
/// \relates NotMap |
1555 | 1555 |
template <typename M> |
1556 | 1556 |
inline NotMap<M> notMap(const M &m) { |
1557 | 1557 |
return NotMap<M>(m); |
1558 | 1558 |
} |
1559 | 1559 |
|
1560 |
/// Returns a \ |
|
1560 |
/// Returns a \c NotWriteMap class |
|
1561 | 1561 |
|
1562 |
/// This function just returns a \ |
|
1562 |
/// This function just returns a \c NotWriteMap class. |
|
1563 | 1563 |
/// |
1564 | 1564 |
/// For example, if \c m is a map with \c bool values, then |
1565 | 1565 |
/// <tt>notWriteMap(m)[x]</tt> will be equal to <tt>!m[x]</tt>. |
1566 | 1566 |
/// Moreover it makes also possible to write the map. |
1567 | 1567 |
/// |
1568 | 1568 |
/// \relates NotWriteMap |
1569 | 1569 |
template <typename M> |
1570 | 1570 |
inline NotWriteMap<M> notWriteMap(M &m) { |
... | ... |
@@ -1600,19 +1600,19 @@ |
1600 | 1600 |
typedef typename Parent::Value Value; |
1601 | 1601 |
|
1602 | 1602 |
/// Constructor |
1603 | 1603 |
EqualMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} |
1604 | 1604 |
/// \e |
1605 | 1605 |
Value operator[](const Key &k) const { return _m1[k]==_m2[k]; } |
1606 | 1606 |
}; |
1607 | 1607 |
|
1608 |
/// Returns an \ |
|
1608 |
/// Returns an \c EqualMap class |
|
1609 | 1609 |
|
1610 |
/// This function just returns an \ |
|
1610 |
/// This function just returns an \c EqualMap class. |
|
1611 | 1611 |
/// |
1612 | 1612 |
/// For example, if \c m1 and \c m2 are maps with keys and values of |
1613 | 1613 |
/// the same type, then <tt>equalMap(m1,m2)[x]</tt> will be equal to |
1614 | 1614 |
/// <tt>m1[x]==m2[x]</tt>. |
1615 | 1615 |
/// |
1616 | 1616 |
/// \relates EqualMap |
1617 | 1617 |
template<typename M1, typename M2> |
1618 | 1618 |
inline EqualMap<M1, M2> equalMap(const M1 &m1, const M2 &m2) { |
... | ... |
@@ -1648,19 +1648,19 @@ |
1648 | 1648 |
typedef typename Parent::Value Value; |
1649 | 1649 |
|
1650 | 1650 |
/// Constructor |
1651 | 1651 |
LessMap(const M1 &m1, const M2 &m2) : _m1(m1), _m2(m2) {} |
1652 | 1652 |
/// \e |
1653 | 1653 |
Value operator[](const Key &k) const { return _m1[k]<_m2[k]; } |
1654 | 1654 |
}; |
1655 | 1655 |
|
1656 |
/// Returns an \ |
|
1656 |
/// Returns an \c LessMap class |
|
1657 | 1657 |
|
1658 |
/// This function just returns an \ |
|
1658 |
/// This function just returns an \c LessMap class. |
|
1659 | 1659 |
/// |
1660 | 1660 |
/// For example, if \c m1 and \c m2 are maps with keys and values of |
1661 | 1661 |
/// the same type, then <tt>lessMap(m1,m2)[x]</tt> will be equal to |
1662 | 1662 |
/// <tt>m1[x]<m2[x]</tt>. |
1663 | 1663 |
/// |
1664 | 1664 |
/// \relates LessMap |
1665 | 1665 |
template<typename M1, typename M2> |
1666 | 1666 |
inline LessMap<M1, M2> lessMap(const M1 &m1, const M2 &m2) { |
... | ... |
@@ -1678,16 +1678,21 @@ |
1678 | 1678 |
struct IteratorTraits<_Iterator, |
1679 | 1679 |
typename exists<typename _Iterator::container_type>::type> |
1680 | 1680 |
{ |
1681 | 1681 |
typedef typename _Iterator::container_type::value_type Value; |
1682 | 1682 |
}; |
1683 | 1683 |
|
1684 | 1684 |
} |
1685 | 1685 |
|
1686 |
/// @} |
|
1687 |
|
|
1688 |
/// \addtogroup maps |
|
1689 |
/// @{ |
|
1690 |
|
|
1686 | 1691 |
/// \brief Writable bool map for logging each \c true assigned element |
1687 | 1692 |
/// |
1688 | 1693 |
/// A \ref concepts::WriteMap "writable" bool map for logging |
1689 | 1694 |
/// each \c true assigned element, i.e it copies subsequently each |
1690 | 1695 |
/// keys set to \c true to the given iterator. |
1691 | 1696 |
/// The most important usage of it is storing certain nodes or arcs |
1692 | 1697 |
/// that were marked \c true by an algorithm. |
1693 | 1698 |
/// |
... | ... |
@@ -1740,19 +1745,19 @@ |
1740 | 1745 |
} |
1741 | 1746 |
} |
1742 | 1747 |
|
1743 | 1748 |
private: |
1744 | 1749 |
Iterator _begin; |
1745 | 1750 |
Iterator _end; |
1746 | 1751 |
}; |
1747 | 1752 |
|
1748 |
/// Returns a \ |
|
1753 |
/// Returns a \c LoggerBoolMap class |
|
1749 | 1754 |
|
1750 |
/// This function just returns a \ |
|
1755 |
/// This function just returns a \c LoggerBoolMap class. |
|
1751 | 1756 |
/// |
1752 | 1757 |
/// The most important usage of it is storing certain nodes or arcs |
1753 | 1758 |
/// that were marked \c true by an algorithm. |
1754 | 1759 |
/// For example it makes easier to store the nodes in the processing |
1755 | 1760 |
/// order of Dfs algorithm, as the following examples show. |
1756 | 1761 |
/// \code |
1757 | 1762 |
/// std::vector<Node> v; |
1758 | 1763 |
/// dfs(g,s).processedMap(loggerBoolMap(std::back_inserter(v))).run(); |
... | ... |
@@ -1762,24 +1767,29 @@ |
1762 | 1767 |
/// dfs(g,s).processedMap(loggerBoolMap(v.begin())).run(); |
1763 | 1768 |
/// \endcode |
1764 | 1769 |
/// |
1765 | 1770 |
/// \note The container of the iterator must contain enough space |
1766 | 1771 |
/// for the elements or the iterator should be an inserter iterator. |
1767 | 1772 |
/// |
1768 | 1773 |
/// \note LoggerBoolMap is just \ref concepts::WriteMap "writable", so |
1769 | 1774 |
/// it cannot be used when a readable map is needed, for example as |
1770 |
/// \c ReachedMap for \ |
|
1775 |
/// \c ReachedMap for \c Bfs, \c Dfs and \c Dijkstra algorithms. |
|
1771 | 1776 |
/// |
1772 | 1777 |
/// \relates LoggerBoolMap |
1773 | 1778 |
template<typename Iterator> |
1774 | 1779 |
inline LoggerBoolMap<Iterator> loggerBoolMap(Iterator it) { |
1775 | 1780 |
return LoggerBoolMap<Iterator>(it); |
1776 | 1781 |
} |
1777 | 1782 |
|
1783 |
/// @} |
|
1784 |
|
|
1785 |
/// \addtogroup graph_maps |
|
1786 |
/// @{ |
|
1787 |
|
|
1778 | 1788 |
/// Provides an immutable and unique id for each item in the graph. |
1779 | 1789 |
|
1780 | 1790 |
/// The IdMap class provides a unique and immutable id for each item of the |
1781 | 1791 |
/// same type (e.g. node) in the graph. This id is <ul><li>\b unique: |
1782 | 1792 |
/// different items (nodes) get different ids <li>\b immutable: the id of an |
1783 | 1793 |
/// item (node) does not change (even if you delete other nodes). </ul> |
1784 | 1794 |
/// Through this map you get access (i.e. can read) the inner id values of |
1785 | 1795 |
/// the items stored in the graph. This map can be inverted with its member |
... | ... |
@@ -1856,35 +1866,35 @@ |
1856 | 1866 |
public: |
1857 | 1867 |
|
1858 | 1868 |
typedef typename Digraph::Node Value; |
1859 | 1869 |
typedef typename Digraph::Arc Key; |
1860 | 1870 |
|
1861 | 1871 |
/// \brief Constructor |
1862 | 1872 |
/// |
1863 | 1873 |
/// Constructor |
1864 |
/// \param |
|
1874 |
/// \param digraph The digraph that the map belongs to. |
|
1865 | 1875 |
explicit SourceMap(const Digraph& digraph) : _digraph(digraph) {} |
1866 | 1876 |
|
1867 | 1877 |
/// \brief The subscript operator. |
1868 | 1878 |
/// |
1869 | 1879 |
/// The subscript operator. |
1870 | 1880 |
/// \param arc The arc |
1871 | 1881 |
/// \return The source of the arc |
1872 | 1882 |
Value operator[](const Key& arc) const { |
1873 | 1883 |
return _digraph.source(arc); |
1874 | 1884 |
} |
1875 | 1885 |
|
1876 | 1886 |
private: |
1877 | 1887 |
const Digraph& _digraph; |
1878 | 1888 |
}; |
1879 | 1889 |
|
1880 |
/// \brief Returns a \ |
|
1890 |
/// \brief Returns a \c SourceMap class. |
|
1881 | 1891 |
/// |
1882 |
/// This function just returns an \ |
|
1892 |
/// This function just returns an \c SourceMap class. |
|
1883 | 1893 |
/// \relates SourceMap |
1884 | 1894 |
template <typename Digraph> |
1885 | 1895 |
inline SourceMap<Digraph> sourceMap(const Digraph& digraph) { |
1886 | 1896 |
return SourceMap<Digraph>(digraph); |
1887 | 1897 |
} |
1888 | 1898 |
|
1889 | 1899 |
/// \brief Returns the target of the given arc. |
1890 | 1900 |
/// |
... | ... |
@@ -1895,35 +1905,35 @@ |
1895 | 1905 |
public: |
1896 | 1906 |
|
1897 | 1907 |
typedef typename Digraph::Node Value; |
1898 | 1908 |
typedef typename Digraph::Arc Key; |
1899 | 1909 |
|
1900 | 1910 |
/// \brief Constructor |
1901 | 1911 |
/// |
1902 | 1912 |
/// Constructor |
1903 |
/// \param |
|
1913 |
/// \param digraph The digraph that the map belongs to. |
|
1904 | 1914 |
explicit TargetMap(const Digraph& digraph) : _digraph(digraph) {} |
1905 | 1915 |
|
1906 | 1916 |
/// \brief The subscript operator. |
1907 | 1917 |
/// |
1908 | 1918 |
/// The subscript operator. |
1909 | 1919 |
/// \param e The arc |
1910 | 1920 |
/// \return The target of the arc |
1911 | 1921 |
Value operator[](const Key& e) const { |
1912 | 1922 |
return _digraph.target(e); |
1913 | 1923 |
} |
1914 | 1924 |
|
1915 | 1925 |
private: |
1916 | 1926 |
const Digraph& _digraph; |
1917 | 1927 |
}; |
1918 | 1928 |
|
1919 |
/// \brief Returns a \ |
|
1929 |
/// \brief Returns a \c TargetMap class. |
|
1920 | 1930 |
/// |
1921 |
/// This function just returns a \ |
|
1931 |
/// This function just returns a \c TargetMap class. |
|
1922 | 1932 |
/// \relates TargetMap |
1923 | 1933 |
template <typename Digraph> |
1924 | 1934 |
inline TargetMap<Digraph> targetMap(const Digraph& digraph) { |
1925 | 1935 |
return TargetMap<Digraph>(digraph); |
1926 | 1936 |
} |
1927 | 1937 |
|
1928 | 1938 |
/// \brief Returns the "forward" directed arc view of an edge. |
1929 | 1939 |
/// |
... | ... |
@@ -1934,35 +1944,35 @@ |
1934 | 1944 |
public: |
1935 | 1945 |
|
1936 | 1946 |
typedef typename Graph::Arc Value; |
1937 | 1947 |
typedef typename Graph::Edge Key; |
1938 | 1948 |
|
1939 | 1949 |
/// \brief Constructor |
1940 | 1950 |
/// |
1941 | 1951 |
/// Constructor |
1942 |
/// \param |
|
1952 |
/// \param graph The graph that the map belongs to. |
|
1943 | 1953 |
explicit ForwardMap(const Graph& graph) : _graph(graph) {} |
1944 | 1954 |
|
1945 | 1955 |
/// \brief The subscript operator. |
1946 | 1956 |
/// |
1947 | 1957 |
/// The subscript operator. |
1948 | 1958 |
/// \param key An edge |
1949 | 1959 |
/// \return The "forward" directed arc view of edge |
1950 | 1960 |
Value operator[](const Key& key) const { |
1951 | 1961 |
return _graph.direct(key, true); |
1952 | 1962 |
} |
1953 | 1963 |
|
1954 | 1964 |
private: |
1955 | 1965 |
const Graph& _graph; |
1956 | 1966 |
}; |
1957 | 1967 |
|
1958 |
/// \brief Returns a \ |
|
1968 |
/// \brief Returns a \c ForwardMap class. |
|
1959 | 1969 |
/// |
1960 |
/// This function just returns an \ |
|
1970 |
/// This function just returns an \c ForwardMap class. |
|
1961 | 1971 |
/// \relates ForwardMap |
1962 | 1972 |
template <typename Graph> |
1963 | 1973 |
inline ForwardMap<Graph> forwardMap(const Graph& graph) { |
1964 | 1974 |
return ForwardMap<Graph>(graph); |
1965 | 1975 |
} |
1966 | 1976 |
|
1967 | 1977 |
/// \brief Returns the "backward" directed arc view of an edge. |
1968 | 1978 |
/// |
... | ... |
@@ -1973,35 +1983,35 @@ |
1973 | 1983 |
public: |
1974 | 1984 |
|
1975 | 1985 |
typedef typename Graph::Arc Value; |
1976 | 1986 |
typedef typename Graph::Edge Key; |
1977 | 1987 |
|
1978 | 1988 |
/// \brief Constructor |
1979 | 1989 |
/// |
1980 | 1990 |
/// Constructor |
1981 |
/// \param |
|
1991 |
/// \param graph The graph that the map belongs to. |
|
1982 | 1992 |
explicit BackwardMap(const Graph& graph) : _graph(graph) {} |
1983 | 1993 |
|
1984 | 1994 |
/// \brief The subscript operator. |
1985 | 1995 |
/// |
1986 | 1996 |
/// The subscript operator. |
1987 | 1997 |
/// \param key An edge |
1988 | 1998 |
/// \return The "backward" directed arc view of edge |
1989 | 1999 |
Value operator[](const Key& key) const { |
1990 | 2000 |
return _graph.direct(key, false); |
1991 | 2001 |
} |
1992 | 2002 |
|
1993 | 2003 |
private: |
1994 | 2004 |
const Graph& _graph; |
1995 | 2005 |
}; |
1996 | 2006 |
|
1997 |
/// \brief Returns a \ |
|
2007 |
/// \brief Returns a \c BackwardMap class |
|
1998 | 2008 |
|
1999 |
/// This function just returns a \ |
|
2009 |
/// This function just returns a \c BackwardMap class. |
|
2000 | 2010 |
/// \relates BackwardMap |
2001 | 2011 |
template <typename Graph> |
2002 | 2012 |
inline BackwardMap<Graph> backwardMap(const Graph& graph) { |
2003 | 2013 |
return BackwardMap<Graph>(graph); |
2004 | 2014 |
} |
2005 | 2015 |
|
2006 | 2016 |
/// \brief Potential difference map |
2007 | 2017 |
/// |
... | ... |
@@ -844,17 +844,17 @@ |
844 | 844 |
} |
845 | 845 |
|
846 | 846 |
/// \brief The length of the path. |
847 | 847 |
int length() const { return len; } |
848 | 848 |
|
849 | 849 |
/// \brief Return true when the path is empty. |
850 | 850 |
int empty() const { return len == 0; } |
851 | 851 |
|
852 |
/// \ |
|
852 |
/// \brief Erase all arcs in the digraph. |
|
853 | 853 |
void clear() { |
854 | 854 |
len = 0; |
855 | 855 |
if (arcs) delete[] arcs; |
856 | 856 |
arcs = 0; |
857 | 857 |
} |
858 | 858 |
|
859 | 859 |
/// \brief The first arc of the path. |
860 | 860 |
const Arc& front() const { |
... | ... |
@@ -360,29 +360,29 @@ |
360 | 360 |
|
361 | 361 |
///Default constructor. |
362 | 362 |
///To actually make a snapshot you must call save(). |
363 | 363 |
/// |
364 | 364 |
Snapshot() : _graph(0) {} |
365 | 365 |
///Constructor that immediately makes a snapshot |
366 | 366 |
|
367 | 367 |
///This constructor immediately makes a snapshot of the digraph. |
368 |
///\param |
|
368 |
///\param graph The digraph we make a snapshot of. |
|
369 | 369 |
Snapshot(SmartDigraph &graph) : _graph(&graph) { |
370 | 370 |
node_num=_graph->nodes.size(); |
371 | 371 |
arc_num=_graph->arcs.size(); |
372 | 372 |
} |
373 | 373 |
|
374 | 374 |
///Make a snapshot. |
375 | 375 |
|
376 | 376 |
///Make a snapshot of the digraph. |
377 | 377 |
/// |
378 | 378 |
///This function can be called more than once. In case of a repeated |
379 | 379 |
///call, the previous snapshot gets lost. |
380 |
///\param |
|
380 |
///\param graph The digraph we make the snapshot of. |
|
381 | 381 |
void save(SmartDigraph &graph) |
382 | 382 |
{ |
383 | 383 |
_graph=&graph; |
384 | 384 |
node_num=_graph->nodes.size(); |
385 | 385 |
arc_num=_graph->arcs.size(); |
386 | 386 |
} |
387 | 387 |
|
388 | 388 |
///Undo the changes until a snapshot. |
... | ... |
@@ -770,28 +770,28 @@ |
770 | 770 |
|
771 | 771 |
///Default constructor. |
772 | 772 |
///To actually make a snapshot you must call save(). |
773 | 773 |
/// |
774 | 774 |
Snapshot() : _graph(0) {} |
775 | 775 |
///Constructor that immediately makes a snapshot |
776 | 776 |
|
777 | 777 |
///This constructor immediately makes a snapshot of the digraph. |
778 |
///\param |
|
778 |
///\param graph The digraph we make a snapshot of. |
|
779 | 779 |
Snapshot(SmartGraph &graph) { |
780 | 780 |
graph.saveSnapshot(*this); |
781 | 781 |
} |
782 | 782 |
|
783 | 783 |
///Make a snapshot. |
784 | 784 |
|
785 | 785 |
///Make a snapshot of the graph. |
786 | 786 |
/// |
787 | 787 |
///This function can be called more than once. In case of a repeated |
788 | 788 |
///call, the previous snapshot gets lost. |
789 |
///\param |
|
789 |
///\param graph The digraph we make the snapshot of. |
|
790 | 790 |
void save(SmartGraph &graph) |
791 | 791 |
{ |
792 | 792 |
graph.saveSnapshot(*this); |
793 | 793 |
} |
794 | 794 |
|
795 | 795 |
///Undo the changes until a snapshot. |
796 | 796 |
|
797 | 797 |
///Undo the changes until a snapshot created by save(). |
... | ... |
@@ -306,22 +306,21 @@ |
306 | 306 |
|
307 | 307 |
///\param run indicates whether or not the timer starts immediately. |
308 | 308 |
/// |
309 | 309 |
Timer(bool run=true) :_running(run) {_reset();} |
310 | 310 |
|
311 | 311 |
///\name Control the state of the timer |
312 | 312 |
///Basically a Timer can be either running or stopped, |
313 | 313 |
///but it provides a bit finer control on the execution. |
314 |
///The \ref Timer also counts the number of \ref start() |
|
315 |
///executions, and is stops only after the same amount (or more) |
|
316 |
///\ref stop() "stop()"s. This can be useful e.g. to compute |
|
317 |
///the running time |
|
314 |
///The \ref lemon::Timer "Timer" also counts the number of |
|
315 |
///\ref lemon::Timer::start() "start()" executions, and it stops |
|
316 |
///only after the same amount (or more) \ref lemon::Timer::stop() |
|
317 |
///"stop()"s. This can be useful e.g. to compute the running time |
|
318 | 318 |
///of recursive functions. |
319 |
/// |
|
320 | 319 |
|
321 | 320 |
///@{ |
322 | 321 |
|
323 | 322 |
///Reset and stop the time counters |
324 | 323 |
|
325 | 324 |
///This function resets and stops the time counters |
326 | 325 |
///\sa restart() |
327 | 326 |
void reset() |
... | ... |
@@ -467,17 +466,17 @@ |
467 | 466 |
t.stamp(); |
468 | 467 |
return _running?t-start_time:start_time; |
469 | 468 |
} |
470 | 469 |
|
471 | 470 |
|
472 | 471 |
///@} |
473 | 472 |
}; |
474 | 473 |
|
475 |
///Same as |
|
474 |
///Same as Timer but prints a report on destruction. |
|
476 | 475 |
|
477 | 476 |
///Same as \ref Timer but prints a report on destruction. |
478 | 477 |
///This example shows its usage. |
479 | 478 |
///\code |
480 | 479 |
/// void myAlg(ListGraph &g,int n) |
481 | 480 |
/// { |
482 | 481 |
/// TimeReport tr("Running time of myAlg: "); |
483 | 482 |
/// ... //Here comes the algorithm |
... | ... |
@@ -486,32 +485,32 @@ |
486 | 485 |
/// |
487 | 486 |
///\sa Timer |
488 | 487 |
///\sa NoTimeReport |
489 | 488 |
class TimeReport : public Timer |
490 | 489 |
{ |
491 | 490 |
std::string _title; |
492 | 491 |
std::ostream &_os; |
493 | 492 |
public: |
494 |
/// |
|
493 |
///Constructor |
|
495 | 494 |
|
495 |
///Constructor. |
|
496 | 496 |
///\param title This text will be printed before the ellapsed time. |
497 | 497 |
///\param os The stream to print the report to. |
498 | 498 |
///\param run Sets whether the timer should start immediately. |
499 |
|
|
500 | 499 |
TimeReport(std::string title,std::ostream &os=std::cerr,bool run=true) |
501 | 500 |
: Timer(run), _title(title), _os(os){} |
502 |
/// |
|
501 |
///Destructor that prints the ellapsed time |
|
503 | 502 |
~TimeReport() |
504 | 503 |
{ |
505 | 504 |
_os << _title << *this << std::endl; |
506 | 505 |
} |
507 | 506 |
}; |
508 | 507 |
|
509 |
///'Do nothing' version of |
|
508 |
///'Do nothing' version of TimeReport |
|
510 | 509 |
|
511 | 510 |
///\sa TimeReport |
512 | 511 |
/// |
513 | 512 |
class NoTimeReport |
514 | 513 |
{ |
515 | 514 |
public: |
516 | 515 |
///\e |
517 | 516 |
NoTimeReport(std::string,std::ostream &,bool) {} |
0 comments (0 inline)