lemongraph 0.0.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +7 -0
- data/.yardopts +8 -0
- data/LICENSE +674 -0
- data/README.md +6 -0
- data/ext/lemon-1.3.1/AUTHORS +26 -0
- data/ext/lemon-1.3.1/CMakeLists.txt +371 -0
- data/ext/lemon-1.3.1/INSTALL +167 -0
- data/ext/lemon-1.3.1/LICENSE +32 -0
- data/ext/lemon-1.3.1/NEWS +337 -0
- data/ext/lemon-1.3.1/README +50 -0
- data/ext/lemon-1.3.1/cmake/FindCOIN.cmake +110 -0
- data/ext/lemon-1.3.1/cmake/FindGLPK.cmake +55 -0
- data/ext/lemon-1.3.1/cmake/FindGhostscript.cmake +10 -0
- data/ext/lemon-1.3.1/cmake/FindILOG.cmake +102 -0
- data/ext/lemon-1.3.1/cmake/FindSOPLEX.cmake +23 -0
- data/ext/lemon-1.3.1/cmake/LEMONConfig.cmake.in +13 -0
- data/ext/lemon-1.3.1/cmake/nsis/lemon.ico +0 -0
- data/ext/lemon-1.3.1/cmake/nsis/uninstall.ico +0 -0
- data/ext/lemon-1.3.1/cmake/version.cmake +1 -0
- data/ext/lemon-1.3.1/cmake/version.cmake.in +1 -0
- data/ext/lemon-1.3.1/contrib/CMakeLists.txt +19 -0
- data/ext/lemon-1.3.1/lemon/CMakeLists.txt +91 -0
- data/ext/lemon-1.3.1/lemon/adaptors.h +3638 -0
- data/ext/lemon-1.3.1/lemon/arg_parser.cc +474 -0
- data/ext/lemon-1.3.1/lemon/arg_parser.h +440 -0
- data/ext/lemon-1.3.1/lemon/assert.h +214 -0
- data/ext/lemon-1.3.1/lemon/base.cc +37 -0
- data/ext/lemon-1.3.1/lemon/bellman_ford.h +1116 -0
- data/ext/lemon-1.3.1/lemon/bfs.h +1754 -0
- data/ext/lemon-1.3.1/lemon/bin_heap.h +347 -0
- data/ext/lemon-1.3.1/lemon/binomial_heap.h +445 -0
- data/ext/lemon-1.3.1/lemon/bits/alteration_notifier.h +472 -0
- data/ext/lemon-1.3.1/lemon/bits/array_map.h +351 -0
- data/ext/lemon-1.3.1/lemon/bits/bezier.h +174 -0
- data/ext/lemon-1.3.1/lemon/bits/default_map.h +182 -0
- data/ext/lemon-1.3.1/lemon/bits/edge_set_extender.h +627 -0
- data/ext/lemon-1.3.1/lemon/bits/enable_if.h +131 -0
- data/ext/lemon-1.3.1/lemon/bits/graph_adaptor_extender.h +401 -0
- data/ext/lemon-1.3.1/lemon/bits/graph_extender.h +1332 -0
- data/ext/lemon-1.3.1/lemon/bits/lock.h +65 -0
- data/ext/lemon-1.3.1/lemon/bits/map_extender.h +332 -0
- data/ext/lemon-1.3.1/lemon/bits/path_dump.h +177 -0
- data/ext/lemon-1.3.1/lemon/bits/solver_bits.h +194 -0
- data/ext/lemon-1.3.1/lemon/bits/traits.h +388 -0
- data/ext/lemon-1.3.1/lemon/bits/variant.h +494 -0
- data/ext/lemon-1.3.1/lemon/bits/vector_map.h +244 -0
- data/ext/lemon-1.3.1/lemon/bits/windows.cc +166 -0
- data/ext/lemon-1.3.1/lemon/bits/windows.h +44 -0
- data/ext/lemon-1.3.1/lemon/bucket_heap.h +594 -0
- data/ext/lemon-1.3.1/lemon/capacity_scaling.h +1014 -0
- data/ext/lemon-1.3.1/lemon/cbc.cc +460 -0
- data/ext/lemon-1.3.1/lemon/cbc.h +129 -0
- data/ext/lemon-1.3.1/lemon/christofides_tsp.h +254 -0
- data/ext/lemon-1.3.1/lemon/circulation.h +807 -0
- data/ext/lemon-1.3.1/lemon/clp.cc +464 -0
- data/ext/lemon-1.3.1/lemon/clp.h +164 -0
- data/ext/lemon-1.3.1/lemon/color.cc +44 -0
- data/ext/lemon-1.3.1/lemon/color.h +204 -0
- data/ext/lemon-1.3.1/lemon/concept_check.h +77 -0
- data/ext/lemon-1.3.1/lemon/concepts/bpgraph.h +1029 -0
- data/ext/lemon-1.3.1/lemon/concepts/digraph.h +491 -0
- data/ext/lemon-1.3.1/lemon/concepts/graph.h +788 -0
- data/ext/lemon-1.3.1/lemon/concepts/graph_components.h +2134 -0
- data/ext/lemon-1.3.1/lemon/concepts/heap.h +324 -0
- data/ext/lemon-1.3.1/lemon/concepts/maps.h +223 -0
- data/ext/lemon-1.3.1/lemon/concepts/path.h +312 -0
- data/ext/lemon-1.3.1/lemon/config.h.in +22 -0
- data/ext/lemon-1.3.1/lemon/connectivity.h +1688 -0
- data/ext/lemon-1.3.1/lemon/core.h +2506 -0
- data/ext/lemon-1.3.1/lemon/cost_scaling.h +1607 -0
- data/ext/lemon-1.3.1/lemon/counter.h +249 -0
- data/ext/lemon-1.3.1/lemon/cplex.cc +994 -0
- data/ext/lemon-1.3.1/lemon/cplex.h +292 -0
- data/ext/lemon-1.3.1/lemon/cycle_canceling.h +1230 -0
- data/ext/lemon-1.3.1/lemon/dfs.h +1637 -0
- data/ext/lemon-1.3.1/lemon/dheap.h +352 -0
- data/ext/lemon-1.3.1/lemon/dijkstra.h +1303 -0
- data/ext/lemon-1.3.1/lemon/dim2.h +726 -0
- data/ext/lemon-1.3.1/lemon/dimacs.h +448 -0
- data/ext/lemon-1.3.1/lemon/edge_set.h +1420 -0
- data/ext/lemon-1.3.1/lemon/edmonds_karp.h +556 -0
- data/ext/lemon-1.3.1/lemon/elevator.h +982 -0
- data/ext/lemon-1.3.1/lemon/error.h +276 -0
- data/ext/lemon-1.3.1/lemon/euler.h +287 -0
- data/ext/lemon-1.3.1/lemon/fib_heap.h +475 -0
- data/ext/lemon-1.3.1/lemon/fractional_matching.h +2139 -0
- data/ext/lemon-1.3.1/lemon/full_graph.h +1082 -0
- data/ext/lemon-1.3.1/lemon/glpk.cc +1012 -0
- data/ext/lemon-1.3.1/lemon/glpk.h +263 -0
- data/ext/lemon-1.3.1/lemon/gomory_hu.h +568 -0
- data/ext/lemon-1.3.1/lemon/graph_to_eps.h +1186 -0
- data/ext/lemon-1.3.1/lemon/greedy_tsp.h +251 -0
- data/ext/lemon-1.3.1/lemon/grid_graph.h +699 -0
- data/ext/lemon-1.3.1/lemon/grosso_locatelli_pullan_mc.h +840 -0
- data/ext/lemon-1.3.1/lemon/hao_orlin.h +1015 -0
- data/ext/lemon-1.3.1/lemon/hartmann_orlin_mmc.h +654 -0
- data/ext/lemon-1.3.1/lemon/howard_mmc.h +651 -0
- data/ext/lemon-1.3.1/lemon/hypercube_graph.h +459 -0
- data/ext/lemon-1.3.1/lemon/insertion_tsp.h +533 -0
- data/ext/lemon-1.3.1/lemon/karp_mmc.h +590 -0
- data/ext/lemon-1.3.1/lemon/kruskal.h +324 -0
- data/ext/lemon-1.3.1/lemon/lemon.pc.in +10 -0
- data/ext/lemon-1.3.1/lemon/lgf_reader.h +3854 -0
- data/ext/lemon-1.3.1/lemon/lgf_writer.h +2687 -0
- data/ext/lemon-1.3.1/lemon/list_graph.h +2510 -0
- data/ext/lemon-1.3.1/lemon/lp.h +95 -0
- data/ext/lemon-1.3.1/lemon/lp_base.cc +30 -0
- data/ext/lemon-1.3.1/lemon/lp_base.h +2147 -0
- data/ext/lemon-1.3.1/lemon/lp_skeleton.cc +143 -0
- data/ext/lemon-1.3.1/lemon/lp_skeleton.h +234 -0
- data/ext/lemon-1.3.1/lemon/maps.h +4057 -0
- data/ext/lemon-1.3.1/lemon/matching.h +3505 -0
- data/ext/lemon-1.3.1/lemon/math.h +77 -0
- data/ext/lemon-1.3.1/lemon/max_cardinality_search.h +794 -0
- data/ext/lemon-1.3.1/lemon/min_cost_arborescence.h +808 -0
- data/ext/lemon-1.3.1/lemon/nagamochi_ibaraki.h +702 -0
- data/ext/lemon-1.3.1/lemon/nauty_reader.h +113 -0
- data/ext/lemon-1.3.1/lemon/nearest_neighbor_tsp.h +238 -0
- data/ext/lemon-1.3.1/lemon/network_simplex.h +1659 -0
- data/ext/lemon-1.3.1/lemon/opt2_tsp.h +367 -0
- data/ext/lemon-1.3.1/lemon/pairing_heap.h +474 -0
- data/ext/lemon-1.3.1/lemon/path.h +1164 -0
- data/ext/lemon-1.3.1/lemon/planarity.h +2754 -0
- data/ext/lemon-1.3.1/lemon/preflow.h +985 -0
- data/ext/lemon-1.3.1/lemon/quad_heap.h +343 -0
- data/ext/lemon-1.3.1/lemon/radix_heap.h +438 -0
- data/ext/lemon-1.3.1/lemon/radix_sort.h +487 -0
- data/ext/lemon-1.3.1/lemon/random.cc +29 -0
- data/ext/lemon-1.3.1/lemon/random.h +1005 -0
- data/ext/lemon-1.3.1/lemon/smart_graph.h +1344 -0
- data/ext/lemon-1.3.1/lemon/soplex.cc +465 -0
- data/ext/lemon-1.3.1/lemon/soplex.h +158 -0
- data/ext/lemon-1.3.1/lemon/static_graph.h +476 -0
- data/ext/lemon-1.3.1/lemon/suurballe.h +776 -0
- data/ext/lemon-1.3.1/lemon/time_measure.h +610 -0
- data/ext/lemon-1.3.1/lemon/tolerance.h +242 -0
- data/ext/lemon-1.3.1/lemon/unionfind.h +1824 -0
- data/ext/lemon-1.3.1/scripts/unify-sources.sh +390 -0
- data/ext/lemon-1.3.1/scripts/valgrind-wrapper.sh +22 -0
- data/ext/lemongraph/arc_map.cc +1007 -0
- data/ext/lemongraph/digraph.cc +282 -0
- data/ext/lemongraph/digraph_arc.cc +153 -0
- data/ext/lemongraph/digraph_node.cc +277 -0
- data/ext/lemongraph/edge_map.cc +770 -0
- data/ext/lemongraph/extconf.rb +53 -0
- data/ext/lemongraph/graph.cc +351 -0
- data/ext/lemongraph/graph_arc.cc +95 -0
- data/ext/lemongraph/graph_edge.cc +153 -0
- data/ext/lemongraph/graph_item.cc +76 -0
- data/ext/lemongraph/graph_node.cc +321 -0
- data/ext/lemongraph/lemongraph.cc +260 -0
- data/ext/lemongraph/lemongraph.hh +295 -0
- data/ext/lemongraph/lemongraph.map +6 -0
- data/ext/lemongraph/lemongraph_export.hh +31 -0
- data/ext/lemongraph/node_map.cc +1011 -0
- data/lemongraph.gemspec +176 -0
- data/lib/lemongraph/graphviz.rb +240 -0
- data/lib/lemongraph/version.rb +4 -0
- data/lib/lemongraph.rb +21 -0
- data/samples/lemondeps.rb +38 -0
- metadata +202 -0
|
@@ -0,0 +1,491 @@
|
|
|
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-2013
|
|
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
|
+
#ifndef LEMON_CONCEPTS_DIGRAPH_H
|
|
20
|
+
#define LEMON_CONCEPTS_DIGRAPH_H
|
|
21
|
+
|
|
22
|
+
///\ingroup graph_concepts
|
|
23
|
+
///\file
|
|
24
|
+
///\brief The concept of directed graphs.
|
|
25
|
+
|
|
26
|
+
#include <lemon/core.h>
|
|
27
|
+
#include <lemon/concepts/maps.h>
|
|
28
|
+
#include <lemon/concept_check.h>
|
|
29
|
+
#include <lemon/concepts/graph_components.h>
|
|
30
|
+
|
|
31
|
+
namespace lemon {
|
|
32
|
+
namespace concepts {
|
|
33
|
+
|
|
34
|
+
/// \ingroup graph_concepts
|
|
35
|
+
///
|
|
36
|
+
/// \brief Class describing the concept of directed graphs.
|
|
37
|
+
///
|
|
38
|
+
/// This class describes the common interface of all directed
|
|
39
|
+
/// graphs (digraphs).
|
|
40
|
+
///
|
|
41
|
+
/// Like all concept classes, it only provides an interface
|
|
42
|
+
/// without any sensible implementation. So any general algorithm for
|
|
43
|
+
/// directed graphs should compile with this class, but it will not
|
|
44
|
+
/// run properly, of course.
|
|
45
|
+
/// An actual digraph implementation like \ref ListDigraph or
|
|
46
|
+
/// \ref SmartDigraph may have additional functionality.
|
|
47
|
+
///
|
|
48
|
+
/// \sa Graph
|
|
49
|
+
class Digraph {
|
|
50
|
+
private:
|
|
51
|
+
/// Diraphs are \e not copy constructible. Use DigraphCopy instead.
|
|
52
|
+
Digraph(const Digraph &) {}
|
|
53
|
+
/// \brief Assignment of a digraph to another one is \e not allowed.
|
|
54
|
+
/// Use DigraphCopy instead.
|
|
55
|
+
void operator=(const Digraph &) {}
|
|
56
|
+
|
|
57
|
+
public:
|
|
58
|
+
/// Default constructor.
|
|
59
|
+
Digraph() { }
|
|
60
|
+
|
|
61
|
+
/// The node type of the digraph
|
|
62
|
+
|
|
63
|
+
/// This class identifies a node of the digraph. It also serves
|
|
64
|
+
/// as a base class of the node iterators,
|
|
65
|
+
/// thus they convert to this type.
|
|
66
|
+
class Node {
|
|
67
|
+
public:
|
|
68
|
+
/// Default constructor
|
|
69
|
+
|
|
70
|
+
/// Default constructor.
|
|
71
|
+
/// \warning It sets the object to an undefined value.
|
|
72
|
+
Node() { }
|
|
73
|
+
/// Copy constructor.
|
|
74
|
+
|
|
75
|
+
/// Copy constructor.
|
|
76
|
+
///
|
|
77
|
+
Node(const Node&) { }
|
|
78
|
+
|
|
79
|
+
/// %Invalid constructor \& conversion.
|
|
80
|
+
|
|
81
|
+
/// Initializes the object to be invalid.
|
|
82
|
+
/// \sa Invalid for more details.
|
|
83
|
+
Node(Invalid) { }
|
|
84
|
+
/// Equality operator
|
|
85
|
+
|
|
86
|
+
/// Equality operator.
|
|
87
|
+
///
|
|
88
|
+
/// Two iterators are equal if and only if they point to the
|
|
89
|
+
/// same object or both are \c INVALID.
|
|
90
|
+
bool operator==(Node) const { return true; }
|
|
91
|
+
|
|
92
|
+
/// Inequality operator
|
|
93
|
+
|
|
94
|
+
/// Inequality operator.
|
|
95
|
+
bool operator!=(Node) const { return true; }
|
|
96
|
+
|
|
97
|
+
/// Artificial ordering operator.
|
|
98
|
+
|
|
99
|
+
/// Artificial ordering operator.
|
|
100
|
+
///
|
|
101
|
+
/// \note This operator only has to define some strict ordering of
|
|
102
|
+
/// the nodes; this order has nothing to do with the iteration
|
|
103
|
+
/// ordering of the nodes.
|
|
104
|
+
bool operator<(Node) const { return false; }
|
|
105
|
+
};
|
|
106
|
+
|
|
107
|
+
/// Iterator class for the nodes.
|
|
108
|
+
|
|
109
|
+
/// This iterator goes through each node of the digraph.
|
|
110
|
+
/// Its usage is quite simple, for example, you can count the number
|
|
111
|
+
/// of nodes in a digraph \c g of type \c %Digraph like this:
|
|
112
|
+
///\code
|
|
113
|
+
/// int count=0;
|
|
114
|
+
/// for (Digraph::NodeIt n(g); n!=INVALID; ++n) ++count;
|
|
115
|
+
///\endcode
|
|
116
|
+
class NodeIt : public Node {
|
|
117
|
+
public:
|
|
118
|
+
/// Default constructor
|
|
119
|
+
|
|
120
|
+
/// Default constructor.
|
|
121
|
+
/// \warning It sets the iterator to an undefined value.
|
|
122
|
+
NodeIt() { }
|
|
123
|
+
/// Copy constructor.
|
|
124
|
+
|
|
125
|
+
/// Copy constructor.
|
|
126
|
+
///
|
|
127
|
+
NodeIt(const NodeIt& n) : Node(n) { }
|
|
128
|
+
/// %Invalid constructor \& conversion.
|
|
129
|
+
|
|
130
|
+
/// Initializes the iterator to be invalid.
|
|
131
|
+
/// \sa Invalid for more details.
|
|
132
|
+
NodeIt(Invalid) { }
|
|
133
|
+
/// Sets the iterator to the first node.
|
|
134
|
+
|
|
135
|
+
/// Sets the iterator to the first node of the given digraph.
|
|
136
|
+
///
|
|
137
|
+
explicit NodeIt(const Digraph&) { }
|
|
138
|
+
/// Sets the iterator to the given node.
|
|
139
|
+
|
|
140
|
+
/// Sets the iterator to the given node of the given digraph.
|
|
141
|
+
///
|
|
142
|
+
NodeIt(const Digraph&, const Node&) { }
|
|
143
|
+
/// Next node.
|
|
144
|
+
|
|
145
|
+
/// Assign the iterator to the next node.
|
|
146
|
+
///
|
|
147
|
+
NodeIt& operator++() { return *this; }
|
|
148
|
+
};
|
|
149
|
+
|
|
150
|
+
|
|
151
|
+
/// The arc type of the digraph
|
|
152
|
+
|
|
153
|
+
/// This class identifies an arc of the digraph. It also serves
|
|
154
|
+
/// as a base class of the arc iterators,
|
|
155
|
+
/// thus they will convert to this type.
|
|
156
|
+
class Arc {
|
|
157
|
+
public:
|
|
158
|
+
/// Default constructor
|
|
159
|
+
|
|
160
|
+
/// Default constructor.
|
|
161
|
+
/// \warning It sets the object to an undefined value.
|
|
162
|
+
Arc() { }
|
|
163
|
+
/// Copy constructor.
|
|
164
|
+
|
|
165
|
+
/// Copy constructor.
|
|
166
|
+
///
|
|
167
|
+
Arc(const Arc&) { }
|
|
168
|
+
/// %Invalid constructor \& conversion.
|
|
169
|
+
|
|
170
|
+
/// Initializes the object to be invalid.
|
|
171
|
+
/// \sa Invalid for more details.
|
|
172
|
+
Arc(Invalid) { }
|
|
173
|
+
/// Equality operator
|
|
174
|
+
|
|
175
|
+
/// Equality operator.
|
|
176
|
+
///
|
|
177
|
+
/// Two iterators are equal if and only if they point to the
|
|
178
|
+
/// same object or both are \c INVALID.
|
|
179
|
+
bool operator==(Arc) const { return true; }
|
|
180
|
+
/// Inequality operator
|
|
181
|
+
|
|
182
|
+
/// Inequality operator.
|
|
183
|
+
bool operator!=(Arc) const { return true; }
|
|
184
|
+
|
|
185
|
+
/// Artificial ordering operator.
|
|
186
|
+
|
|
187
|
+
/// Artificial ordering operator.
|
|
188
|
+
///
|
|
189
|
+
/// \note This operator only has to define some strict ordering of
|
|
190
|
+
/// the arcs; this order has nothing to do with the iteration
|
|
191
|
+
/// ordering of the arcs.
|
|
192
|
+
bool operator<(Arc) const { return false; }
|
|
193
|
+
};
|
|
194
|
+
|
|
195
|
+
/// Iterator class for the outgoing arcs of a node.
|
|
196
|
+
|
|
197
|
+
/// This iterator goes trough the \e outgoing arcs of a certain node
|
|
198
|
+
/// of a digraph.
|
|
199
|
+
/// Its usage is quite simple, for example, you can count the number
|
|
200
|
+
/// of outgoing arcs of a node \c n
|
|
201
|
+
/// in a digraph \c g of type \c %Digraph as follows.
|
|
202
|
+
///\code
|
|
203
|
+
/// int count=0;
|
|
204
|
+
/// for (Digraph::OutArcIt a(g, n); a!=INVALID; ++a) ++count;
|
|
205
|
+
///\endcode
|
|
206
|
+
class OutArcIt : public Arc {
|
|
207
|
+
public:
|
|
208
|
+
/// Default constructor
|
|
209
|
+
|
|
210
|
+
/// Default constructor.
|
|
211
|
+
/// \warning It sets the iterator to an undefined value.
|
|
212
|
+
OutArcIt() { }
|
|
213
|
+
/// Copy constructor.
|
|
214
|
+
|
|
215
|
+
/// Copy constructor.
|
|
216
|
+
///
|
|
217
|
+
OutArcIt(const OutArcIt& e) : Arc(e) { }
|
|
218
|
+
/// %Invalid constructor \& conversion.
|
|
219
|
+
|
|
220
|
+
/// Initializes the iterator to be invalid.
|
|
221
|
+
/// \sa Invalid for more details.
|
|
222
|
+
OutArcIt(Invalid) { }
|
|
223
|
+
/// Sets the iterator to the first outgoing arc.
|
|
224
|
+
|
|
225
|
+
/// Sets the iterator to the first outgoing arc of the given node.
|
|
226
|
+
///
|
|
227
|
+
OutArcIt(const Digraph&, const Node&) { }
|
|
228
|
+
/// Sets the iterator to the given arc.
|
|
229
|
+
|
|
230
|
+
/// Sets the iterator to the given arc of the given digraph.
|
|
231
|
+
///
|
|
232
|
+
OutArcIt(const Digraph&, const Arc&) { }
|
|
233
|
+
/// Next outgoing arc
|
|
234
|
+
|
|
235
|
+
/// Assign the iterator to the next
|
|
236
|
+
/// outgoing arc of the corresponding node.
|
|
237
|
+
OutArcIt& operator++() { return *this; }
|
|
238
|
+
};
|
|
239
|
+
|
|
240
|
+
/// Iterator class for the incoming arcs of a node.
|
|
241
|
+
|
|
242
|
+
/// This iterator goes trough the \e incoming arcs of a certain node
|
|
243
|
+
/// of a digraph.
|
|
244
|
+
/// Its usage is quite simple, for example, you can count the number
|
|
245
|
+
/// of incoming arcs of a node \c n
|
|
246
|
+
/// in a digraph \c g of type \c %Digraph as follows.
|
|
247
|
+
///\code
|
|
248
|
+
/// int count=0;
|
|
249
|
+
/// for(Digraph::InArcIt a(g, n); a!=INVALID; ++a) ++count;
|
|
250
|
+
///\endcode
|
|
251
|
+
class InArcIt : public Arc {
|
|
252
|
+
public:
|
|
253
|
+
/// Default constructor
|
|
254
|
+
|
|
255
|
+
/// Default constructor.
|
|
256
|
+
/// \warning It sets the iterator to an undefined value.
|
|
257
|
+
InArcIt() { }
|
|
258
|
+
/// Copy constructor.
|
|
259
|
+
|
|
260
|
+
/// Copy constructor.
|
|
261
|
+
///
|
|
262
|
+
InArcIt(const InArcIt& e) : Arc(e) { }
|
|
263
|
+
/// %Invalid constructor \& conversion.
|
|
264
|
+
|
|
265
|
+
/// Initializes the iterator to be invalid.
|
|
266
|
+
/// \sa Invalid for more details.
|
|
267
|
+
InArcIt(Invalid) { }
|
|
268
|
+
/// Sets the iterator to the first incoming arc.
|
|
269
|
+
|
|
270
|
+
/// Sets the iterator to the first incoming arc of the given node.
|
|
271
|
+
///
|
|
272
|
+
InArcIt(const Digraph&, const Node&) { }
|
|
273
|
+
/// Sets the iterator to the given arc.
|
|
274
|
+
|
|
275
|
+
/// Sets the iterator to the given arc of the given digraph.
|
|
276
|
+
///
|
|
277
|
+
InArcIt(const Digraph&, const Arc&) { }
|
|
278
|
+
/// Next incoming arc
|
|
279
|
+
|
|
280
|
+
/// Assign the iterator to the next
|
|
281
|
+
/// incoming arc of the corresponding node.
|
|
282
|
+
InArcIt& operator++() { return *this; }
|
|
283
|
+
};
|
|
284
|
+
|
|
285
|
+
/// Iterator class for the arcs.
|
|
286
|
+
|
|
287
|
+
/// This iterator goes through each arc of the digraph.
|
|
288
|
+
/// Its usage is quite simple, for example, you can count the number
|
|
289
|
+
/// of arcs in a digraph \c g of type \c %Digraph as follows:
|
|
290
|
+
///\code
|
|
291
|
+
/// int count=0;
|
|
292
|
+
/// for(Digraph::ArcIt a(g); a!=INVALID; ++a) ++count;
|
|
293
|
+
///\endcode
|
|
294
|
+
class ArcIt : public Arc {
|
|
295
|
+
public:
|
|
296
|
+
/// Default constructor
|
|
297
|
+
|
|
298
|
+
/// Default constructor.
|
|
299
|
+
/// \warning It sets the iterator to an undefined value.
|
|
300
|
+
ArcIt() { }
|
|
301
|
+
/// Copy constructor.
|
|
302
|
+
|
|
303
|
+
/// Copy constructor.
|
|
304
|
+
///
|
|
305
|
+
ArcIt(const ArcIt& e) : Arc(e) { }
|
|
306
|
+
/// %Invalid constructor \& conversion.
|
|
307
|
+
|
|
308
|
+
/// Initializes the iterator to be invalid.
|
|
309
|
+
/// \sa Invalid for more details.
|
|
310
|
+
ArcIt(Invalid) { }
|
|
311
|
+
/// Sets the iterator to the first arc.
|
|
312
|
+
|
|
313
|
+
/// Sets the iterator to the first arc of the given digraph.
|
|
314
|
+
///
|
|
315
|
+
explicit ArcIt(const Digraph& g) {
|
|
316
|
+
::lemon::ignore_unused_variable_warning(g);
|
|
317
|
+
}
|
|
318
|
+
/// Sets the iterator to the given arc.
|
|
319
|
+
|
|
320
|
+
/// Sets the iterator to the given arc of the given digraph.
|
|
321
|
+
///
|
|
322
|
+
ArcIt(const Digraph&, const Arc&) { }
|
|
323
|
+
/// Next arc
|
|
324
|
+
|
|
325
|
+
/// Assign the iterator to the next arc.
|
|
326
|
+
///
|
|
327
|
+
ArcIt& operator++() { return *this; }
|
|
328
|
+
};
|
|
329
|
+
|
|
330
|
+
/// \brief The source node of the arc.
|
|
331
|
+
///
|
|
332
|
+
/// Returns the source node of the given arc.
|
|
333
|
+
Node source(Arc) const { return INVALID; }
|
|
334
|
+
|
|
335
|
+
/// \brief The target node of the arc.
|
|
336
|
+
///
|
|
337
|
+
/// Returns the target node of the given arc.
|
|
338
|
+
Node target(Arc) const { return INVALID; }
|
|
339
|
+
|
|
340
|
+
/// \brief The ID of the node.
|
|
341
|
+
///
|
|
342
|
+
/// Returns the ID of the given node.
|
|
343
|
+
int id(Node) const { return -1; }
|
|
344
|
+
|
|
345
|
+
/// \brief The ID of the arc.
|
|
346
|
+
///
|
|
347
|
+
/// Returns the ID of the given arc.
|
|
348
|
+
int id(Arc) const { return -1; }
|
|
349
|
+
|
|
350
|
+
/// \brief The node with the given ID.
|
|
351
|
+
///
|
|
352
|
+
/// Returns the node with the given ID.
|
|
353
|
+
/// \pre The argument should be a valid node ID in the digraph.
|
|
354
|
+
Node nodeFromId(int) const { return INVALID; }
|
|
355
|
+
|
|
356
|
+
/// \brief The arc with the given ID.
|
|
357
|
+
///
|
|
358
|
+
/// Returns the arc with the given ID.
|
|
359
|
+
/// \pre The argument should be a valid arc ID in the digraph.
|
|
360
|
+
Arc arcFromId(int) const { return INVALID; }
|
|
361
|
+
|
|
362
|
+
/// \brief An upper bound on the node IDs.
|
|
363
|
+
///
|
|
364
|
+
/// Returns an upper bound on the node IDs.
|
|
365
|
+
int maxNodeId() const { return -1; }
|
|
366
|
+
|
|
367
|
+
/// \brief An upper bound on the arc IDs.
|
|
368
|
+
///
|
|
369
|
+
/// Returns an upper bound on the arc IDs.
|
|
370
|
+
int maxArcId() const { return -1; }
|
|
371
|
+
|
|
372
|
+
void first(Node&) const {}
|
|
373
|
+
void next(Node&) const {}
|
|
374
|
+
|
|
375
|
+
void first(Arc&) const {}
|
|
376
|
+
void next(Arc&) const {}
|
|
377
|
+
|
|
378
|
+
|
|
379
|
+
void firstIn(Arc&, const Node&) const {}
|
|
380
|
+
void nextIn(Arc&) const {}
|
|
381
|
+
|
|
382
|
+
void firstOut(Arc&, const Node&) const {}
|
|
383
|
+
void nextOut(Arc&) const {}
|
|
384
|
+
|
|
385
|
+
// The second parameter is dummy.
|
|
386
|
+
Node fromId(int, Node) const { return INVALID; }
|
|
387
|
+
// The second parameter is dummy.
|
|
388
|
+
Arc fromId(int, Arc) const { return INVALID; }
|
|
389
|
+
|
|
390
|
+
// Dummy parameter.
|
|
391
|
+
int maxId(Node) const { return -1; }
|
|
392
|
+
// Dummy parameter.
|
|
393
|
+
int maxId(Arc) const { return -1; }
|
|
394
|
+
|
|
395
|
+
/// \brief The opposite node on the arc.
|
|
396
|
+
///
|
|
397
|
+
/// Returns the opposite node on the given arc.
|
|
398
|
+
Node oppositeNode(Node, Arc) const { return INVALID; }
|
|
399
|
+
|
|
400
|
+
/// \brief The base node of the iterator.
|
|
401
|
+
///
|
|
402
|
+
/// Returns the base node of the given outgoing arc iterator
|
|
403
|
+
/// (i.e. the source node of the corresponding arc).
|
|
404
|
+
Node baseNode(OutArcIt) const { return INVALID; }
|
|
405
|
+
|
|
406
|
+
/// \brief The running node of the iterator.
|
|
407
|
+
///
|
|
408
|
+
/// Returns the running node of the given outgoing arc iterator
|
|
409
|
+
/// (i.e. the target node of the corresponding arc).
|
|
410
|
+
Node runningNode(OutArcIt) const { return INVALID; }
|
|
411
|
+
|
|
412
|
+
/// \brief The base node of the iterator.
|
|
413
|
+
///
|
|
414
|
+
/// Returns the base node of the given incoming arc iterator
|
|
415
|
+
/// (i.e. the target node of the corresponding arc).
|
|
416
|
+
Node baseNode(InArcIt) const { return INVALID; }
|
|
417
|
+
|
|
418
|
+
/// \brief The running node of the iterator.
|
|
419
|
+
///
|
|
420
|
+
/// Returns the running node of the given incoming arc iterator
|
|
421
|
+
/// (i.e. the source node of the corresponding arc).
|
|
422
|
+
Node runningNode(InArcIt) const { return INVALID; }
|
|
423
|
+
|
|
424
|
+
/// \brief Standard graph map type for the nodes.
|
|
425
|
+
///
|
|
426
|
+
/// Standard graph map type for the nodes.
|
|
427
|
+
/// It conforms to the ReferenceMap concept.
|
|
428
|
+
template<class T>
|
|
429
|
+
class NodeMap : public ReferenceMap<Node, T, T&, const T&> {
|
|
430
|
+
public:
|
|
431
|
+
|
|
432
|
+
/// Constructor
|
|
433
|
+
explicit NodeMap(const Digraph&) { }
|
|
434
|
+
/// Constructor with given initial value
|
|
435
|
+
NodeMap(const Digraph&, T) { }
|
|
436
|
+
|
|
437
|
+
private:
|
|
438
|
+
///Copy constructor
|
|
439
|
+
NodeMap(const NodeMap& nm) :
|
|
440
|
+
ReferenceMap<Node, T, T&, const T&>(nm) { }
|
|
441
|
+
///Assignment operator
|
|
442
|
+
template <typename CMap>
|
|
443
|
+
NodeMap& operator=(const CMap&) {
|
|
444
|
+
checkConcept<ReadMap<Node, T>, CMap>();
|
|
445
|
+
return *this;
|
|
446
|
+
}
|
|
447
|
+
};
|
|
448
|
+
|
|
449
|
+
/// \brief Standard graph map type for the arcs.
|
|
450
|
+
///
|
|
451
|
+
/// Standard graph map type for the arcs.
|
|
452
|
+
/// It conforms to the ReferenceMap concept.
|
|
453
|
+
template<class T>
|
|
454
|
+
class ArcMap : public ReferenceMap<Arc, T, T&, const T&> {
|
|
455
|
+
public:
|
|
456
|
+
|
|
457
|
+
/// Constructor
|
|
458
|
+
explicit ArcMap(const Digraph&) { }
|
|
459
|
+
/// Constructor with given initial value
|
|
460
|
+
ArcMap(const Digraph&, T) { }
|
|
461
|
+
|
|
462
|
+
private:
|
|
463
|
+
///Copy constructor
|
|
464
|
+
ArcMap(const ArcMap& em) :
|
|
465
|
+
ReferenceMap<Arc, T, T&, const T&>(em) { }
|
|
466
|
+
///Assignment operator
|
|
467
|
+
template <typename CMap>
|
|
468
|
+
ArcMap& operator=(const CMap&) {
|
|
469
|
+
checkConcept<ReadMap<Arc, T>, CMap>();
|
|
470
|
+
return *this;
|
|
471
|
+
}
|
|
472
|
+
};
|
|
473
|
+
|
|
474
|
+
template <typename _Digraph>
|
|
475
|
+
struct Constraints {
|
|
476
|
+
void constraints() {
|
|
477
|
+
checkConcept<BaseDigraphComponent, _Digraph>();
|
|
478
|
+
checkConcept<IterableDigraphComponent<>, _Digraph>();
|
|
479
|
+
checkConcept<IDableDigraphComponent<>, _Digraph>();
|
|
480
|
+
checkConcept<MappableDigraphComponent<>, _Digraph>();
|
|
481
|
+
}
|
|
482
|
+
};
|
|
483
|
+
|
|
484
|
+
};
|
|
485
|
+
|
|
486
|
+
} //namespace concepts
|
|
487
|
+
} //namespace lemon
|
|
488
|
+
|
|
489
|
+
|
|
490
|
+
|
|
491
|
+
#endif
|