Changeset 148:004fdf703abb in lemon-0.x for src/work/marci
- Timestamp:
- 03/03/04 15:30:38 (21 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@208
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
src/work/marci/graph_wrapper.h
r105 r148 276 276 277 277 278 // FIXME: comparison should be made better!!! 279 template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap> 280 class ResGraphWrapper 281 { 282 Graph* graph; 283 284 public: 285 typedef Graph BaseGraph; 286 287 typedef typename Graph::NodeIt NodeIt; 288 typedef typename Graph::EdgeIt EdgeIt; 289 290 typedef typename Graph::EachNodeIt EachNodeIt; 278 279 // // FIXME: comparison should be made better!!! 280 // template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap> 281 // class ResGraphWrapper 282 // { 283 // Graph* graph; 284 285 // public: 286 // typedef Graph BaseGraph; 287 288 // typedef typename Graph::NodeIt NodeIt; 289 // typedef typename Graph::EdgeIt EdgeIt; 290 291 // typedef typename Graph::EachNodeIt EachNodeIt; 291 292 292 class OutEdgeIt {293 public:294 //Graph::NodeIt n;295 bool out_or_in;296 typename Graph::OutEdgeIt o;297 typename Graph::InEdgeIt i;298 };299 class InEdgeIt {300 public:301 //Graph::NodeIt n;302 bool out_or_in;303 typename Graph::OutEdgeIt o;304 typename Graph::InEdgeIt i;305 };306 typedef typename Graph::SymEdgeIt SymEdgeIt;307 typedef typename Graph::EachEdgeIt EachEdgeIt;308 309 int nodeNum() const { return graph->nodeNum(); }310 int edgeNum() const { return graph->edgeNum(); }311 312 NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); }313 314 // EachEdge and SymEdge is missing!!!!315 // EdgeIt <-> In/OutEdgeIt conversion is missing!!!!316 317 //FIXME318 OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const319 {320 e.n=n;321 graph->getFirst(e.o,n);322 while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))323 graph->goNext(e.o);324 if(!graph->valid(e.o)) {325 graph->getFirst(e.i,n);326 while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))327 graph->goNext(e.i);328 }329 return e;330 }331 / *332 OutEdgeIt &goNext(OutEdgeIt &e)333 {334 if(graph->valid(e.o)) {335 while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))336 graph->goNext(e.o);337 if(graph->valid(e.o)) return e;338 else graph->getFirst(e.i,e.n);339 }340 else {341 while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))342 graph->goNext(e.i);343 return e;344 }345 }346 OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}347 */348 //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);}349 350 //FIXME351 InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const352 {353 e.n=n;354 graph->getFirst(e.i,n);355 while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))356 graph->goNext(e.i);357 if(!graph->valid(e.i)) {358 graph->getFirst(e.o,n);359 while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))360 graph->goNext(e.o);361 }362 return e;363 }364 / *365 InEdgeIt &goNext(InEdgeIt &e)366 {367 if(graph->valid(e.i)) {368 while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))369 graph->goNext(e.i);370 if(graph->valid(e.i)) return e;371 else graph->getFirst(e.o,e.n);372 }373 else {374 while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))375 graph->goNext(e.o);376 return e;377 }378 }379 InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}380 */381 //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);}382 383 //template<typename I> I &goNext(I &i); { return graph->goNext(i); }384 //template<typename I> I next(const I i); { return graph->goNext(i); }385 386 template< typename It > It first() const {387 It e; getFirst(e); return e; }388 389 template< typename It > It first(NodeIt v) const {390 It e; getFirst(e, v); return e; }391 392 NodeIt head(const EdgeIt& e) const { return graph->head(e); }393 NodeIt tail(const EdgeIt& e) const { return graph->tail(e); }394 395 template<typename I> NodeIt aNode(const I& e) const {396 return graph->aNode(e); }397 template<typename I> NodeIt bNode(const I& e) const {398 return graph->bNode(e); }399 400 //template<typename I> bool valid(const I i);401 //{ return graph->valid(i); }402 403 //template<typename I> void setInvalid(const I &i);404 //{ return graph->setInvalid(i); }405 406 NodeIt addNode() { return graph->addNode(); }407 EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) {408 return graph->addEdge(tail, head); }409 410 template<typename I> void erase(const I& i) { graph->erase(i); }411 412 void clear() { graph->clear(); }413 414 template<typename S> class NodeMap : public Graph::NodeMap<S> { };415 template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };416 417 void setGraph(Graph& _graph) { graph = &_graph; }418 Graph& getGraph() { return (*graph); }419 420 //ResGraphWrapper() : graph(0) { }421 ResGraphWrapper(Graph& _graph) : graph(&_graph) { }422 };423 424 425 // FIXME: comparison should be made better!!!426 template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap>427 class ConstResGraphWrapper428 {429 const Graph* graph;430 const LowerMap* low;431 FlowMap* flow;432 const UpperMap* up;433 public:434 typedef Graph BaseGraph;435 436 typedef typename Graph::NodeIt NodeIt;437 typedef typename Graph::EdgeIt EdgeIt;438 439 typedef typename Graph::EachNodeIt EachNodeIt;293 // class OutEdgeIt { 294 // public: 295 // //Graph::NodeIt n; 296 // bool out_or_in; 297 // typename Graph::OutEdgeIt o; 298 // typename Graph::InEdgeIt i; 299 // }; 300 // class InEdgeIt { 301 // public: 302 // //Graph::NodeIt n; 303 // bool out_or_in; 304 // typename Graph::OutEdgeIt o; 305 // typename Graph::InEdgeIt i; 306 // }; 307 // typedef typename Graph::SymEdgeIt SymEdgeIt; 308 // typedef typename Graph::EachEdgeIt EachEdgeIt; 309 310 // int nodeNum() const { return graph->nodeNum(); } 311 // int edgeNum() const { return graph->edgeNum(); } 312 313 // NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); } 314 315 // // EachEdge and SymEdge is missing!!!! 316 // // EdgeIt <-> In/OutEdgeIt conversion is missing!!!! 317 318 // //FIXME 319 // OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const 320 // { 321 // e.n=n; 322 // graph->getFirst(e.o,n); 323 // while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) 324 // graph->goNext(e.o); 325 // if(!graph->valid(e.o)) { 326 // graph->getFirst(e.i,n); 327 // while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) 328 // graph->goNext(e.i); 329 // } 330 // return e; 331 // } 332 // /* 333 // OutEdgeIt &goNext(OutEdgeIt &e) 334 // { 335 // if(graph->valid(e.o)) { 336 // while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) 337 // graph->goNext(e.o); 338 // if(graph->valid(e.o)) return e; 339 // else graph->getFirst(e.i,e.n); 340 // } 341 // else { 342 // while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) 343 // graph->goNext(e.i); 344 // return e; 345 // } 346 // } 347 // OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);} 348 // */ 349 // //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);} 350 351 // //FIXME 352 // InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const 353 // { 354 // e.n=n; 355 // graph->getFirst(e.i,n); 356 // while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) 357 // graph->goNext(e.i); 358 // if(!graph->valid(e.i)) { 359 // graph->getFirst(e.o,n); 360 // while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) 361 // graph->goNext(e.o); 362 // } 363 // return e; 364 // } 365 // /* 366 // InEdgeIt &goNext(InEdgeIt &e) 367 // { 368 // if(graph->valid(e.i)) { 369 // while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) 370 // graph->goNext(e.i); 371 // if(graph->valid(e.i)) return e; 372 // else graph->getFirst(e.o,e.n); 373 // } 374 // else { 375 // while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) 376 // graph->goNext(e.o); 377 // return e; 378 // } 379 // } 380 // InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);} 381 // */ 382 // //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);} 383 384 // //template<typename I> I &goNext(I &i); { return graph->goNext(i); } 385 // //template<typename I> I next(const I i); { return graph->goNext(i); } 386 387 // template< typename It > It first() const { 388 // It e; getFirst(e); return e; } 389 390 // template< typename It > It first(NodeIt v) const { 391 // It e; getFirst(e, v); return e; } 392 393 // NodeIt head(const EdgeIt& e) const { return graph->head(e); } 394 // NodeIt tail(const EdgeIt& e) const { return graph->tail(e); } 395 396 // template<typename I> NodeIt aNode(const I& e) const { 397 // return graph->aNode(e); } 398 // template<typename I> NodeIt bNode(const I& e) const { 399 // return graph->bNode(e); } 400 401 // //template<typename I> bool valid(const I i); 402 // //{ return graph->valid(i); } 403 404 // //template<typename I> void setInvalid(const I &i); 405 // //{ return graph->setInvalid(i); } 406 407 // NodeIt addNode() { return graph->addNode(); } 408 // EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { 409 // return graph->addEdge(tail, head); } 410 411 // template<typename I> void erase(const I& i) { graph->erase(i); } 412 413 // void clear() { graph->clear(); } 414 415 // template<typename S> class NodeMap : public Graph::NodeMap<S> { }; 416 // template<typename S> class EdgeMap : public Graph::EdgeMap<S> { }; 417 418 // void setGraph(Graph& _graph) { graph = &_graph; } 419 // Graph& getGraph() { return (*graph); } 420 421 // //ResGraphWrapper() : graph(0) { } 422 // ResGraphWrapper(Graph& _graph) : graph(&_graph) { } 423 // }; 424 425 426 // // FIXME: comparison should be made better!!! 427 // template<typename Graph, typename T, typename LowerMap, typename FlowMap, typename UpperMap> 428 // class ConstResGraphWrapper 429 // { 430 // const Graph* graph; 431 // const LowerMap* low; 432 // FlowMap* flow; 433 // const UpperMap* up; 434 // public: 435 // typedef Graph BaseGraph; 436 437 // typedef typename Graph::NodeIt NodeIt; 438 // typedef typename Graph::EdgeIt EdgeIt; 439 440 // typedef typename Graph::EachNodeIt EachNodeIt; 440 441 441 class OutEdgeIt {442 public:443 //Graph::NodeIt n;444 bool out_or_in;445 typename Graph::SymEdgeIt sym;446 };447 class InEdgeIt {448 public:449 //Graph::NodeIt n;450 bool out_or_in;451 typename Graph::OutEdgeIt sym;452 };453 //typedef typename Graph::SymEdgeIt SymEdgeIt;454 //typedef typename Graph::EachEdgeIt EachEdgeIt;455 456 int nodeNum() const { return graph->nodeNum(); }457 //int edgeNum() const { return graph->edgeNum(); }458 459 NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); }460 461 // EachEdge and SymEdge is missing!!!!462 // EdgeIt <-> In/OutEdgeIt conversion is missing!!!!442 // class OutEdgeIt { 443 // public: 444 // //Graph::NodeIt n; 445 // bool out_or_in; 446 // typename Graph::SymEdgeIt sym; 447 // }; 448 // class InEdgeIt { 449 // public: 450 // //Graph::NodeIt n; 451 // bool out_or_in; 452 // typename Graph::OutEdgeIt sym; 453 // }; 454 // //typedef typename Graph::SymEdgeIt SymEdgeIt; 455 // //typedef typename Graph::EachEdgeIt EachEdgeIt; 456 457 // int nodeNum() const { return graph->nodeNum(); } 458 // //int edgeNum() const { return graph->edgeNum(); } 459 460 // NodeIt& getFirst(NodeIt& n) const { return graph->getFirst(n); } 461 462 // // EachEdge and SymEdge is missing!!!! 463 // // EdgeIt <-> In/OutEdgeIt conversion is missing!!!! 463 464 464 465 465 //FIXME466 OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const467 {468 e.n=n;469 graph->getFirst(e.o,n);470 while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))471 graph->goNext(e.o);472 if(!graph->valid(e.o)) {473 graph->getFirst(e.i,n);474 while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))475 graph->goNext(e.i);476 }477 return e;478 }479 / *480 OutEdgeIt &goNext(OutEdgeIt &e)481 {482 if(graph->valid(e.o)) {483 while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o))484 graph->goNext(e.o);485 if(graph->valid(e.o)) return e;486 else graph->getFirst(e.i,e.n);487 }488 else {489 while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i))490 graph->goNext(e.i);491 return e;492 }493 }494 OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);}495 */496 //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);}497 498 //FIXME499 InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const500 {501 e.n=n;502 graph->getFirst(e.i,n);503 while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))504 graph->goNext(e.i);505 if(!graph->valid(e.i)) {506 graph->getFirst(e.o,n);507 while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))508 graph->goNext(e.o);509 }510 return e;511 }512 / *513 InEdgeIt &goNext(InEdgeIt &e)514 {515 if(graph->valid(e.i)) {516 while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i))517 graph->goNext(e.i);518 if(graph->valid(e.i)) return e;519 else graph->getFirst(e.o,e.n);520 }521 else {522 while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o))523 graph->goNext(e.o);524 return e;525 }526 }527 InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);}528 */529 //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);}530 531 //template<typename I> I &goNext(I &i); { return graph->goNext(i); }532 //template<typename I> I next(const I i); { return graph->goNext(i); }533 534 template< typename It > It first() const {535 It e; getFirst(e); return e; }536 537 template< typename It > It first(NodeIt v) const {538 It e; getFirst(e, v); return e; }539 540 NodeIt head(const EdgeIt& e) const { return graph->head(e); }541 NodeIt tail(const EdgeIt& e) const { return graph->tail(e); }542 543 template<typename I> NodeIt aNode(const I& e) const {544 return graph->aNode(e); }545 template<typename I> NodeIt bNode(const I& e) const {546 return graph->bNode(e); }547 548 //template<typename I> bool valid(const I i);549 //{ return graph->valid(i); }550 551 //template<typename I> void setInvalid(const I &i);552 //{ return graph->setInvalid(i); }553 554 NodeIt addNode() { return graph->addNode(); }555 EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) {556 return graph->addEdge(tail, head); }557 558 template<typename I> void erase(const I& i) { graph->erase(i); }559 560 void clear() { graph->clear(); }561 562 template<typename S> class NodeMap : public Graph::NodeMap<S> { };563 template<typename S> class EdgeMap : public Graph::EdgeMap<S> { };564 565 void setGraph(const Graph& _graph) { graph = &_graph; }566 const Graph& getGraph() { return (*graph); }567 568 //ConstResGraphWrapper() : graph(0) { }569 ConstResGraphWrapper(const Graph& _graph) : graph(&_graph) { }570 };466 // //FIXME 467 // OutEdgeIt& getFirst(OutEdgeIt& e, const NodeIt& n) const 468 // { 469 // e.n=n; 470 // graph->getFirst(e.o,n); 471 // while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) 472 // graph->goNext(e.o); 473 // if(!graph->valid(e.o)) { 474 // graph->getFirst(e.i,n); 475 // while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) 476 // graph->goNext(e.i); 477 // } 478 // return e; 479 // } 480 // /* 481 // OutEdgeIt &goNext(OutEdgeIt &e) 482 // { 483 // if(graph->valid(e.o)) { 484 // while(graph->valid(e.o) && fmap.get(e.o)>=himap.get(e.o)) 485 // graph->goNext(e.o); 486 // if(graph->valid(e.o)) return e; 487 // else graph->getFirst(e.i,e.n); 488 // } 489 // else { 490 // while(graph->valid(e.i) && fmap.get(e.i)<=lomap.get(e.i)) 491 // graph->goNext(e.i); 492 // return e; 493 // } 494 // } 495 // OutEdgeIt Next(const OutEdgeIt &e) {OutEdgeIt t(e); return goNext(t);} 496 // */ 497 // //bool valid(const OutEdgeIt e) { return graph->valid(e.o)||graph->valid(e.i);} 498 499 // //FIXME 500 // InEdgeIt& getFirst(InEdgeIt& e, const NodeIt& n) const 501 // { 502 // e.n=n; 503 // graph->getFirst(e.i,n); 504 // while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) 505 // graph->goNext(e.i); 506 // if(!graph->valid(e.i)) { 507 // graph->getFirst(e.o,n); 508 // while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) 509 // graph->goNext(e.o); 510 // } 511 // return e; 512 // } 513 // /* 514 // InEdgeIt &goNext(InEdgeIt &e) 515 // { 516 // if(graph->valid(e.i)) { 517 // while(graph->valid(e.i) && fmap.get(e.i)>=himap.get(e.i)) 518 // graph->goNext(e.i); 519 // if(graph->valid(e.i)) return e; 520 // else graph->getFirst(e.o,e.n); 521 // } 522 // else { 523 // while(graph->valid(e.o) && fmap.get(e.o)<=lomap.get(e.o)) 524 // graph->goNext(e.o); 525 // return e; 526 // } 527 // } 528 // InEdgeIt Next(const InEdgeIt &e) {InEdgeIt t(e); return goNext(t);} 529 // */ 530 // //bool valid(const InEdgeIt e) { return graph->valid(e.i)||graph->valid(e.o);} 531 532 // //template<typename I> I &goNext(I &i); { return graph->goNext(i); } 533 // //template<typename I> I next(const I i); { return graph->goNext(i); } 534 535 // template< typename It > It first() const { 536 // It e; getFirst(e); return e; } 537 538 // template< typename It > It first(NodeIt v) const { 539 // It e; getFirst(e, v); return e; } 540 541 // NodeIt head(const EdgeIt& e) const { return graph->head(e); } 542 // NodeIt tail(const EdgeIt& e) const { return graph->tail(e); } 543 544 // template<typename I> NodeIt aNode(const I& e) const { 545 // return graph->aNode(e); } 546 // template<typename I> NodeIt bNode(const I& e) const { 547 // return graph->bNode(e); } 548 549 // //template<typename I> bool valid(const I i); 550 // //{ return graph->valid(i); } 551 552 // //template<typename I> void setInvalid(const I &i); 553 // //{ return graph->setInvalid(i); } 554 555 // NodeIt addNode() { return graph->addNode(); } 556 // EdgeIt addEdge(const NodeIt& tail, const NodeIt& head) { 557 // return graph->addEdge(tail, head); } 558 559 // template<typename I> void erase(const I& i) { graph->erase(i); } 560 561 // void clear() { graph->clear(); } 562 563 // template<typename S> class NodeMap : public Graph::NodeMap<S> { }; 564 // template<typename S> class EdgeMap : public Graph::EdgeMap<S> { }; 565 566 // void setGraph(const Graph& _graph) { graph = &_graph; } 567 // const Graph& getGraph() { return (*graph); } 568 569 // //ConstResGraphWrapper() : graph(0) { } 570 // ConstResGraphWrapper(const Graph& _graph) : graph(&_graph) { } 571 // }; 571 572 572 573
Note: See TracChangeset
for help on using the changeset viewer.