Changeset 1980:a954b780e3ab in lemon-0.x
- Timestamp:
- 02/23/06 09:55:54 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2573
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/concept/ugraph.h
r1979 r1980 865 865 866 866 867 void firstInc(UEdge &, bool &, const Node &) const {} 868 869 void nextInc(UEdge &, bool &) const {} 870 867 871 /// \brief Base node of the iterator 868 872 /// -
lemon/graph_adaptor.h
r1979 r1980 699 699 700 700 template <typename _Graph> 701 class Undir ectGraphAdaptorBase :701 class UndirGraphAdaptorBase : 702 702 public UGraphBaseExtender<GraphAdaptorBase<_Graph> > { 703 703 public: … … 705 705 typedef UGraphBaseExtender<GraphAdaptorBase<_Graph> > Parent; 706 706 protected: 707 Undir ectGraphAdaptorBase() : Parent() { }707 UndirGraphAdaptorBase() : Parent() { } 708 708 public: 709 709 typedef typename Parent::UEdge UEdge; … … 713 713 class EdgeMap { 714 714 protected: 715 const Undir ectGraphAdaptorBase<_Graph>* g;715 const UndirGraphAdaptorBase<_Graph>* g; 716 716 template <typename TT> friend class EdgeMap; 717 717 typename _Graph::template EdgeMap<T> forward_map, backward_map; … … 720 720 typedef Edge Key; 721 721 722 EdgeMap(const Undir ectGraphAdaptorBase<_Graph>& _g) : g(&_g),722 EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g) : g(&_g), 723 723 forward_map(*(g->graph)), backward_map(*(g->graph)) { } 724 724 725 EdgeMap(const Undir ectGraphAdaptorBase<_Graph>& _g, T a) : g(&_g),725 EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g, T a) : g(&_g), 726 726 forward_map(*(g->graph), a), backward_map(*(g->graph), a) { } 727 727 … … 749 749 typedef UEdge Key; 750 750 751 UEdgeMap(const Undir ectGraphAdaptorBase<_Graph>& g) :751 UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g) : 752 752 map(*(g.graph)) { } 753 753 754 UEdgeMap(const Undir ectGraphAdaptorBase<_Graph>& g, T a) :754 UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g, T a) : 755 755 map(*(g.graph), a) { } 756 756 … … 774 774 /// \author Marton Makai 775 775 template<typename _Graph> 776 class Undir ectGraphAdaptor :776 class UndirGraphAdaptor : 777 777 public UGraphAdaptorExtender< 778 Undir ectGraphAdaptorBase<_Graph> > {778 UndirGraphAdaptorBase<_Graph> > { 779 779 public: 780 780 typedef _Graph Graph; 781 781 typedef UGraphAdaptorExtender< 782 Undir ectGraphAdaptorBase<_Graph> > Parent;782 UndirGraphAdaptorBase<_Graph> > Parent; 783 783 protected: 784 Undir ectGraphAdaptor() { }785 public: 786 Undir ectGraphAdaptor(_Graph& _graph) {784 UndirGraphAdaptor() { } 785 public: 786 UndirGraphAdaptor(_Graph& _graph) { 787 787 setGraph(_graph); 788 788 } -
lemon/ugraph_adaptor.h
r1979 r1980 512 512 /// graph. 513 513 /// 514 /// \warning Graph adaptors are in even more experimental state than the515 /// other parts of the lib. Use them at you own risk.516 ///517 514 /// SubUGraphAdaptor shows the undirected graph with filtered node-set and 518 515 /// edge-set. If the \c checked parameter is true then it filters the edgeset … … 529 526 /// \c Graph::Node that is why \c g.id(n) can be applied. 530 527 /// 531 /// For examples see also the documentation of NodeSubUGraphAdaptor and532 /// EdgeSubUGraphAdaptor.533 ///534 /// \author Marton Makai535 536 528 template<typename _UGraph, typename NodeFilterMap, 537 529 typename UEdgeFilterMap, bool checked = true> … … 554 546 }; 555 547 548 template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap> 549 SubUGraphAdaptor<const UGraph, NodeFilterMap, EdgeFilterMap> 550 subUGraphAdaptor(const UGraph& graph, 551 NodeFilterMap& nfm, EdgeFilterMap& efm) { 552 return SubUGraphAdaptor<const UGraph, NodeFilterMap, EdgeFilterMap> 553 (graph, nfm, efm); 554 } 555 556 template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap> 557 SubUGraphAdaptor<const UGraph, const NodeFilterMap, EdgeFilterMap> 558 subUGraphAdaptor(const UGraph& graph, 559 NodeFilterMap& nfm, EdgeFilterMap& efm) { 560 return SubUGraphAdaptor<const UGraph, const NodeFilterMap, EdgeFilterMap> 561 (graph, nfm, efm); 562 } 563 564 template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap> 565 SubUGraphAdaptor<const UGraph, NodeFilterMap, const EdgeFilterMap> 566 subUGraphAdaptor(const UGraph& graph, 567 NodeFilterMap& nfm, EdgeFilterMap& efm) { 568 return SubUGraphAdaptor<const UGraph, NodeFilterMap, const EdgeFilterMap> 569 (graph, nfm, efm); 570 } 571 572 template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap> 573 SubUGraphAdaptor<const UGraph, const NodeFilterMap, const EdgeFilterMap> 574 subUGraphAdaptor(const UGraph& graph, 575 NodeFilterMap& nfm, EdgeFilterMap& efm) { 576 return SubUGraphAdaptor<const UGraph, const NodeFilterMap, 577 const EdgeFilterMap>(graph, nfm, efm); 578 } 579 556 580 /// \ingroup graph_adaptors 557 581 /// 558 /// \brief An adaptor for hiding nodes from an undorected graph. 559 /// 560 /// \warning Graph adaptors are in even more experimental state 561 /// than the other 562 /// parts of the lib. Use them at you own risk. 582 /// \brief An adaptor for hiding nodes from an undirected graph. 583 /// 563 584 /// 564 585 /// An adaptor for hiding nodes from an undirected graph. … … 568 589 /// induced subgraph. But if the checked parameter is false then we can only 569 590 /// filter only isolated nodes. 570 /// \author Marton Makai571 591 template<typename _UGraph, typename NodeFilterMap, bool checked = true> 572 592 class NodeSubUGraphAdaptor : … … 610 630 /// only the edge-set 611 631 /// can be filtered. 612 ///613 ///\author Marton Makai614 632 template<typename _UGraph, typename UEdgeFilterMap> 615 633 class EdgeSubUGraphAdaptor : … … 644 662 645 663 template <typename _UGraph, typename _DirectionMap> 646 class Dir ectUGraphAdaptorBase {664 class DirUGraphAdaptorBase { 647 665 public: 648 666 … … 737 755 public: 738 756 typedef typename _UGraph::template NodeMap<_Value> Parent; 739 explicit NodeMap(const Dir ectUGraphAdaptorBase& ga)757 explicit NodeMap(const DirUGraphAdaptorBase& ga) 740 758 : Parent(*ga.graph) { } 741 NodeMap(const Dir ectUGraphAdaptorBase& ga, const _Value& value)759 NodeMap(const DirUGraphAdaptorBase& ga, const _Value& value) 742 760 : Parent(*ga.graph, value) { } 743 761 }; … … 746 764 class EdgeMap : public _UGraph::template UEdgeMap<_Value> { 747 765 public: 748 typedef typename _UGraph::template EdgeMap<_Value> Parent;749 explicit EdgeMap(const Dir ectUGraphAdaptorBase& ga)766 typedef typename _UGraph::template UEdgeMap<_Value> Parent; 767 explicit EdgeMap(const DirUGraphAdaptorBase& ga) 750 768 : Parent(*ga.graph) { } 751 EdgeMap(const Dir ectUGraphAdaptorBase& ga, const _Value& value)769 EdgeMap(const DirUGraphAdaptorBase& ga, const _Value& value) 752 770 : Parent(*ga.graph, value) { } 753 771 }; … … 770 788 771 789 772 template<typename _Graph, typename DirectionMap> 773 class DirectUGraphAdaptor : 790 /// \ingroup graph_adaptors 791 /// \brief A directed graph is made from a undirected graph by an adaptor 792 /// 793 /// This adaptor gives a direction for each uedge in the undirected graph. 794 /// The direction of the edges stored in the DirectionMap. This map is 795 /// a bool map on the undirected edges. If the uedge is mapped to true 796 /// then the direction of the directed edge will be the same as the 797 /// default direction of the uedge. The edges can be easily reverted 798 /// by the reverseEdge member in the adaptor. 799 template<typename _Graph, 800 typename DirectionMap = typename _Graph::template UEdgeMap<bool> > 801 class DirUGraphAdaptor : 774 802 public GraphAdaptorExtender< 775 Dir ectUGraphAdaptorBase<_Graph, DirectionMap> > {803 DirUGraphAdaptorBase<_Graph, DirectionMap> > { 776 804 public: 777 805 typedef _Graph Graph; 778 806 typedef GraphAdaptorExtender< 779 Dir ectUGraphAdaptorBase<_Graph, DirectionMap> > Parent;807 DirUGraphAdaptorBase<_Graph, DirectionMap> > Parent; 780 808 protected: 781 Dir ectUGraphAdaptor() { }782 public: 783 Dir ectUGraphAdaptor(_Graph& _graph, DirectionMap& _direction_map) {809 DirUGraphAdaptor() { } 810 public: 811 DirUGraphAdaptor(_Graph& _graph, DirectionMap& _direction_map) { 784 812 setGraph(_graph); 785 813 setDirectionMap(_direction_map); … … 788 816 789 817 template<typename UGraph, typename DirectionMap> 790 Dir ectUGraphAdaptor<const UGraph, DirectionMap>791 dir ectUGraphAdaptor(const UGraph& graph, DirectionMap& dm) {792 return Dir ectUGraphAdaptor<const UGraph, DirectionMap>(graph, dm);818 DirUGraphAdaptor<const UGraph, DirectionMap> 819 dirUGraphAdaptor(const UGraph& graph, DirectionMap& dm) { 820 return DirUGraphAdaptor<const UGraph, DirectionMap>(graph, dm); 793 821 } 794 822 795 823 template<typename UGraph, typename DirectionMap> 796 Dir ectUGraphAdaptor<const UGraph, const DirectionMap>797 dir ectUGraphAdaptor(const UGraph& graph, const DirectionMap& dm) {798 return Dir ectUGraphAdaptor<const UGraph, const DirectionMap>(graph, dm);824 DirUGraphAdaptor<const UGraph, const DirectionMap> 825 dirUGraphAdaptor(const UGraph& graph, const DirectionMap& dm) { 826 return DirUGraphAdaptor<const UGraph, const DirectionMap>(graph, dm); 799 827 } 800 828 -
test/graph_adaptor_test.cc
r1979 r1980 27 27 #include<lemon/full_graph.h> 28 28 #include<lemon/graph_adaptor.h> 29 #include<lemon/ugraph_adaptor.h> 29 30 30 31 #include"test/test_tools.h" … … 67 68 Graph::NodeMap<Graph::Edge> > >(); 68 69 69 /// \bug why does not compile with StaticGraph 70 checkConcept<UGraph, UndirectGraphAdaptor<ListGraph> >(); 70 checkConcept<UGraph, UndirGraphAdaptor<Graph> >(); 71 72 checkConcept<UGraph, SubUGraphAdaptor<UGraph, 73 UGraph::NodeMap<bool> , UGraph::UEdgeMap<bool> > >(); 74 checkConcept<UGraph, NodeSubUGraphAdaptor<UGraph, 75 UGraph::NodeMap<bool> > >(); 76 checkConcept<UGraph, EdgeSubUGraphAdaptor<UGraph, 77 UGraph::UEdgeMap<bool> > >(); 78 79 checkConcept<StaticGraph, DirUGraphAdaptor<UGraph, 80 UGraph::UEdgeMap<bool> > >(); 71 81 } 72 82 std::cout << __FILE__ ": All tests passed.\n";
Note: See TracChangeset
for help on using the changeset viewer.