Changeset 415:4b6112235fad in lemon1.2 for lemon/graph_adaptor.h
 Timestamp:
 11/30/08 19:00:30 (14 years ago)
 Branch:
 default
 Phase:
 public
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

lemon/graph_adaptor.h
r414 r415 32 32 namespace lemon { 33 33 34 /// \brief Base type for the Graph Adaptors35 ///36 /// This is the base type for most of LEMON graph adaptors.37 /// This class implements a trivial graph adaptor i.e. it only wraps the38 /// functions and types of the graph. The purpose of this class is to39 /// make easier implementing graph adaptors. E.g. if an adaptor is40 /// considered which differs from the wrapped graph only in some of its41 /// functions or types, then it can be derived from GraphAdaptor, and only42 /// the differences should be implemented.43 34 template<typename _Graph> 44 35 class GraphAdaptorBase { … … 196 187 }; 197 188 198 /// \ingroup graph_adaptors199 ///200 /// \brief Trivial graph adaptor201 ///202 /// This class is an adaptor which does not change the adapted undirected203 /// graph. It can be used only to test the graph adaptors.204 template <typename _Graph>205 class GraphAdaptor206 : public GraphAdaptorExtender< GraphAdaptorBase<_Graph> > {207 public:208 typedef _Graph Graph;209 typedef GraphAdaptorExtender<GraphAdaptorBase<_Graph> > Parent;210 protected:211 GraphAdaptor() : Parent() {}212 213 public:214 explicit GraphAdaptor(Graph& graph) { setGraph(graph); }215 };216 217 189 template <typename _Graph, typename NodeFilterMap, 218 190 typename EdgeFilterMap, bool checked = true> … … 319 291 } 320 292 321 /// \brief Hide the given node in the graph.322 ///323 /// This function hides \c n in the graph, i.e. the iteration324 /// jumps over it. This is done by simply setting the value of \c n325 /// to be false in the corresponding nodemap.326 293 void hide(const Node& n) const { _node_filter_map>set(n, false); } 327 328 /// \brief Hide the given edge in the graph.329 ///330 /// This function hides \c e in the graph, i.e. the iteration331 /// jumps over it. This is done by simply setting the value of \c e332 /// to be false in the corresponding edgemap.333 294 void hide(const Edge& e) const { _edge_filter_map>set(e, false); } 334 295 335 /// \brief Unhide the given node in the graph. 336 /// 337 /// The value of \c n is set to be true in the nodemap which stores 338 /// hide information. If \c n was hidden previuosly, then it is shown 339 /// again 340 void unHide(const Node& n) const { _node_filter_map>set(n, true); } 341 342 /// \brief Hide the given edge in the graph. 343 /// 344 /// The value of \c e is set to be true in the edgemap which stores 345 /// hide information. If \c e was hidden previuosly, then it is shown 346 /// again 296 void unHide(const Node& n) const { _node_filter_map>set(n, true); } 347 297 void unHide(const Edge& e) const { _edge_filter_map>set(e, true); } 348 298 349 /// \brief Returns true if \c n is hidden.350 ///351 /// Returns true if \c n is hidden.352 299 bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; } 353 354 /// \brief Returns true if \c e is hidden.355 ///356 /// Returns true if \c e is hidden.357 300 bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; } 358 301 … … 544 487 } 545 488 546 /// \brief Hide the given node in the graph.547 ///548 /// This function hides \c n in the graph, i.e. the iteration549 /// jumps over it. This is done by simply setting the value of \c n550 /// to be false in the corresponding nodemap.551 489 void hide(const Node& n) const { _node_filter_map>set(n, false); } 552 553 /// \brief Hide the given edge in the graph.554 ///555 /// This function hides \c e in the graph, i.e. the iteration556 /// jumps over it. This is done by simply setting the value of \c e557 /// to be false in the corresponding edgemap.558 490 void hide(const Edge& e) const { _edge_filter_map>set(e, false); } 559 491 560 /// \brief Unhide the given node in the graph. 561 /// 562 /// The value of \c n is set to be true in the nodemap which stores 563 /// hide information. If \c n was hidden previuosly, then it is shown 564 /// again 565 void unHide(const Node& n) const { _node_filter_map>set(n, true); } 566 567 /// \brief Hide the given edge in the graph. 568 /// 569 /// The value of \c e is set to be true in the edgemap which stores 570 /// hide information. If \c e was hidden previuosly, then it is shown 571 /// again 492 void unHide(const Node& n) const { _node_filter_map>set(n, true); } 572 493 void unHide(const Edge& e) const { _edge_filter_map>set(e, true); } 573 494 574 /// \brief Returns true if \c n is hidden.575 ///576 /// Returns true if \c n is hidden.577 495 bool hidden(const Node& n) const { return !(*_node_filter_map)[n]; } 578 579 /// \brief Returns true if \c e is hidden.580 ///581 /// Returns true if \c e is hidden.582 496 bool hidden(const Edge& e) const { return !(*_edge_filter_map)[e]; } 583 497 … … 683 597 /// \ingroup graph_adaptors 684 598 /// 685 /// \brief A graph adaptor for hiding nodes and arcs from an599 /// \brief A graph adaptor for hiding nodes and edges from an 686 600 /// undirected graph. 687 601 /// … … 705 619 typedef GraphAdaptorExtender< 706 620 SubGraphAdaptorBase<_Graph, NodeFilterMap, EdgeFilterMap> > Parent; 621 622 typedef typename Parent::Node Node; 623 typedef typename Parent::Edge Edge; 624 707 625 protected: 708 626 SubGraphAdaptor() { } 709 627 public: 628 629 /// \brief Constructor 630 /// 631 /// Creates a subgraphadaptor for the given graph with 632 /// given node and edge map filters. 710 633 SubGraphAdaptor(Graph& _graph, NodeFilterMap& node_filter_map, 711 634 EdgeFilterMap& edge_filter_map) { … … 714 637 setEdgeFilterMap(edge_filter_map); 715 638 } 639 640 /// \brief Hides the node of the graph 641 /// 642 /// This function hides \c n in the digraph, i.e. the iteration 643 /// jumps over it. This is done by simply setting the value of \c n 644 /// to be false in the corresponding nodemap. 645 void hide(const Node& n) const { Parent::hide(n); } 646 647 /// \brief Hides the edge of the graph 648 /// 649 /// This function hides \c e in the digraph, i.e. the iteration 650 /// jumps over it. This is done by simply setting the value of \c e 651 /// to be false in the corresponding edgemap. 652 void hide(const Edge& e) const { Parent::hide(e); } 653 654 /// \brief Unhides the node of the graph 655 /// 656 /// The value of \c n is set to be true in the nodemap which stores 657 /// hide information. If \c n was hidden previuosly, then it is shown 658 /// again 659 void unHide(const Node& n) const { Parent::unHide(n); } 660 661 /// \brief Unhides the edge of the graph 662 /// 663 /// The value of \c e is set to be true in the edgemap which stores 664 /// hide information. If \c e was hidden previuosly, then it is shown 665 /// again 666 void unHide(const Edge& e) const { Parent::unHide(e); } 667 668 /// \brief Returns true if \c n is hidden. 669 /// 670 /// Returns true if \c n is hidden. 671 /// 672 bool hidden(const Node& n) const { return Parent::hidden(n); } 673 674 /// \brief Returns true if \c e is hidden. 675 /// 676 /// Returns true if \c e is hidden. 677 /// 678 bool hidden(const Edge& e) const { return Parent::hidden(e); } 716 679 }; 717 680 681 /// \brief Just gives back a subgraph adaptor 682 /// 683 /// Just gives back a subgraph adaptor 718 684 template<typename Graph, typename NodeFilterMap, typename ArcFilterMap> 719 685 SubGraphAdaptor<const Graph, NodeFilterMap, ArcFilterMap> … … 766 732 typedef SubGraphAdaptor<Graph, NodeFilterMap, 767 733 ConstMap<typename Graph::Edge, bool> > Parent; 734 735 typedef typename Parent::Node Node; 768 736 protected: 769 737 ConstMap<typename Graph::Edge, bool> const_true_map; … … 774 742 775 743 public: 744 745 /// \brief Constructor 746 /// 747 /// Creates a nodesubgraphadaptor for the given graph with 748 /// given node map filters. 776 749 NodeSubGraphAdaptor(Graph& _graph, NodeFilterMap& node_filter_map) : 777 750 Parent(), const_true_map(true) { … … 780 753 Parent::setEdgeFilterMap(const_true_map); 781 754 } 755 756 /// \brief Hides the node of the graph 757 /// 758 /// This function hides \c n in the digraph, i.e. the iteration 759 /// jumps over it. This is done by simply setting the value of \c n 760 /// to be false in the corresponding nodemap. 761 void hide(const Node& n) const { Parent::hide(n); } 762 763 /// \brief Unhides the node of the graph 764 /// 765 /// The value of \c n is set to be true in the nodemap which stores 766 /// hide information. If \c n was hidden previuosly, then it is shown 767 /// again 768 void unHide(const Node& n) const { Parent::unHide(n); } 769 770 /// \brief Returns true if \c n is hidden. 771 /// 772 /// Returns true if \c n is hidden. 773 /// 774 bool hidden(const Node& n) const { return Parent::hidden(n); } 775 782 776 }; 783 777 778 /// \brief Just gives back a nodesubgraph adaptor 779 /// 780 /// Just gives back a nodesubgraph adaptor 784 781 template<typename Graph, typename NodeFilterMap> 785 782 NodeSubGraphAdaptor<const Graph, NodeFilterMap> … … 814 811 typedef SubGraphAdaptor<Graph, ConstMap<typename Graph::Node,bool>, 815 812 EdgeFilterMap, false> Parent; 813 typedef typename Parent::Edge Edge; 816 814 protected: 817 815 ConstMap<typename Graph::Node, bool> const_true_map; … … 823 821 public: 824 822 823 /// \brief Constructor 824 /// 825 /// Creates a edgesubgraphadaptor for the given graph with 826 /// given node map filters. 825 827 EdgeSubGraphAdaptor(Graph& _graph, EdgeFilterMap& edge_filter_map) : 826 828 Parent(), const_true_map(true) { … … 830 832 } 831 833 834 /// \brief Hides the edge of the graph 835 /// 836 /// This function hides \c e in the digraph, i.e. the iteration 837 /// jumps over it. This is done by simply setting the value of \c e 838 /// to be false in the corresponding edgemap. 839 void hide(const Edge& e) const { Parent::hide(e); } 840 841 /// \brief Unhides the edge of the graph 842 /// 843 /// The value of \c e is set to be true in the edgemap which stores 844 /// hide information. If \c e was hidden previuosly, then it is shown 845 /// again 846 void unHide(const Edge& e) const { Parent::unHide(e); } 847 848 /// \brief Returns true if \c e is hidden. 849 /// 850 /// Returns true if \c e is hidden. 851 /// 852 bool hidden(const Edge& e) const { return Parent::hidden(e); } 853 832 854 }; 833 855 856 /// \brief Just gives back an edgesubgraph adaptor 857 /// 858 /// Just gives back an edgesubgraph adaptor 834 859 template<typename Graph, typename EdgeFilterMap> 835 860 EdgeSubGraphAdaptor<const Graph, EdgeFilterMap> … … 844 869 } 845 870 846 /// \brief Base of direct graph adaptor847 ///848 /// Base class of the direct graph adaptor. All public member849 /// of this class can be used with the DirGraphAdaptor too.850 /// \sa DirGraphAdaptor851 871 template <typename _Graph, typename _DirectionMap> 852 872 class DirGraphAdaptorBase { … … 1104 1124 typedef DigraphAdaptorExtender< 1105 1125 DirGraphAdaptorBase<_Graph, DirectionMap> > Parent; 1126 typedef typename Parent::Arc Arc; 1106 1127 protected: 1107 1128 DirGraphAdaptor() { } … … 1114 1135 setGraph(graph); 1115 1136 setDirectionMap(direction); 1137 } 1138 1139 /// \brief Reverse arc 1140 /// 1141 /// It reverse the given arc. It simply negate the direction in the map. 1142 void reverseArc(const Arc& a) { 1143 Parent::reverseArc(a); 1116 1144 } 1117 1145 };
Note: See TracChangeset
for help on using the changeset viewer.