| ... | ... |
@@ -29,107 +29,107 @@ |
| 29 | 29 |
#include <lemon/maps.h> |
| 30 | 30 |
#include <lemon/bits/variant.h> |
| 31 | 31 |
|
| 32 | 32 |
#include <lemon/bits/graph_adaptor_extender.h> |
| 33 | 33 |
#include <lemon/tolerance.h> |
| 34 | 34 |
|
| 35 | 35 |
#include <algorithm> |
| 36 | 36 |
|
| 37 | 37 |
namespace lemon {
|
| 38 | 38 |
|
| 39 | 39 |
template<typename _Digraph> |
| 40 | 40 |
class DigraphAdaptorBase {
|
| 41 | 41 |
public: |
| 42 | 42 |
typedef _Digraph Digraph; |
| 43 | 43 |
typedef DigraphAdaptorBase Adaptor; |
| 44 | 44 |
typedef Digraph ParentDigraph; |
| 45 | 45 |
|
| 46 | 46 |
protected: |
| 47 | 47 |
Digraph* _digraph; |
| 48 | 48 |
DigraphAdaptorBase() : _digraph(0) { }
|
| 49 | 49 |
void setDigraph(Digraph& digraph) { _digraph = &digraph; }
|
| 50 | 50 |
|
| 51 | 51 |
public: |
| 52 | 52 |
DigraphAdaptorBase(Digraph& digraph) : _digraph(&digraph) { }
|
| 53 | 53 |
|
| 54 | 54 |
typedef typename Digraph::Node Node; |
| 55 | 55 |
typedef typename Digraph::Arc Arc; |
| 56 | 56 |
|
| 57 | 57 |
void first(Node& i) const { _digraph->first(i); }
|
| 58 | 58 |
void first(Arc& i) const { _digraph->first(i); }
|
| 59 | 59 |
void firstIn(Arc& i, const Node& n) const { _digraph->firstIn(i, n); }
|
| 60 | 60 |
void firstOut(Arc& i, const Node& n ) const { _digraph->firstOut(i, n); }
|
| 61 | 61 |
|
| 62 | 62 |
void next(Node& i) const { _digraph->next(i); }
|
| 63 | 63 |
void next(Arc& i) const { _digraph->next(i); }
|
| 64 | 64 |
void nextIn(Arc& i) const { _digraph->nextIn(i); }
|
| 65 | 65 |
void nextOut(Arc& i) const { _digraph->nextOut(i); }
|
| 66 | 66 |
|
| 67 | 67 |
Node source(const Arc& a) const { return _digraph->source(a); }
|
| 68 | 68 |
Node target(const Arc& a) const { return _digraph->target(a); }
|
| 69 | 69 |
|
| 70 | 70 |
typedef NodeNumTagIndicator<Digraph> NodeNumTag; |
| 71 | 71 |
int nodeNum() const { return _digraph->nodeNum(); }
|
| 72 | 72 |
|
| 73 | 73 |
typedef ArcNumTagIndicator<Digraph> ArcNumTag; |
| 74 | 74 |
int arcNum() const { return _digraph->arcNum(); }
|
| 75 | 75 |
|
| 76 | 76 |
typedef FindArcTagIndicator<Digraph> FindArcTag; |
| 77 |
Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) {
|
|
| 77 |
Arc findArc(const Node& u, const Node& v, const Arc& prev = INVALID) const {
|
|
| 78 | 78 |
return _digraph->findArc(u, v, prev); |
| 79 | 79 |
} |
| 80 | 80 |
|
| 81 | 81 |
Node addNode() { return _digraph->addNode(); }
|
| 82 | 82 |
Arc addArc(const Node& u, const Node& v) { return _digraph->addArc(u, v); }
|
| 83 | 83 |
|
| 84 |
void erase(const Node& n) const { _digraph->erase(n); }
|
|
| 85 |
void erase(const Arc& a) const { _digraph->erase(a); }
|
|
| 86 |
|
|
| 87 |
void clear() const { _digraph->clear(); }
|
|
| 84 |
void erase(const Node& n) { _digraph->erase(n); }
|
|
| 85 |
void erase(const Arc& a) { _digraph->erase(a); }
|
|
| 86 |
|
|
| 87 |
void clear() { _digraph->clear(); }
|
|
| 88 | 88 |
|
| 89 | 89 |
int id(const Node& n) const { return _digraph->id(n); }
|
| 90 | 90 |
int id(const Arc& a) const { return _digraph->id(a); }
|
| 91 | 91 |
|
| 92 | 92 |
Node nodeFromId(int ix) const { return _digraph->nodeFromId(ix); }
|
| 93 | 93 |
Arc arcFromId(int ix) const { return _digraph->arcFromId(ix); }
|
| 94 | 94 |
|
| 95 | 95 |
int maxNodeId() const { return _digraph->maxNodeId(); }
|
| 96 | 96 |
int maxArcId() const { return _digraph->maxArcId(); }
|
| 97 | 97 |
|
| 98 | 98 |
typedef typename ItemSetTraits<Digraph, Node>::ItemNotifier NodeNotifier; |
| 99 | 99 |
NodeNotifier& notifier(Node) const { return _digraph->notifier(Node()); }
|
| 100 | 100 |
|
| 101 | 101 |
typedef typename ItemSetTraits<Digraph, Arc>::ItemNotifier ArcNotifier; |
| 102 | 102 |
ArcNotifier& notifier(Arc) const { return _digraph->notifier(Arc()); }
|
| 103 | 103 |
|
| 104 | 104 |
template <typename _Value> |
| 105 | 105 |
class NodeMap : public Digraph::template NodeMap<_Value> {
|
| 106 | 106 |
public: |
| 107 | 107 |
|
| 108 | 108 |
typedef typename Digraph::template NodeMap<_Value> Parent; |
| 109 | 109 |
|
| 110 | 110 |
explicit NodeMap(const Adaptor& adaptor) |
| 111 | 111 |
: Parent(*adaptor._digraph) {}
|
| 112 | 112 |
|
| 113 | 113 |
NodeMap(const Adaptor& adaptor, const _Value& value) |
| 114 | 114 |
: Parent(*adaptor._digraph, value) { }
|
| 115 | 115 |
|
| 116 | 116 |
private: |
| 117 | 117 |
NodeMap& operator=(const NodeMap& cmap) {
|
| 118 | 118 |
return operator=<NodeMap>(cmap); |
| 119 | 119 |
} |
| 120 | 120 |
|
| 121 | 121 |
template <typename CMap> |
| 122 | 122 |
NodeMap& operator=(const CMap& cmap) {
|
| 123 | 123 |
Parent::operator=(cmap); |
| 124 | 124 |
return *this; |
| 125 | 125 |
} |
| 126 | 126 |
|
| 127 | 127 |
}; |
| 128 | 128 |
|
| 129 | 129 |
template <typename _Value> |
| 130 | 130 |
class ArcMap : public Digraph::template ArcMap<_Value> {
|
| 131 | 131 |
public: |
| 132 | 132 |
|
| 133 | 133 |
typedef typename Digraph::template ArcMap<_Value> Parent; |
| 134 | 134 |
|
| 135 | 135 |
explicit ArcMap(const Adaptor& adaptor) |
| ... | ... |
@@ -160,102 +160,104 @@ |
| 160 | 160 |
typedef Graph ParentGraph; |
| 161 | 161 |
|
| 162 | 162 |
protected: |
| 163 | 163 |
Graph* _graph; |
| 164 | 164 |
|
| 165 | 165 |
GraphAdaptorBase() : _graph(0) {}
|
| 166 | 166 |
|
| 167 | 167 |
void setGraph(Graph& graph) { _graph = &graph; }
|
| 168 | 168 |
|
| 169 | 169 |
public: |
| 170 | 170 |
GraphAdaptorBase(Graph& graph) : _graph(&graph) {}
|
| 171 | 171 |
|
| 172 | 172 |
typedef typename Graph::Node Node; |
| 173 | 173 |
typedef typename Graph::Arc Arc; |
| 174 | 174 |
typedef typename Graph::Edge Edge; |
| 175 | 175 |
|
| 176 | 176 |
void first(Node& i) const { _graph->first(i); }
|
| 177 | 177 |
void first(Arc& i) const { _graph->first(i); }
|
| 178 | 178 |
void first(Edge& i) const { _graph->first(i); }
|
| 179 | 179 |
void firstIn(Arc& i, const Node& n) const { _graph->firstIn(i, n); }
|
| 180 | 180 |
void firstOut(Arc& i, const Node& n ) const { _graph->firstOut(i, n); }
|
| 181 | 181 |
void firstInc(Edge &i, bool &d, const Node &n) const {
|
| 182 | 182 |
_graph->firstInc(i, d, n); |
| 183 | 183 |
} |
| 184 | 184 |
|
| 185 | 185 |
void next(Node& i) const { _graph->next(i); }
|
| 186 | 186 |
void next(Arc& i) const { _graph->next(i); }
|
| 187 | 187 |
void next(Edge& i) const { _graph->next(i); }
|
| 188 | 188 |
void nextIn(Arc& i) const { _graph->nextIn(i); }
|
| 189 | 189 |
void nextOut(Arc& i) const { _graph->nextOut(i); }
|
| 190 | 190 |
void nextInc(Edge &i, bool &d) const { _graph->nextInc(i, d); }
|
| 191 | 191 |
|
| 192 | 192 |
Node u(const Edge& e) const { return _graph->u(e); }
|
| 193 | 193 |
Node v(const Edge& e) const { return _graph->v(e); }
|
| 194 | 194 |
|
| 195 | 195 |
Node source(const Arc& a) const { return _graph->source(a); }
|
| 196 | 196 |
Node target(const Arc& a) const { return _graph->target(a); }
|
| 197 | 197 |
|
| 198 | 198 |
typedef NodeNumTagIndicator<Graph> NodeNumTag; |
| 199 | 199 |
int nodeNum() const { return _graph->nodeNum(); }
|
| 200 | 200 |
|
| 201 | 201 |
typedef ArcNumTagIndicator<Graph> ArcNumTag; |
| 202 | 202 |
int arcNum() const { return _graph->arcNum(); }
|
| 203 | 203 |
|
| 204 | 204 |
typedef EdgeNumTagIndicator<Graph> EdgeNumTag; |
| 205 | 205 |
int edgeNum() const { return _graph->edgeNum(); }
|
| 206 | 206 |
|
| 207 | 207 |
typedef FindArcTagIndicator<Graph> FindArcTag; |
| 208 |
Arc findArc(const Node& u, const Node& v, |
|
| 208 |
Arc findArc(const Node& u, const Node& v, |
|
| 209 |
const Arc& prev = INVALID) const {
|
|
| 209 | 210 |
return _graph->findArc(u, v, prev); |
| 210 | 211 |
} |
| 211 | 212 |
|
| 212 | 213 |
typedef FindEdgeTagIndicator<Graph> FindEdgeTag; |
| 213 |
Edge findEdge(const Node& u, const Node& v, |
|
| 214 |
Edge findEdge(const Node& u, const Node& v, |
|
| 215 |
const Edge& prev = INVALID) const {
|
|
| 214 | 216 |
return _graph->findEdge(u, v, prev); |
| 215 | 217 |
} |
| 216 | 218 |
|
| 217 | 219 |
Node addNode() { return _graph->addNode(); }
|
| 218 | 220 |
Edge addEdge(const Node& u, const Node& v) { return _graph->addEdge(u, v); }
|
| 219 | 221 |
|
| 220 | 222 |
void erase(const Node& i) { _graph->erase(i); }
|
| 221 | 223 |
void erase(const Edge& i) { _graph->erase(i); }
|
| 222 | 224 |
|
| 223 | 225 |
void clear() { _graph->clear(); }
|
| 224 | 226 |
|
| 225 | 227 |
bool direction(const Arc& a) const { return _graph->direction(a); }
|
| 226 | 228 |
Arc direct(const Edge& e, bool d) const { return _graph->direct(e, d); }
|
| 227 | 229 |
|
| 228 | 230 |
int id(const Node& v) const { return _graph->id(v); }
|
| 229 | 231 |
int id(const Arc& a) const { return _graph->id(a); }
|
| 230 | 232 |
int id(const Edge& e) const { return _graph->id(e); }
|
| 231 | 233 |
|
| 232 | 234 |
Node nodeFromId(int ix) const { return _graph->nodeFromId(ix); }
|
| 233 | 235 |
Arc arcFromId(int ix) const { return _graph->arcFromId(ix); }
|
| 234 | 236 |
Edge edgeFromId(int ix) const { return _graph->edgeFromId(ix); }
|
| 235 | 237 |
|
| 236 | 238 |
int maxNodeId() const { return _graph->maxNodeId(); }
|
| 237 | 239 |
int maxArcId() const { return _graph->maxArcId(); }
|
| 238 | 240 |
int maxEdgeId() const { return _graph->maxEdgeId(); }
|
| 239 | 241 |
|
| 240 | 242 |
typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier; |
| 241 | 243 |
NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
|
| 242 | 244 |
|
| 243 | 245 |
typedef typename ItemSetTraits<Graph, Arc>::ItemNotifier ArcNotifier; |
| 244 | 246 |
ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
|
| 245 | 247 |
|
| 246 | 248 |
typedef typename ItemSetTraits<Graph, Edge>::ItemNotifier EdgeNotifier; |
| 247 | 249 |
EdgeNotifier& notifier(Edge) const { return _graph->notifier(Edge()); }
|
| 248 | 250 |
|
| 249 | 251 |
template <typename _Value> |
| 250 | 252 |
class NodeMap : public Graph::template NodeMap<_Value> {
|
| 251 | 253 |
public: |
| 252 | 254 |
typedef typename Graph::template NodeMap<_Value> Parent; |
| 253 | 255 |
explicit NodeMap(const GraphAdaptorBase<Graph>& adapter) |
| 254 | 256 |
: Parent(*adapter._graph) {}
|
| 255 | 257 |
NodeMap(const GraphAdaptorBase<Graph>& adapter, const _Value& value) |
| 256 | 258 |
: Parent(*adapter._graph, value) {}
|
| 257 | 259 |
|
| 258 | 260 |
private: |
| 259 | 261 |
NodeMap& operator=(const NodeMap& cmap) {
|
| 260 | 262 |
return operator=<NodeMap>(cmap); |
| 261 | 263 |
} |
| ... | ... |
@@ -291,97 +293,97 @@ |
| 291 | 293 |
|
| 292 | 294 |
template <typename _Value> |
| 293 | 295 |
class EdgeMap : public Graph::template EdgeMap<_Value> {
|
| 294 | 296 |
public: |
| 295 | 297 |
typedef typename Graph::template EdgeMap<_Value> Parent; |
| 296 | 298 |
explicit EdgeMap(const GraphAdaptorBase<Graph>& adapter) |
| 297 | 299 |
: Parent(*adapter._graph) {}
|
| 298 | 300 |
EdgeMap(const GraphAdaptorBase<Graph>& adapter, const _Value& value) |
| 299 | 301 |
: Parent(*adapter._graph, value) {}
|
| 300 | 302 |
|
| 301 | 303 |
private: |
| 302 | 304 |
EdgeMap& operator=(const EdgeMap& cmap) {
|
| 303 | 305 |
return operator=<EdgeMap>(cmap); |
| 304 | 306 |
} |
| 305 | 307 |
|
| 306 | 308 |
template <typename CMap> |
| 307 | 309 |
EdgeMap& operator=(const CMap& cmap) {
|
| 308 | 310 |
Parent::operator=(cmap); |
| 309 | 311 |
return *this; |
| 310 | 312 |
} |
| 311 | 313 |
}; |
| 312 | 314 |
|
| 313 | 315 |
}; |
| 314 | 316 |
|
| 315 | 317 |
template <typename _Digraph> |
| 316 | 318 |
class ReverseDigraphBase : public DigraphAdaptorBase<_Digraph> {
|
| 317 | 319 |
public: |
| 318 | 320 |
typedef _Digraph Digraph; |
| 319 | 321 |
typedef DigraphAdaptorBase<_Digraph> Parent; |
| 320 | 322 |
protected: |
| 321 | 323 |
ReverseDigraphBase() : Parent() { }
|
| 322 | 324 |
public: |
| 323 | 325 |
typedef typename Parent::Node Node; |
| 324 | 326 |
typedef typename Parent::Arc Arc; |
| 325 | 327 |
|
| 326 | 328 |
void firstIn(Arc& a, const Node& n) const { Parent::firstOut(a, n); }
|
| 327 | 329 |
void firstOut(Arc& a, const Node& n ) const { Parent::firstIn(a, n); }
|
| 328 | 330 |
|
| 329 | 331 |
void nextIn(Arc& a) const { Parent::nextOut(a); }
|
| 330 | 332 |
void nextOut(Arc& a) const { Parent::nextIn(a); }
|
| 331 | 333 |
|
| 332 | 334 |
Node source(const Arc& a) const { return Parent::target(a); }
|
| 333 | 335 |
Node target(const Arc& a) const { return Parent::source(a); }
|
| 334 | 336 |
|
| 335 | 337 |
Arc addArc(const Node& u, const Node& v) { return Parent::addArc(v, u); }
|
| 336 | 338 |
|
| 337 | 339 |
typedef FindArcTagIndicator<Digraph> FindArcTag; |
| 338 | 340 |
Arc findArc(const Node& u, const Node& v, |
| 339 |
const Arc& prev = INVALID) {
|
|
| 341 |
const Arc& prev = INVALID) const {
|
|
| 340 | 342 |
return Parent::findArc(v, u, prev); |
| 341 | 343 |
} |
| 342 | 344 |
|
| 343 | 345 |
}; |
| 344 | 346 |
|
| 345 | 347 |
/// \ingroup graph_adaptors |
| 346 | 348 |
/// |
| 347 | 349 |
/// \brief A digraph adaptor which reverses the orientation of the arcs. |
| 348 | 350 |
/// |
| 349 | 351 |
/// ReverseDigraph reverses the arcs in the adapted digraph. The |
| 350 | 352 |
/// SubDigraph is conform to the \ref concepts::Digraph |
| 351 | 353 |
/// "Digraph concept". |
| 352 | 354 |
/// |
| 353 | 355 |
/// \tparam _Digraph It must be conform to the \ref concepts::Digraph |
| 354 | 356 |
/// "Digraph concept". The type can be specified to be const. |
| 355 | 357 |
template<typename _Digraph> |
| 356 | 358 |
class ReverseDigraph : |
| 357 | 359 |
public DigraphAdaptorExtender<ReverseDigraphBase<_Digraph> > {
|
| 358 | 360 |
public: |
| 359 | 361 |
typedef _Digraph Digraph; |
| 360 | 362 |
typedef DigraphAdaptorExtender< |
| 361 | 363 |
ReverseDigraphBase<_Digraph> > Parent; |
| 362 | 364 |
protected: |
| 363 | 365 |
ReverseDigraph() { }
|
| 364 | 366 |
public: |
| 365 | 367 |
|
| 366 | 368 |
/// \brief Constructor |
| 367 | 369 |
/// |
| 368 | 370 |
/// Creates a reverse digraph adaptor for the given digraph |
| 369 | 371 |
explicit ReverseDigraph(Digraph& digraph) {
|
| 370 | 372 |
Parent::setDigraph(digraph); |
| 371 | 373 |
} |
| 372 | 374 |
}; |
| 373 | 375 |
|
| 374 | 376 |
/// \brief Just gives back a reverse digraph adaptor |
| 375 | 377 |
/// |
| 376 | 378 |
/// Just gives back a reverse digraph adaptor |
| 377 | 379 |
template<typename Digraph> |
| 378 | 380 |
ReverseDigraph<const Digraph> reverseDigraph(const Digraph& digraph) {
|
| 379 | 381 |
return ReverseDigraph<const Digraph>(digraph); |
| 380 | 382 |
} |
| 381 | 383 |
|
| 382 | 384 |
template <typename _Digraph, typename _NodeFilterMap, |
| 383 | 385 |
typename _ArcFilterMap, bool _checked = true> |
| 384 | 386 |
class SubDigraphBase : public DigraphAdaptorBase<_Digraph> {
|
| 385 | 387 |
public: |
| 386 | 388 |
typedef _Digraph Digraph; |
| 387 | 389 |
typedef _NodeFilterMap NodeFilterMap; |
| ... | ... |
@@ -430,97 +432,97 @@ |
| 430 | 432 |
void firstOut(Arc& i, const Node& n) const {
|
| 431 | 433 |
Parent::firstOut(i, n); |
| 432 | 434 |
while (i != INVALID && (!(*_arc_filter)[i] |
| 433 | 435 |
|| !(*_node_filter)[Parent::target(i)])) |
| 434 | 436 |
Parent::nextOut(i); |
| 435 | 437 |
} |
| 436 | 438 |
|
| 437 | 439 |
void next(Node& i) const {
|
| 438 | 440 |
Parent::next(i); |
| 439 | 441 |
while (i != INVALID && !(*_node_filter)[i]) Parent::next(i); |
| 440 | 442 |
} |
| 441 | 443 |
|
| 442 | 444 |
void next(Arc& i) const {
|
| 443 | 445 |
Parent::next(i); |
| 444 | 446 |
while (i != INVALID && (!(*_arc_filter)[i] |
| 445 | 447 |
|| !(*_node_filter)[Parent::source(i)] |
| 446 | 448 |
|| !(*_node_filter)[Parent::target(i)])) |
| 447 | 449 |
Parent::next(i); |
| 448 | 450 |
} |
| 449 | 451 |
|
| 450 | 452 |
void nextIn(Arc& i) const {
|
| 451 | 453 |
Parent::nextIn(i); |
| 452 | 454 |
while (i != INVALID && (!(*_arc_filter)[i] |
| 453 | 455 |
|| !(*_node_filter)[Parent::source(i)])) |
| 454 | 456 |
Parent::nextIn(i); |
| 455 | 457 |
} |
| 456 | 458 |
|
| 457 | 459 |
void nextOut(Arc& i) const {
|
| 458 | 460 |
Parent::nextOut(i); |
| 459 | 461 |
while (i != INVALID && (!(*_arc_filter)[i] |
| 460 | 462 |
|| !(*_node_filter)[Parent::target(i)])) |
| 461 | 463 |
Parent::nextOut(i); |
| 462 | 464 |
} |
| 463 | 465 |
|
| 464 | 466 |
void hide(const Node& n) const { _node_filter->set(n, false); }
|
| 465 | 467 |
void hide(const Arc& a) const { _arc_filter->set(a, false); }
|
| 466 | 468 |
|
| 467 | 469 |
void unHide(const Node& n) const { _node_filter->set(n, true); }
|
| 468 | 470 |
void unHide(const Arc& a) const { _arc_filter->set(a, true); }
|
| 469 | 471 |
|
| 470 | 472 |
bool hidden(const Node& n) const { return !(*_node_filter)[n]; }
|
| 471 | 473 |
bool hidden(const Arc& a) const { return !(*_arc_filter)[a]; }
|
| 472 | 474 |
|
| 473 | 475 |
typedef False NodeNumTag; |
| 474 | 476 |
typedef False ArcNumTag; |
| 475 | 477 |
|
| 476 | 478 |
typedef FindArcTagIndicator<Digraph> FindArcTag; |
| 477 | 479 |
Arc findArc(const Node& source, const Node& target, |
| 478 |
const Arc& prev = INVALID) {
|
|
| 480 |
const Arc& prev = INVALID) const {
|
|
| 479 | 481 |
if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
|
| 480 | 482 |
return INVALID; |
| 481 | 483 |
} |
| 482 | 484 |
Arc arc = Parent::findArc(source, target, prev); |
| 483 | 485 |
while (arc != INVALID && !(*_arc_filter)[arc]) {
|
| 484 | 486 |
arc = Parent::findArc(source, target, arc); |
| 485 | 487 |
} |
| 486 | 488 |
return arc; |
| 487 | 489 |
} |
| 488 | 490 |
|
| 489 | 491 |
template <typename _Value> |
| 490 | 492 |
class NodeMap : public SubMapExtender<Adaptor, |
| 491 | 493 |
typename Parent::template NodeMap<_Value> > {
|
| 492 | 494 |
public: |
| 493 | 495 |
typedef _Value Value; |
| 494 | 496 |
typedef SubMapExtender<Adaptor, typename Parent:: |
| 495 | 497 |
template NodeMap<Value> > MapParent; |
| 496 | 498 |
|
| 497 | 499 |
NodeMap(const Adaptor& adaptor) |
| 498 | 500 |
: MapParent(adaptor) {}
|
| 499 | 501 |
NodeMap(const Adaptor& adaptor, const Value& value) |
| 500 | 502 |
: MapParent(adaptor, value) {}
|
| 501 | 503 |
|
| 502 | 504 |
private: |
| 503 | 505 |
NodeMap& operator=(const NodeMap& cmap) {
|
| 504 | 506 |
return operator=<NodeMap>(cmap); |
| 505 | 507 |
} |
| 506 | 508 |
|
| 507 | 509 |
template <typename CMap> |
| 508 | 510 |
NodeMap& operator=(const CMap& cmap) {
|
| 509 | 511 |
MapParent::operator=(cmap); |
| 510 | 512 |
return *this; |
| 511 | 513 |
} |
| 512 | 514 |
}; |
| 513 | 515 |
|
| 514 | 516 |
template <typename _Value> |
| 515 | 517 |
class ArcMap : public SubMapExtender<Adaptor, |
| 516 | 518 |
typename Parent::template ArcMap<_Value> > {
|
| 517 | 519 |
public: |
| 518 | 520 |
typedef _Value Value; |
| 519 | 521 |
typedef SubMapExtender<Adaptor, typename Parent:: |
| 520 | 522 |
template ArcMap<Value> > MapParent; |
| 521 | 523 |
|
| 522 | 524 |
ArcMap(const Adaptor& adaptor) |
| 523 | 525 |
: MapParent(adaptor) {}
|
| 524 | 526 |
ArcMap(const Adaptor& adaptor, const Value& value) |
| 525 | 527 |
: MapParent(adaptor, value) {}
|
| 526 | 528 |
|
| ... | ... |
@@ -573,97 +575,97 @@ |
| 573 | 575 |
|
| 574 | 576 |
void first(Arc& i) const {
|
| 575 | 577 |
Parent::first(i); |
| 576 | 578 |
while (i!=INVALID && !(*_arc_filter)[i]) Parent::next(i); |
| 577 | 579 |
} |
| 578 | 580 |
|
| 579 | 581 |
void firstIn(Arc& i, const Node& n) const {
|
| 580 | 582 |
Parent::firstIn(i, n); |
| 581 | 583 |
while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextIn(i); |
| 582 | 584 |
} |
| 583 | 585 |
|
| 584 | 586 |
void firstOut(Arc& i, const Node& n) const {
|
| 585 | 587 |
Parent::firstOut(i, n); |
| 586 | 588 |
while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextOut(i); |
| 587 | 589 |
} |
| 588 | 590 |
|
| 589 | 591 |
void next(Node& i) const {
|
| 590 | 592 |
Parent::next(i); |
| 591 | 593 |
while (i!=INVALID && !(*_node_filter)[i]) Parent::next(i); |
| 592 | 594 |
} |
| 593 | 595 |
void next(Arc& i) const {
|
| 594 | 596 |
Parent::next(i); |
| 595 | 597 |
while (i!=INVALID && !(*_arc_filter)[i]) Parent::next(i); |
| 596 | 598 |
} |
| 597 | 599 |
void nextIn(Arc& i) const {
|
| 598 | 600 |
Parent::nextIn(i); |
| 599 | 601 |
while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextIn(i); |
| 600 | 602 |
} |
| 601 | 603 |
|
| 602 | 604 |
void nextOut(Arc& i) const {
|
| 603 | 605 |
Parent::nextOut(i); |
| 604 | 606 |
while (i!=INVALID && !(*_arc_filter)[i]) Parent::nextOut(i); |
| 605 | 607 |
} |
| 606 | 608 |
|
| 607 | 609 |
void hide(const Node& n) const { _node_filter->set(n, false); }
|
| 608 | 610 |
void hide(const Arc& e) const { _arc_filter->set(e, false); }
|
| 609 | 611 |
|
| 610 | 612 |
void unHide(const Node& n) const { _node_filter->set(n, true); }
|
| 611 | 613 |
void unHide(const Arc& e) const { _arc_filter->set(e, true); }
|
| 612 | 614 |
|
| 613 | 615 |
bool hidden(const Node& n) const { return !(*_node_filter)[n]; }
|
| 614 | 616 |
bool hidden(const Arc& e) const { return !(*_arc_filter)[e]; }
|
| 615 | 617 |
|
| 616 | 618 |
typedef False NodeNumTag; |
| 617 | 619 |
typedef False ArcNumTag; |
| 618 | 620 |
|
| 619 | 621 |
typedef FindArcTagIndicator<Digraph> FindArcTag; |
| 620 | 622 |
Arc findArc(const Node& source, const Node& target, |
| 621 |
const Arc& prev = INVALID) {
|
|
| 623 |
const Arc& prev = INVALID) const {
|
|
| 622 | 624 |
if (!(*_node_filter)[source] || !(*_node_filter)[target]) {
|
| 623 | 625 |
return INVALID; |
| 624 | 626 |
} |
| 625 | 627 |
Arc arc = Parent::findArc(source, target, prev); |
| 626 | 628 |
while (arc != INVALID && !(*_arc_filter)[arc]) {
|
| 627 | 629 |
arc = Parent::findArc(source, target, arc); |
| 628 | 630 |
} |
| 629 | 631 |
return arc; |
| 630 | 632 |
} |
| 631 | 633 |
|
| 632 | 634 |
template <typename _Value> |
| 633 | 635 |
class NodeMap : public SubMapExtender<Adaptor, |
| 634 | 636 |
typename Parent::template NodeMap<_Value> > {
|
| 635 | 637 |
public: |
| 636 | 638 |
typedef _Value Value; |
| 637 | 639 |
typedef SubMapExtender<Adaptor, typename Parent:: |
| 638 | 640 |
template NodeMap<Value> > MapParent; |
| 639 | 641 |
|
| 640 | 642 |
NodeMap(const Adaptor& adaptor) |
| 641 | 643 |
: MapParent(adaptor) {}
|
| 642 | 644 |
NodeMap(const Adaptor& adaptor, const Value& value) |
| 643 | 645 |
: MapParent(adaptor, value) {}
|
| 644 | 646 |
|
| 645 | 647 |
private: |
| 646 | 648 |
NodeMap& operator=(const NodeMap& cmap) {
|
| 647 | 649 |
return operator=<NodeMap>(cmap); |
| 648 | 650 |
} |
| 649 | 651 |
|
| 650 | 652 |
template <typename CMap> |
| 651 | 653 |
NodeMap& operator=(const CMap& cmap) {
|
| 652 | 654 |
MapParent::operator=(cmap); |
| 653 | 655 |
return *this; |
| 654 | 656 |
} |
| 655 | 657 |
}; |
| 656 | 658 |
|
| 657 | 659 |
template <typename _Value> |
| 658 | 660 |
class ArcMap : public SubMapExtender<Adaptor, |
| 659 | 661 |
typename Parent::template ArcMap<_Value> > {
|
| 660 | 662 |
public: |
| 661 | 663 |
typedef _Value Value; |
| 662 | 664 |
typedef SubMapExtender<Adaptor, typename Parent:: |
| 663 | 665 |
template ArcMap<Value> > MapParent; |
| 664 | 666 |
|
| 665 | 667 |
ArcMap(const Adaptor& adaptor) |
| 666 | 668 |
: MapParent(adaptor) {}
|
| 667 | 669 |
ArcMap(const Adaptor& adaptor, const Value& value) |
| 668 | 670 |
: MapParent(adaptor, value) {}
|
| 669 | 671 |
|
| ... | ... |
@@ -899,110 +901,110 @@ |
| 899 | 901 |
Parent::next(i); |
| 900 | 902 |
} |
| 901 | 903 |
|
| 902 | 904 |
void next(Edge& i) const {
|
| 903 | 905 |
Parent::next(i); |
| 904 | 906 |
while (i!=INVALID && (!(*_edge_filter_map)[i] |
| 905 | 907 |
|| !(*_node_filter_map)[Parent::u(i)] |
| 906 | 908 |
|| !(*_node_filter_map)[Parent::v(i)])) |
| 907 | 909 |
Parent::next(i); |
| 908 | 910 |
} |
| 909 | 911 |
|
| 910 | 912 |
void nextIn(Arc& i) const {
|
| 911 | 913 |
Parent::nextIn(i); |
| 912 | 914 |
while (i!=INVALID && (!(*_edge_filter_map)[i] |
| 913 | 915 |
|| !(*_node_filter_map)[Parent::source(i)])) |
| 914 | 916 |
Parent::nextIn(i); |
| 915 | 917 |
} |
| 916 | 918 |
|
| 917 | 919 |
void nextOut(Arc& i) const {
|
| 918 | 920 |
Parent::nextOut(i); |
| 919 | 921 |
while (i!=INVALID && (!(*_edge_filter_map)[i] |
| 920 | 922 |
|| !(*_node_filter_map)[Parent::target(i)])) |
| 921 | 923 |
Parent::nextOut(i); |
| 922 | 924 |
} |
| 923 | 925 |
|
| 924 | 926 |
void nextInc(Edge& i, bool& d) const {
|
| 925 | 927 |
Parent::nextInc(i, d); |
| 926 | 928 |
while (i!=INVALID && (!(*_edge_filter_map)[i] |
| 927 | 929 |
|| !(*_node_filter_map)[Parent::u(i)] |
| 928 | 930 |
|| !(*_node_filter_map)[Parent::v(i)])) |
| 929 | 931 |
Parent::nextInc(i, d); |
| 930 | 932 |
} |
| 931 | 933 |
|
| 932 | 934 |
void hide(const Node& n) const { _node_filter_map->set(n, false); }
|
| 933 | 935 |
void hide(const Edge& e) const { _edge_filter_map->set(e, false); }
|
| 934 | 936 |
|
| 935 | 937 |
void unHide(const Node& n) const { _node_filter_map->set(n, true); }
|
| 936 | 938 |
void unHide(const Edge& e) const { _edge_filter_map->set(e, true); }
|
| 937 | 939 |
|
| 938 | 940 |
bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
|
| 939 | 941 |
bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
|
| 940 | 942 |
|
| 941 | 943 |
typedef False NodeNumTag; |
| 942 | 944 |
typedef False ArcNumTag; |
| 943 | 945 |
typedef False EdgeNumTag; |
| 944 | 946 |
|
| 945 | 947 |
typedef FindArcTagIndicator<Graph> FindArcTag; |
| 946 | 948 |
Arc findArc(const Node& u, const Node& v, |
| 947 |
const Arc& prev = INVALID) {
|
|
| 949 |
const Arc& prev = INVALID) const {
|
|
| 948 | 950 |
if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
|
| 949 | 951 |
return INVALID; |
| 950 | 952 |
} |
| 951 | 953 |
Arc arc = Parent::findArc(u, v, prev); |
| 952 | 954 |
while (arc != INVALID && !(*_edge_filter_map)[arc]) {
|
| 953 | 955 |
arc = Parent::findArc(u, v, arc); |
| 954 | 956 |
} |
| 955 | 957 |
return arc; |
| 956 | 958 |
} |
| 957 | 959 |
|
| 958 | 960 |
typedef FindEdgeTagIndicator<Graph> FindEdgeTag; |
| 959 | 961 |
Edge findEdge(const Node& u, const Node& v, |
| 960 |
const Edge& prev = INVALID) {
|
|
| 962 |
const Edge& prev = INVALID) const {
|
|
| 961 | 963 |
if (!(*_node_filter_map)[u] || !(*_node_filter_map)[v]) {
|
| 962 | 964 |
return INVALID; |
| 963 | 965 |
} |
| 964 | 966 |
Edge edge = Parent::findEdge(u, v, prev); |
| 965 | 967 |
while (edge != INVALID && !(*_edge_filter_map)[edge]) {
|
| 966 | 968 |
edge = Parent::findEdge(u, v, edge); |
| 967 | 969 |
} |
| 968 | 970 |
return edge; |
| 969 | 971 |
} |
| 970 | 972 |
|
| 971 | 973 |
template <typename _Value> |
| 972 | 974 |
class NodeMap : public SubMapExtender<Adaptor, |
| 973 | 975 |
typename Parent::template NodeMap<_Value> > {
|
| 974 | 976 |
public: |
| 975 | 977 |
typedef _Value Value; |
| 976 | 978 |
typedef SubMapExtender<Adaptor, typename Parent:: |
| 977 | 979 |
template NodeMap<Value> > MapParent; |
| 978 | 980 |
|
| 979 | 981 |
NodeMap(const Adaptor& adaptor) |
| 980 | 982 |
: MapParent(adaptor) {}
|
| 981 | 983 |
NodeMap(const Adaptor& adaptor, const Value& value) |
| 982 | 984 |
: MapParent(adaptor, value) {}
|
| 983 | 985 |
|
| 984 | 986 |
private: |
| 985 | 987 |
NodeMap& operator=(const NodeMap& cmap) {
|
| 986 | 988 |
return operator=<NodeMap>(cmap); |
| 987 | 989 |
} |
| 988 | 990 |
|
| 989 | 991 |
template <typename CMap> |
| 990 | 992 |
NodeMap& operator=(const CMap& cmap) {
|
| 991 | 993 |
MapParent::operator=(cmap); |
| 992 | 994 |
return *this; |
| 993 | 995 |
} |
| 994 | 996 |
}; |
| 995 | 997 |
|
| 996 | 998 |
template <typename _Value> |
| 997 | 999 |
class ArcMap : public SubMapExtender<Adaptor, |
| 998 | 1000 |
typename Parent::template ArcMap<_Value> > {
|
| 999 | 1001 |
public: |
| 1000 | 1002 |
typedef _Value Value; |
| 1001 | 1003 |
typedef SubMapExtender<Adaptor, typename Parent:: |
| 1002 | 1004 |
template ArcMap<Value> > MapParent; |
| 1003 | 1005 |
|
| 1004 | 1006 |
ArcMap(const Adaptor& adaptor) |
| 1005 | 1007 |
: MapParent(adaptor) {}
|
| 1006 | 1008 |
ArcMap(const Adaptor& adaptor, const Value& value) |
| 1007 | 1009 |
: MapParent(adaptor, value) {}
|
| 1008 | 1010 |
|
| ... | ... |
@@ -1098,107 +1100,107 @@ |
| 1098 | 1100 |
} |
| 1099 | 1101 |
|
| 1100 | 1102 |
void firstInc(Edge& i, bool& d, const Node& n) const {
|
| 1101 | 1103 |
Parent::firstInc(i, d, n); |
| 1102 | 1104 |
while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextInc(i, d); |
| 1103 | 1105 |
} |
| 1104 | 1106 |
|
| 1105 | 1107 |
void next(Node& i) const {
|
| 1106 | 1108 |
Parent::next(i); |
| 1107 | 1109 |
while (i!=INVALID && !(*_node_filter_map)[i]) Parent::next(i); |
| 1108 | 1110 |
} |
| 1109 | 1111 |
void next(Arc& i) const {
|
| 1110 | 1112 |
Parent::next(i); |
| 1111 | 1113 |
while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i); |
| 1112 | 1114 |
} |
| 1113 | 1115 |
void next(Edge& i) const {
|
| 1114 | 1116 |
Parent::next(i); |
| 1115 | 1117 |
while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::next(i); |
| 1116 | 1118 |
} |
| 1117 | 1119 |
void nextIn(Arc& i) const {
|
| 1118 | 1120 |
Parent::nextIn(i); |
| 1119 | 1121 |
while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextIn(i); |
| 1120 | 1122 |
} |
| 1121 | 1123 |
|
| 1122 | 1124 |
void nextOut(Arc& i) const {
|
| 1123 | 1125 |
Parent::nextOut(i); |
| 1124 | 1126 |
while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextOut(i); |
| 1125 | 1127 |
} |
| 1126 | 1128 |
void nextInc(Edge& i, bool& d) const {
|
| 1127 | 1129 |
Parent::nextInc(i, d); |
| 1128 | 1130 |
while (i!=INVALID && !(*_edge_filter_map)[i]) Parent::nextInc(i, d); |
| 1129 | 1131 |
} |
| 1130 | 1132 |
|
| 1131 | 1133 |
void hide(const Node& n) const { _node_filter_map->set(n, false); }
|
| 1132 | 1134 |
void hide(const Edge& e) const { _edge_filter_map->set(e, false); }
|
| 1133 | 1135 |
|
| 1134 | 1136 |
void unHide(const Node& n) const { _node_filter_map->set(n, true); }
|
| 1135 | 1137 |
void unHide(const Edge& e) const { _edge_filter_map->set(e, true); }
|
| 1136 | 1138 |
|
| 1137 | 1139 |
bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; }
|
| 1138 | 1140 |
bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; }
|
| 1139 | 1141 |
|
| 1140 | 1142 |
typedef False NodeNumTag; |
| 1141 | 1143 |
typedef False ArcNumTag; |
| 1142 | 1144 |
typedef False EdgeNumTag; |
| 1143 | 1145 |
|
| 1144 | 1146 |
typedef FindArcTagIndicator<Graph> FindArcTag; |
| 1145 | 1147 |
Arc findArc(const Node& u, const Node& v, |
| 1146 |
const Arc& prev = INVALID) {
|
|
| 1148 |
const Arc& prev = INVALID) const {
|
|
| 1147 | 1149 |
Arc arc = Parent::findArc(u, v, prev); |
| 1148 | 1150 |
while (arc != INVALID && !(*_edge_filter_map)[arc]) {
|
| 1149 | 1151 |
arc = Parent::findArc(u, v, arc); |
| 1150 | 1152 |
} |
| 1151 | 1153 |
return arc; |
| 1152 | 1154 |
} |
| 1153 | 1155 |
|
| 1154 | 1156 |
typedef FindEdgeTagIndicator<Graph> FindEdgeTag; |
| 1155 | 1157 |
Edge findEdge(const Node& u, const Node& v, |
| 1156 |
const Edge& prev = INVALID) {
|
|
| 1158 |
const Edge& prev = INVALID) const {
|
|
| 1157 | 1159 |
Edge edge = Parent::findEdge(u, v, prev); |
| 1158 | 1160 |
while (edge != INVALID && !(*_edge_filter_map)[edge]) {
|
| 1159 | 1161 |
edge = Parent::findEdge(u, v, edge); |
| 1160 | 1162 |
} |
| 1161 | 1163 |
return edge; |
| 1162 | 1164 |
} |
| 1163 | 1165 |
|
| 1164 | 1166 |
template <typename _Value> |
| 1165 | 1167 |
class NodeMap : public SubMapExtender<Adaptor, |
| 1166 | 1168 |
typename Parent::template NodeMap<_Value> > {
|
| 1167 | 1169 |
public: |
| 1168 | 1170 |
typedef _Value Value; |
| 1169 | 1171 |
typedef SubMapExtender<Adaptor, typename Parent:: |
| 1170 | 1172 |
template NodeMap<Value> > MapParent; |
| 1171 | 1173 |
|
| 1172 | 1174 |
NodeMap(const Adaptor& adaptor) |
| 1173 | 1175 |
: MapParent(adaptor) {}
|
| 1174 | 1176 |
NodeMap(const Adaptor& adaptor, const Value& value) |
| 1175 | 1177 |
: MapParent(adaptor, value) {}
|
| 1176 | 1178 |
|
| 1177 | 1179 |
private: |
| 1178 | 1180 |
NodeMap& operator=(const NodeMap& cmap) {
|
| 1179 | 1181 |
return operator=<NodeMap>(cmap); |
| 1180 | 1182 |
} |
| 1181 | 1183 |
|
| 1182 | 1184 |
template <typename CMap> |
| 1183 | 1185 |
NodeMap& operator=(const CMap& cmap) {
|
| 1184 | 1186 |
MapParent::operator=(cmap); |
| 1185 | 1187 |
return *this; |
| 1186 | 1188 |
} |
| 1187 | 1189 |
}; |
| 1188 | 1190 |
|
| 1189 | 1191 |
template <typename _Value> |
| 1190 | 1192 |
class ArcMap : public SubMapExtender<Adaptor, |
| 1191 | 1193 |
typename Parent::template ArcMap<_Value> > {
|
| 1192 | 1194 |
public: |
| 1193 | 1195 |
typedef _Value Value; |
| 1194 | 1196 |
typedef SubMapExtender<Adaptor, typename Parent:: |
| 1195 | 1197 |
template ArcMap<Value> > MapParent; |
| 1196 | 1198 |
|
| 1197 | 1199 |
ArcMap(const Adaptor& adaptor) |
| 1198 | 1200 |
: MapParent(adaptor) {}
|
| 1199 | 1201 |
ArcMap(const Adaptor& adaptor, const Value& value) |
| 1200 | 1202 |
: MapParent(adaptor, value) {}
|
| 1201 | 1203 |
|
| 1202 | 1204 |
private: |
| 1203 | 1205 |
ArcMap& operator=(const ArcMap& cmap) {
|
| 1204 | 1206 |
return operator=<ArcMap>(cmap); |
| ... | ... |
@@ -2198,97 +2200,97 @@ |
| 2198 | 2200 |
typedef typename Graph::Node Node; |
| 2199 | 2201 |
typedef typename Graph::Edge Arc; |
| 2200 | 2202 |
|
| 2201 | 2203 |
void reverseArc(const Arc& arc) {
|
| 2202 | 2204 |
_direction->set(arc, !(*_direction)[arc]); |
| 2203 | 2205 |
} |
| 2204 | 2206 |
|
| 2205 | 2207 |
void first(Node& i) const { _graph->first(i); }
|
| 2206 | 2208 |
void first(Arc& i) const { _graph->first(i); }
|
| 2207 | 2209 |
void firstIn(Arc& i, const Node& n) const {
|
| 2208 | 2210 |
bool d = true; |
| 2209 | 2211 |
_graph->firstInc(i, d, n); |
| 2210 | 2212 |
while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d); |
| 2211 | 2213 |
} |
| 2212 | 2214 |
void firstOut(Arc& i, const Node& n ) const {
|
| 2213 | 2215 |
bool d = true; |
| 2214 | 2216 |
_graph->firstInc(i, d, n); |
| 2215 | 2217 |
while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d); |
| 2216 | 2218 |
} |
| 2217 | 2219 |
|
| 2218 | 2220 |
void next(Node& i) const { _graph->next(i); }
|
| 2219 | 2221 |
void next(Arc& i) const { _graph->next(i); }
|
| 2220 | 2222 |
void nextIn(Arc& i) const {
|
| 2221 | 2223 |
bool d = !(*_direction)[i]; |
| 2222 | 2224 |
_graph->nextInc(i, d); |
| 2223 | 2225 |
while (i != INVALID && d == (*_direction)[i]) _graph->nextInc(i, d); |
| 2224 | 2226 |
} |
| 2225 | 2227 |
void nextOut(Arc& i) const {
|
| 2226 | 2228 |
bool d = (*_direction)[i]; |
| 2227 | 2229 |
_graph->nextInc(i, d); |
| 2228 | 2230 |
while (i != INVALID && d != (*_direction)[i]) _graph->nextInc(i, d); |
| 2229 | 2231 |
} |
| 2230 | 2232 |
|
| 2231 | 2233 |
Node source(const Arc& e) const {
|
| 2232 | 2234 |
return (*_direction)[e] ? _graph->u(e) : _graph->v(e); |
| 2233 | 2235 |
} |
| 2234 | 2236 |
Node target(const Arc& e) const {
|
| 2235 | 2237 |
return (*_direction)[e] ? _graph->v(e) : _graph->u(e); |
| 2236 | 2238 |
} |
| 2237 | 2239 |
|
| 2238 | 2240 |
typedef NodeNumTagIndicator<Graph> NodeNumTag; |
| 2239 | 2241 |
int nodeNum() const { return _graph->nodeNum(); }
|
| 2240 | 2242 |
|
| 2241 | 2243 |
typedef EdgeNumTagIndicator<Graph> ArcNumTag; |
| 2242 | 2244 |
int arcNum() const { return _graph->edgeNum(); }
|
| 2243 | 2245 |
|
| 2244 | 2246 |
typedef FindEdgeTagIndicator<Graph> FindArcTag; |
| 2245 | 2247 |
Arc findArc(const Node& u, const Node& v, |
| 2246 |
const Arc& prev = INVALID) {
|
|
| 2248 |
const Arc& prev = INVALID) const {
|
|
| 2247 | 2249 |
Arc arc = prev; |
| 2248 | 2250 |
bool d = arc == INVALID ? true : (*_direction)[arc]; |
| 2249 | 2251 |
if (d) {
|
| 2250 | 2252 |
arc = _graph->findEdge(u, v, arc); |
| 2251 | 2253 |
while (arc != INVALID && !(*_direction)[arc]) {
|
| 2252 | 2254 |
_graph->findEdge(u, v, arc); |
| 2253 | 2255 |
} |
| 2254 | 2256 |
if (arc != INVALID) return arc; |
| 2255 | 2257 |
} |
| 2256 | 2258 |
_graph->findEdge(v, u, arc); |
| 2257 | 2259 |
while (arc != INVALID && (*_direction)[arc]) {
|
| 2258 | 2260 |
_graph->findEdge(u, v, arc); |
| 2259 | 2261 |
} |
| 2260 | 2262 |
return arc; |
| 2261 | 2263 |
} |
| 2262 | 2264 |
|
| 2263 | 2265 |
Node addNode() {
|
| 2264 | 2266 |
return Node(_graph->addNode()); |
| 2265 | 2267 |
} |
| 2266 | 2268 |
|
| 2267 | 2269 |
Arc addArc(const Node& u, const Node& v) {
|
| 2268 | 2270 |
Arc arc = _graph->addArc(u, v); |
| 2269 | 2271 |
_direction->set(arc, _graph->source(arc) == u); |
| 2270 | 2272 |
return arc; |
| 2271 | 2273 |
} |
| 2272 | 2274 |
|
| 2273 | 2275 |
void erase(const Node& i) { _graph->erase(i); }
|
| 2274 | 2276 |
void erase(const Arc& i) { _graph->erase(i); }
|
| 2275 | 2277 |
|
| 2276 | 2278 |
void clear() { _graph->clear(); }
|
| 2277 | 2279 |
|
| 2278 | 2280 |
int id(const Node& v) const { return _graph->id(v); }
|
| 2279 | 2281 |
int id(const Arc& e) const { return _graph->id(e); }
|
| 2280 | 2282 |
|
| 2281 | 2283 |
Node nodeFromId(int idx) const { return _graph->nodeFromId(idx); }
|
| 2282 | 2284 |
Arc arcFromId(int idx) const { return _graph->edgeFromId(idx); }
|
| 2283 | 2285 |
|
| 2284 | 2286 |
int maxNodeId() const { return _graph->maxNodeId(); }
|
| 2285 | 2287 |
int maxArcId() const { return _graph->maxEdgeId(); }
|
| 2286 | 2288 |
|
| 2287 | 2289 |
typedef typename ItemSetTraits<Graph, Node>::ItemNotifier NodeNotifier; |
| 2288 | 2290 |
NodeNotifier& notifier(Node) const { return _graph->notifier(Node()); }
|
| 2289 | 2291 |
|
| 2290 | 2292 |
typedef typename ItemSetTraits<Graph, Arc>::ItemNotifier ArcNotifier; |
| 2291 | 2293 |
ArcNotifier& notifier(Arc) const { return _graph->notifier(Arc()); }
|
| 2292 | 2294 |
|
| 2293 | 2295 |
template <typename _Value> |
| 2294 | 2296 |
class NodeMap : public _Graph::template NodeMap<_Value> {
|
| ... | ... |
@@ -3052,111 +3054,111 @@ |
| 3052 | 3054 |
|
| 3053 | 3055 |
private: |
| 3054 | 3056 |
ArcMap& operator=(const ArcMap& cmap) {
|
| 3055 | 3057 |
return operator=<ArcMap>(cmap); |
| 3056 | 3058 |
} |
| 3057 | 3059 |
|
| 3058 | 3060 |
template <typename CMap> |
| 3059 | 3061 |
ArcMap& operator=(const CMap& cmap) {
|
| 3060 | 3062 |
Parent::operator=(cmap); |
| 3061 | 3063 |
return *this; |
| 3062 | 3064 |
} |
| 3063 | 3065 |
}; |
| 3064 | 3066 |
|
| 3065 | 3067 |
protected: |
| 3066 | 3068 |
|
| 3067 | 3069 |
SplitNodesBase() : _digraph(0) {}
|
| 3068 | 3070 |
|
| 3069 | 3071 |
Digraph* _digraph; |
| 3070 | 3072 |
|
| 3071 | 3073 |
void setDigraph(Digraph& digraph) {
|
| 3072 | 3074 |
_digraph = &digraph; |
| 3073 | 3075 |
} |
| 3074 | 3076 |
|
| 3075 | 3077 |
}; |
| 3076 | 3078 |
|
| 3077 | 3079 |
/// \ingroup graph_adaptors |
| 3078 | 3080 |
/// |
| 3079 | 3081 |
/// \brief Split the nodes of a directed graph |
| 3080 | 3082 |
/// |
| 3081 | 3083 |
/// The SplitNodes adaptor splits each node into an in-node and an |
| 3082 | 3084 |
/// out-node. Formaly, the adaptor replaces each \f$ u \f$ node in |
| 3083 | 3085 |
/// the digraph with two nodes(namely node \f$ u_{in} \f$ and node
|
| 3084 | 3086 |
/// \f$ u_{out} \f$). If there is a \f$ (v, u) \f$ arc in the
|
| 3085 | 3087 |
/// original digraph the new target of the arc will be \f$ u_{in} \f$
|
| 3086 | 3088 |
/// and similarly the source of the original \f$ (u, v) \f$ arc |
| 3087 | 3089 |
/// will be \f$ u_{out} \f$. The adaptor will add for each node in
|
| 3088 | 3090 |
/// the original digraph an additional arc which connects |
| 3089 | 3091 |
/// \f$ (u_{in}, u_{out}) \f$.
|
| 3090 | 3092 |
/// |
| 3091 | 3093 |
/// The aim of this class is to run algorithm with node costs if the |
| 3092 | 3094 |
/// algorithm can use directly just arc costs. In this case we should use |
| 3093 | 3095 |
/// a \c SplitNodes and set the node cost of the graph to the |
| 3094 | 3096 |
/// bind arc in the adapted graph. |
| 3095 | 3097 |
/// |
| 3096 | 3098 |
/// \tparam _Digraph It must be conform to the \ref concepts::Digraph |
| 3097 | 3099 |
/// "Digraph concept". The type can be specified to be const. |
| 3098 | 3100 |
template <typename _Digraph> |
| 3099 | 3101 |
class SplitNodes |
| 3100 |
: public DigraphAdaptorExtender<SplitNodesBase<_Digraph> > {
|
|
| 3102 |
: public DigraphAdaptorExtender<SplitNodesBase<const _Digraph> > {
|
|
| 3101 | 3103 |
public: |
| 3102 | 3104 |
typedef _Digraph Digraph; |
| 3103 |
typedef DigraphAdaptorExtender<SplitNodesBase<Digraph> > Parent; |
|
| 3105 |
typedef DigraphAdaptorExtender<SplitNodesBase<const Digraph> > Parent; |
|
| 3104 | 3106 |
|
| 3105 | 3107 |
typedef typename Digraph::Node DigraphNode; |
| 3106 | 3108 |
typedef typename Digraph::Arc DigraphArc; |
| 3107 | 3109 |
|
| 3108 | 3110 |
typedef typename Parent::Node Node; |
| 3109 | 3111 |
typedef typename Parent::Arc Arc; |
| 3110 | 3112 |
|
| 3111 | 3113 |
/// \brief Constructor of the adaptor. |
| 3112 | 3114 |
/// |
| 3113 | 3115 |
/// Constructor of the adaptor. |
| 3114 |
SplitNodes(Digraph& g) {
|
|
| 3116 |
SplitNodes(const Digraph& g) {
|
|
| 3115 | 3117 |
Parent::setDigraph(g); |
| 3116 | 3118 |
} |
| 3117 | 3119 |
|
| 3118 | 3120 |
/// \brief Returns true when the node is in-node. |
| 3119 | 3121 |
/// |
| 3120 | 3122 |
/// Returns true when the node is in-node. |
| 3121 | 3123 |
static bool inNode(const Node& n) {
|
| 3122 | 3124 |
return Parent::inNode(n); |
| 3123 | 3125 |
} |
| 3124 | 3126 |
|
| 3125 | 3127 |
/// \brief Returns true when the node is out-node. |
| 3126 | 3128 |
/// |
| 3127 | 3129 |
/// Returns true when the node is out-node. |
| 3128 | 3130 |
static bool outNode(const Node& n) {
|
| 3129 | 3131 |
return Parent::outNode(n); |
| 3130 | 3132 |
} |
| 3131 | 3133 |
|
| 3132 | 3134 |
/// \brief Returns true when the arc is arc in the original digraph. |
| 3133 | 3135 |
/// |
| 3134 | 3136 |
/// Returns true when the arc is arc in the original digraph. |
| 3135 | 3137 |
static bool origArc(const Arc& a) {
|
| 3136 | 3138 |
return Parent::origArc(a); |
| 3137 | 3139 |
} |
| 3138 | 3140 |
|
| 3139 | 3141 |
/// \brief Returns true when the arc binds an in-node and an out-node. |
| 3140 | 3142 |
/// |
| 3141 | 3143 |
/// Returns true when the arc binds an in-node and an out-node. |
| 3142 | 3144 |
static bool bindArc(const Arc& a) {
|
| 3143 | 3145 |
return Parent::bindArc(a); |
| 3144 | 3146 |
} |
| 3145 | 3147 |
|
| 3146 | 3148 |
/// \brief Gives back the in-node created from the \c node. |
| 3147 | 3149 |
/// |
| 3148 | 3150 |
/// Gives back the in-node created from the \c node. |
| 3149 | 3151 |
static Node inNode(const DigraphNode& n) {
|
| 3150 | 3152 |
return Parent::inNode(n); |
| 3151 | 3153 |
} |
| 3152 | 3154 |
|
| 3153 | 3155 |
/// \brief Gives back the out-node created from the \c node. |
| 3154 | 3156 |
/// |
| 3155 | 3157 |
/// Gives back the out-node created from the \c node. |
| 3156 | 3158 |
static Node outNode(const DigraphNode& n) {
|
| 3157 | 3159 |
return Parent::outNode(n); |
| 3158 | 3160 |
} |
| 3159 | 3161 |
|
| 3160 | 3162 |
/// \brief Gives back the arc binds the two part of the node. |
| 3161 | 3163 |
/// |
| 3162 | 3164 |
/// Gives back the arc binds the two part of the node. |
0 comments (0 inline)