Changeset 938:70e2886211d5 in lemon0.x for src/lemon
 Timestamp:
 10/05/04 11:41:05 (18 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1266
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/lemon/skeletons/graph.h
r921 r938 46 46 /// like @ref ListGraph or 47 47 /// @ref SmartGraph will just refer to this structure. 48 /// 49 /// \todo A pages describing the concept of concept description would 50 /// be nice. 48 51 class StaticGraph 49 52 { … … 443 446 }; 444 447 445 448 struct DummyType { 449 int value; 450 DummyType() {} 451 DummyType(int p) : value(p) {} 452 DummyType& operator=(int p) { value = p; return *this;} 453 }; 454 455 ///\brief Checks whether \c G meets the 456 ///\ref lemon::skeleton::StaticGraph "StaticGraph" concept 457 template<class Graph> void checkCompileStaticGraph(Graph &G) 458 { 459 typedef typename Graph::Node Node; 460 typedef typename Graph::NodeIt NodeIt; 461 typedef typename Graph::Edge Edge; 462 typedef typename Graph::EdgeIt EdgeIt; 463 typedef typename Graph::InEdgeIt InEdgeIt; 464 typedef typename Graph::OutEdgeIt OutEdgeIt; 446 465 466 { 467 Node i; Node j(i); Node k(INVALID); 468 i=j; 469 bool b; b=true; 470 b=(i==INVALID); b=(i!=INVALID); 471 b=(i==j); b=(i!=j); b=(i<j); 472 } 473 { 474 NodeIt i; NodeIt j(i); NodeIt k(INVALID); NodeIt l(G); 475 i=j; 476 j=G.first(i); 477 j=++i; 478 bool b; b=true; 479 b=(i==INVALID); b=(i!=INVALID); 480 Node n(i); 481 n=i; 482 b=(i==j); b=(i!=j); b=(i<j); 483 //Node >NodeIt conversion 484 NodeIt ni(G,n); 485 } 486 { 487 Edge i; Edge j(i); Edge k(INVALID); 488 i=j; 489 bool b; b=true; 490 b=(i==INVALID); b=(i!=INVALID); 491 b=(i==j); b=(i!=j); b=(i<j); 492 } 493 { 494 EdgeIt i; EdgeIt j(i); EdgeIt k(INVALID); EdgeIt l(G); 495 i=j; 496 j=G.first(i); 497 j=++i; 498 bool b; b=true; 499 b=(i==INVALID); b=(i!=INVALID); 500 Edge e(i); 501 e=i; 502 b=(i==j); b=(i!=j); b=(i<j); 503 //Edge >EdgeIt conversion 504 EdgeIt ei(G,e); 505 } 506 { 507 Node n; 508 InEdgeIt i; InEdgeIt j(i); InEdgeIt k(INVALID); InEdgeIt l(G,n); 509 i=j; 510 j=G.first(i,n); 511 j=++i; 512 bool b; b=true; 513 b=(i==INVALID); b=(i!=INVALID); 514 Edge e(i); 515 e=i; 516 b=(i==j); b=(i!=j); b=(i<j); 517 //Edge >InEdgeIt conversion 518 InEdgeIt ei(G,e); 519 } 520 { 521 Node n; 522 OutEdgeIt i; OutEdgeIt j(i); OutEdgeIt k(INVALID); OutEdgeIt l(G,n); 523 i=j; 524 j=G.first(i,n); 525 j=++i; 526 bool b; b=true; 527 b=(i==INVALID); b=(i!=INVALID); 528 Edge e(i); 529 e=i; 530 b=(i==j); b=(i!=j); b=(i<j); 531 //Edge >OutEdgeIt conversion 532 OutEdgeIt ei(G,e); 533 } 534 { 535 Node n,m; 536 n=m=INVALID; 537 Edge e; 538 e=INVALID; 539 n=G.tail(e); 540 n=G.head(e); 541 } 542 // id tests 543 { Node n; int i=G.id(n); i=i; } 544 { Edge e; int i=G.id(e); i=i; } 545 //NodeMap tests 546 { 547 Node k; 548 typename Graph::template NodeMap<int> m(G); 549 //Const map 550 typename Graph::template NodeMap<int> const &cm = m; 551 //Inicialize with default value 552 typename Graph::template NodeMap<int> mdef(G,12); 553 //Copy 554 typename Graph::template NodeMap<int> mm(cm); 555 //Copy from another type 556 typename Graph::template NodeMap<double> dm(cm); 557 //Copy to more complex type 558 typename Graph::template NodeMap<DummyType> em(cm); 559 int v; 560 v=m[k]; m[k]=v; m.set(k,v); 561 v=cm[k]; 562 563 m=cm; 564 dm=cm; //Copy from another type 565 em=cm; //Copy to more complex type 566 { 567 //Check the typedef's 568 typename Graph::template NodeMap<int>::ValueType val; 569 val=1; 570 typename Graph::template NodeMap<int>::KeyType key; 571 key = typename Graph::NodeIt(G); 572 } 573 } 574 { //bool NodeMap 575 Node k; 576 typename Graph::template NodeMap<bool> m(G); 577 typename Graph::template NodeMap<bool> const &cm = m; //Const map 578 //Inicialize with default value 579 typename Graph::template NodeMap<bool> mdef(G,12); 580 typename Graph::template NodeMap<bool> mm(cm); //Copy 581 typename Graph::template NodeMap<int> dm(cm); //Copy from another type 582 bool v; 583 v=m[k]; m[k]=v; m.set(k,v); 584 v=cm[k]; 585 586 m=cm; 587 dm=cm; //Copy from another type 588 m=dm; //Copy to another type 589 590 { 591 //Check the typedef's 592 typename Graph::template NodeMap<bool>::ValueType val; 593 val=true; 594 typename Graph::template NodeMap<bool>::KeyType key; 595 key= typename Graph::NodeIt(G); 596 } 597 } 598 //EdgeMap tests 599 { 600 Edge k; 601 typename Graph::template EdgeMap<int> m(G); 602 typename Graph::template EdgeMap<int> const &cm = m; //Const map 603 //Inicialize with default value 604 typename Graph::template EdgeMap<int> mdef(G,12); 605 typename Graph::template EdgeMap<int> mm(cm); //Copy 606 typename Graph::template EdgeMap<double> dm(cm);//Copy from another type 607 int v; 608 v=m[k]; m[k]=v; m.set(k,v); 609 v=cm[k]; 610 611 m=cm; 612 dm=cm; //Copy from another type 613 { 614 //Check the typedef's 615 typename Graph::template EdgeMap<int>::ValueType val; 616 val=1; 617 typename Graph::template EdgeMap<int>::KeyType key; 618 key= typename Graph::EdgeIt(G); 619 } 620 } 621 { //bool EdgeMap 622 Edge k; 623 typename Graph::template EdgeMap<bool> m(G); 624 typename Graph::template EdgeMap<bool> const &cm = m; //Const map 625 //Inicialize with default value 626 typename Graph::template EdgeMap<bool> mdef(G,12); 627 typename Graph::template EdgeMap<bool> mm(cm); //Copy 628 typename Graph::template EdgeMap<int> dm(cm); //Copy from another type 629 bool v; 630 v=m[k]; m[k]=v; m.set(k,v); 631 v=cm[k]; 632 633 m=cm; 634 dm=cm; //Copy from another type 635 m=dm; //Copy to another type 636 { 637 //Check the typedef's 638 typename Graph::template EdgeMap<bool>::ValueType val; 639 val=true; 640 typename Graph::template EdgeMap<bool>::KeyType key; 641 key= typename Graph::EdgeIt(G); 642 } 643 } 644 } 645 447 646 /// An empty nonstatic graph class. 448 647 449 648 /// This class provides everything that \ref StaticGraph 450 649 /// with additional functionality which enables to build a … … 478 677 }; 479 678 679 680 ///\brief Checks whether \c G meets the 681 ///\ref lemon::skeleton::ExtendableGraph "ExtendableGraph" concept 682 template<class Graph> void checkCompileExtendableGraph(Graph &G) 683 { 684 checkCompileStaticGraph(G); 685 686 typedef typename Graph::Node Node; 687 typedef typename Graph::NodeIt NodeIt; 688 typedef typename Graph::Edge Edge; 689 typedef typename Graph::EdgeIt EdgeIt; 690 typedef typename Graph::InEdgeIt InEdgeIt; 691 typedef typename Graph::OutEdgeIt OutEdgeIt; 692 693 Node n,m; 694 n=G.addNode(); 695 m=G.addNode(); 696 Edge e; 697 e=G.addEdge(n,m); 698 699 // G.clear(); 700 } 701 702 480 703 /// An empty erasable graph class. 481 704 … … 501 724 void erase(Edge e) { } 502 725 }; 503 726 727 template<class Graph> void checkCompileGraphEraseEdge(Graph &G) 728 { 729 typename Graph::Edge e; 730 G.erase(e); 731 } 732 733 template<class Graph> void checkCompileGraphEraseNode(Graph &G) 734 { 735 typename Graph::Node n; 736 G.erase(n); 737 } 738 739 ///\brief Checks whether \c G meets the 740 ///\ref lemon::skeleton::EresableGraph "EresableGraph" concept 741 template<class Graph> void checkCompileErasableGraph(Graph &G) 742 { 743 checkCompileExtendableGraph(G); 744 checkCompileGraphEraseNode(G); 745 checkCompileGraphEraseEdge(G); 746 } 747 748 ///Checks whether a graph has findEdge() member function. 749 750 ///\todo findEdge() might be a global function. 751 /// 752 template<class Graph> void checkCompileGraphFindEdge(Graph &G) 753 { 754 typedef typename Graph::NodeIt Node; 755 typedef typename Graph::NodeIt NodeIt; 756 757 G.findEdge(NodeIt(G),++NodeIt(G),G.findEdge(NodeIt(G),++NodeIt(G))); 758 G.findEdge(Node(),Node(),G.findEdge(Node(),Node())); 759 } 760 504 761 // @} 505 762 } //namespace skeleton
Note: See TracChangeset
for help on using the changeset viewer.