Changeset 1401:9588dcef6793 in lemon-0.x
- Timestamp:
- 05/04/05 15:07:10 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1863
- Files:
-
- 7 edited
- 5 moved
Legend:
- Unmodified
- Added
- Removed
-
doc/Makefile.am
r1400 r1401 9 9 demoprograms.dox graphs.dox undir_graphs.dox named-param.dox \ 10 10 maps.dox coding_style.dox groups.dox namespaces.dox license.dox \ 11 developers_interface.dox graph_io.dox dirs.dox g wrappers.dox11 developers_interface.dox graph_io.dox dirs.dox graph-adaptors.dox 12 12 13 13 -
doc/graph-adaptors.dox
r1252 r1401 1 1 /** 2 @defgroup g wrappers Wrapper Classes for Graphs3 \brief This group contains several wrapper classes for graphs2 @defgroup graph_adaptors Adaptor Classes for Graphs 3 \brief This group contains several adaptor classes for graphs 4 4 @ingroup graphs 5 5 6 6 The main parts of LEMON are the different graph structures, 7 7 generic graph algorithms, graph concepts which couple these, and 8 graph wrappers. While the previous notions are more or less clear, the8 graph adaptors. While the previous notions are more or less clear, the 9 9 latter one needs further explanation. 10 Graph wrappers are graph classes which serve for considering graph10 Graph adaptors are graph classes which serve for considering graph 11 11 structures in different ways. 12 12 … … 19 19 It may be expensive (in time or in memory usage) to copy 20 20 \c g with the reversed orientation. 21 In this case, a wrapper class is used, which21 In this case, an adaptor class is used, which 22 22 (according to LEMON graph concepts) works as a graph. 23 The wrapper uses23 The adaptor uses 24 24 the original graph structure and graph operations when methods of the 25 25 reversed oriented graph are called. 26 This means that the wrapper have minor memory usage,26 This means that the adaptor have minor memory usage, 27 27 and do not perform sophisticated algorithmic actions. 28 28 The purpose of it is to give a tool for the cases when … … 30 30 If this alteration is obtained by a usual construction 31 31 like filtering the edge-set or considering a new orientation, then 32 a wrapper is worthwhile to use.32 an adaptor is worthwhile to use. 33 33 To come back to the reversed oriented graph, in this situation 34 \code template<typename Graph> class RevGraph Wrapper; \endcode34 \code template<typename Graph> class RevGraphAdaptor; \endcode 35 35 template class can be used. 36 36 The code looks as follows 37 37 \code 38 38 ListGraph g; 39 RevGraph Wrapper<ListGraph> rgw(g);39 RevGraphAdaptor<ListGraph> rgw(g); 40 40 int result=algorithm(rgw); 41 41 \endcode … … 43 43 is untouched. 44 44 This techniques gives rise to an elegant code, and 45 based on stable graph wrappers, complex algorithms can be45 based on stable graph adaptors, complex algorithms can be 46 46 implemented easily. 47 47 48 48 In flow, circulation and bipartite matching problems, the residual 49 graph is of particular importance. Combining a wrapper implementing49 graph is of particular importance. Combining an adaptor implementing 50 50 this, shortest path algorithms and minimum mean cycle algorithms, 51 51 a range of weighted and cardinality optimization algorithms can be … … 53 53 For other examples, 54 54 the interested user is referred to the detailed documentation of 55 particular wrappers.55 particular adaptors. 56 56 57 The behavior of graph wrappers can be very different. Some of them keep57 The behavior of graph adaptors can be very different. Some of them keep 58 58 capabilities of the original graph while in other cases this would be 59 59 meaningless. This means that the concepts that they are models of depend 60 on the graph wrapper, and the wrapped graph(s).60 on the graph adaptor, and the wrapped graph(s). 61 61 If an edge of \c rgw is deleted, this is carried out by 62 deleting the corresponding edge of \c g, thus the wrapper modifies the62 deleting the corresponding edge of \c g, thus the adaptor modifies the 63 63 original graph. 64 64 But for a residual 65 65 graph, this operation has no sense. 66 66 Let us stand one more example here to simplify your work. 67 RevGraph Wrapper has constructor67 RevGraphAdaptor has constructor 68 68 \code 69 RevGraph Wrapper(Graph& _g);69 RevGraphAdaptor(Graph& _g); 70 70 \endcode 71 71 This means that in a situation, … … 74 74 \code 75 75 int algorithm1(const ListGraph& g) { 76 RevGraph Wrapper<const ListGraph> rgw(g);76 RevGraphAdaptor<const ListGraph> rgw(g); 77 77 return algorithm2(rgw); 78 78 } -
doc/groups.dox
r1329 r1401 32 32 is to be shrunk for an other algorithm. 33 33 LEMON also provides a variety of graphs for these requirements called 34 \ref g wrappers "graph wrappers". Wrappers cannot be used alone but only34 \ref graph_adaptors "graph adaptors". Adaptors cannot be used alone but only 35 35 in conjunction with other graph representation. 36 36 -
src/demo/Makefile.am
r1387 r1401 2 2 LDADD = $(top_builddir)/src/lemon/libemon.la 3 3 4 EXTRA_DIST = sub_graph_ wrapper_demo.dim4 EXTRA_DIST = sub_graph_adaptor_demo.dim 5 5 6 6 noinst_PROGRAMS = \ … … 9 9 graph_to_eps_demo \ 10 10 min_route \ 11 sub_graph_ wrapper_demo11 sub_graph_adaptor_demo 12 12 13 13 if HAVE_GLPK … … 28 28 min_route_SOURCES = min_route.cc 29 29 30 sub_graph_ wrapper_demo_SOURCES = \31 sub_graph_ wrapper_demo.cc \30 sub_graph_adaptor_demo_SOURCES = \ 31 sub_graph_adaptor_demo.cc \ 32 32 tight_edge_filter_map.h 33 33 -
src/demo/sub_graph_adaptor_demo.cc
r986 r1401 2 2 3 3 // Use a DIMACS max flow file as stdin. 4 // sub_graph_ wrapper_demo < dimacs_max_flow_file4 // sub_graph_adaptor_demo < dimacs_max_flow_file 5 5 // This program computes a maximum number of edge-disjoint shortest paths 6 6 // between s and t. … … 12 12 #include <lemon/dijkstra.h> 13 13 #include <lemon/maps.h> 14 #include <lemon/graph_ wrapper.h>14 #include <lemon/graph_adaptor.h> 15 15 #include <lemon/dimacs.h> 16 16 #include <lemon/preflow.h> … … 58 58 // ConstMap<Node, bool> const_true_map(true); 59 59 // This graph contains exaclty the tight edges. 60 // typedef SubGraph Wrapper<Graph, ConstMap<Node, bool>, TightEdgeFilter> SubGW;61 typedef EdgeSubGraph Wrapper<Graph, TightEdgeFilter> SubGW;60 // typedef SubGraphAdaptor<Graph, ConstMap<Node, bool>, TightEdgeFilter> SubGW; 61 typedef EdgeSubGraphAdaptor<Graph, TightEdgeFilter> SubGW; 62 62 SubGW gw(g, tight_edge_filter); 63 63 -
src/lemon/Makefile.am
r1386 r1401 30 30 fib_heap.h \ 31 31 full_graph.h \ 32 graph_ wrapper.h \32 graph_adaptor.h \ 33 33 graph_utils.h \ 34 34 graph_to_eps.h \ -
src/lemon/bits/undir_graph_extender.h
r1359 r1401 39 39 40 40 protected: 41 // FIXME: Marci use opposite logic in his graph wrappers. It would41 // FIXME: Marci use opposite logic in his graph adaptors. It would 42 42 // be reasonable to syncronize... 43 43 bool forward; -
src/lemon/graph_adaptor.h
r1383 r1401 1 1 /* -*- C++ -*- 2 * src/lemon/graph_ wrapper.h - Part of LEMON, a generic C++ optimization library2 * src/lemon/graph_adaptor.h - Part of LEMON, a generic C++ optimization library 3 3 * 4 4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport … … 15 15 */ 16 16 17 #ifndef LEMON_GRAPH_ WRAPPER_H18 #define LEMON_GRAPH_ WRAPPER_H19 20 ///\ingroup g wrappers17 #ifndef LEMON_GRAPH_ADAPTOR_H 18 #define LEMON_GRAPH_ADAPTOR_H 19 20 ///\ingroup graph_adaptors 21 21 ///\file 22 ///\brief Several graph wrappers.22 ///\brief Several graph adaptors. 23 23 /// 24 ///This file contains several useful graph wrapper functions.24 ///This file contains several useful graph adaptor functions. 25 25 /// 26 26 ///\author Marton Makai … … 34 34 namespace lemon { 35 35 36 // Graph wrappers36 // Graph adaptors 37 37 38 38 /*! 39 \addtogroup g wrappers39 \addtogroup graph_adaptors 40 40 @{ 41 41 */ 42 42 43 43 /*! 44 Base type for the Graph Wrappers44 Base type for the Graph Adaptors 45 45 46 \warning Graph wrappers are in even more experimental state than the other46 \warning Graph adaptors are in even more experimental state than the other 47 47 parts of the lib. Use them at you own risk. 48 48 49 This is the base type for most of LEMON graph wrappers.50 This class implements a trivial graph wrapper i.e. it only wraps the49 This is the base type for most of LEMON graph adaptors. 50 This class implements a trivial graph adaptor i.e. it only wraps the 51 51 functions and types of the graph. The purpose of this class is to 52 make easier implementing graph wrappers. E.g. if a wrapper is52 make easier implementing graph adaptors. E.g. if an adaptor is 53 53 considered which differs from the wrapped graph only in some of its 54 functions or types, then it can be derived from Graph Wrapper, and only the54 functions or types, then it can be derived from GraphAdaptor, and only the 55 55 differences should be implemented. 56 56 … … 58 58 */ 59 59 template<typename _Graph> 60 class Graph WrapperBase {60 class GraphAdaptorBase { 61 61 public: 62 62 typedef _Graph Graph; … … 67 67 protected: 68 68 Graph* graph; 69 Graph WrapperBase() : graph(0) { }69 GraphAdaptorBase() : graph(0) { } 70 70 void setGraph(Graph& _graph) { graph=&_graph; } 71 71 72 72 public: 73 Graph WrapperBase(Graph& _graph) : graph(&_graph) { }73 GraphAdaptorBase(Graph& _graph) : graph(&_graph) { } 74 74 75 75 typedef typename Graph::Node Node; … … 113 113 public: 114 114 typedef typename _Graph::template NodeMap<_Value> Parent; 115 NodeMap(const Graph WrapperBase<_Graph>& gw) : Parent(*gw.graph) { }116 NodeMap(const Graph WrapperBase<_Graph>& gw, const _Value& value)115 NodeMap(const GraphAdaptorBase<_Graph>& gw) : Parent(*gw.graph) { } 116 NodeMap(const GraphAdaptorBase<_Graph>& gw, const _Value& value) 117 117 : Parent(*gw.graph, value) { } 118 118 }; … … 122 122 public: 123 123 typedef typename _Graph::template EdgeMap<_Value> Parent; 124 EdgeMap(const Graph WrapperBase<_Graph>& gw) : Parent(*gw.graph) { }125 EdgeMap(const Graph WrapperBase<_Graph>& gw, const _Value& value)124 EdgeMap(const GraphAdaptorBase<_Graph>& gw) : Parent(*gw.graph) { } 125 EdgeMap(const GraphAdaptorBase<_Graph>& gw, const _Value& value) 126 126 : Parent(*gw.graph, value) { } 127 127 }; … … 130 130 131 131 template <typename _Graph> 132 class Graph Wrapper :133 public IterableGraphExtender<Graph WrapperBase<_Graph> > {132 class GraphAdaptor : 133 public IterableGraphExtender<GraphAdaptorBase<_Graph> > { 134 134 public: 135 135 typedef _Graph Graph; 136 typedef IterableGraphExtender<Graph WrapperBase<_Graph> > Parent;137 protected: 138 Graph Wrapper() : Parent() { }139 140 public: 141 Graph Wrapper(Graph& _graph) { setGraph(_graph); }136 typedef IterableGraphExtender<GraphAdaptorBase<_Graph> > Parent; 137 protected: 138 GraphAdaptor() : Parent() { } 139 140 public: 141 GraphAdaptor(Graph& _graph) { setGraph(_graph); } 142 142 }; 143 143 144 144 template <typename _Graph> 145 class RevGraph WrapperBase : public GraphWrapperBase<_Graph> {145 class RevGraphAdaptorBase : public GraphAdaptorBase<_Graph> { 146 146 public: 147 147 typedef _Graph Graph; 148 typedef Graph WrapperBase<_Graph> Parent;149 protected: 150 RevGraph WrapperBase() : Parent() { }148 typedef GraphAdaptorBase<_Graph> Parent; 149 protected: 150 RevGraphAdaptorBase() : Parent() { } 151 151 public: 152 152 typedef typename Parent::Node Node; … … 166 166 167 167 168 /// A graph wrapper which reverses the orientation of the edges.169 170 ///\warning Graph wrappers are in even more experimental state than the other168 /// A graph adaptor which reverses the orientation of the edges. 169 170 ///\warning Graph adaptors are in even more experimental state than the other 171 171 ///parts of the lib. Use them at you own risk. 172 172 /// … … 180 180 /// \f$e\in A\f$, let \f$\bar e\f$ denote the edge obtained by 181 181 /// reversing its orientation. 182 /// Then RevGraph Wrapper implements the graph structure with node-set182 /// Then RevGraphAdaptor implements the graph structure with node-set 183 183 /// \f$V\f$ and edge-set 184 184 /// \f$\{\bar e : e\in A \}\f$, i.e. the graph obtained from \f$G\f$ be … … 186 186 /// such an instance can be constructed. 187 187 /// \code 188 /// RevGraph Wrapper<ListGraph> gw(g);188 /// RevGraphAdaptor<ListGraph> gw(g); 189 189 /// \endcode 190 190 ///\author Marton Makai 191 191 template<typename _Graph> 192 class RevGraph Wrapper :193 public IterableGraphExtender<RevGraph WrapperBase<_Graph> > {192 class RevGraphAdaptor : 193 public IterableGraphExtender<RevGraphAdaptorBase<_Graph> > { 194 194 public: 195 195 typedef _Graph Graph; 196 196 typedef IterableGraphExtender< 197 RevGraph WrapperBase<_Graph> > Parent;198 protected: 199 RevGraph Wrapper() { }200 public: 201 RevGraph Wrapper(_Graph& _graph) { setGraph(_graph); }197 RevGraphAdaptorBase<_Graph> > Parent; 198 protected: 199 RevGraphAdaptor() { } 200 public: 201 RevGraphAdaptor(_Graph& _graph) { setGraph(_graph); } 202 202 }; 203 203 204 204 205 205 template <typename _Graph, typename NodeFilterMap, typename EdgeFilterMap> 206 class SubGraph WrapperBase : public GraphWrapperBase<_Graph> {206 class SubGraphAdaptorBase : public GraphAdaptorBase<_Graph> { 207 207 public: 208 208 typedef _Graph Graph; 209 typedef Graph WrapperBase<_Graph> Parent;209 typedef GraphAdaptorBase<_Graph> Parent; 210 210 protected: 211 211 NodeFilterMap* node_filter_map; 212 212 EdgeFilterMap* edge_filter_map; 213 SubGraph WrapperBase() : Parent(),213 SubGraphAdaptorBase() : Parent(), 214 214 node_filter_map(0), edge_filter_map(0) { } 215 215 … … 222 222 223 223 public: 224 // SubGraph WrapperBase(Graph& _graph,224 // SubGraphAdaptorBase(Graph& _graph, 225 225 // NodeFilterMap& _node_filter_map, 226 226 // EdgeFilterMap& _edge_filter_map) : … … 315 315 }; 316 316 317 /*! \brief A graph wrapper for hiding nodes and edges from a graph.317 /*! \brief A graph adaptor for hiding nodes and edges from a graph. 318 318 319 \warning Graph wrappers are in even more experimental state than the other319 \warning Graph adaptors are in even more experimental state than the other 320 320 parts of the lib. Use them at you own risk. 321 321 322 SubGraph Wrapper shows the graph with filtered node-set and322 SubGraphAdaptor shows the graph with filtered node-set and 323 323 edge-set. 324 324 Let \f$G=(V, A)\f$ be a directed graph … … 327 327 Let moreover \f$b_V\f$ and 328 328 \f$b_A\f$ be bool-valued functions resp. on the node-set and edge-set. 329 SubGraph Wrapper<...>::NodeIt iterates329 SubGraphAdaptor<...>::NodeIt iterates 330 330 on the node-set \f$\{v\in V : b_V(v)=true\}\f$ and 331 SubGraph Wrapper<...>::EdgeIt iterates331 SubGraphAdaptor<...>::EdgeIt iterates 332 332 on the edge-set \f$\{e\in A : b_A(e)=true\}\f$. Similarly, 333 SubGraph Wrapper<...>::OutEdgeIt and SubGraphWrapper<...>::InEdgeIt iterates333 SubGraphAdaptor<...>::OutEdgeIt and SubGraphAdaptor<...>::InEdgeIt iterates 334 334 only on edges leaving and entering a specific node which have true value. 335 335 … … 351 351 Graph::EdgeMap<bool> em(g, true); 352 352 em.set(e, false); 353 typedef SubGraph Wrapper<Graph, Graph::NodeMap<bool>, Graph::EdgeMap<bool> > SubGW;353 typedef SubGraphAdaptor<Graph, Graph::NodeMap<bool>, Graph::EdgeMap<bool> > SubGW; 354 354 SubGW gw(g, nm, em); 355 355 for (SubGW::NodeIt n(gw); n!=INVALID; ++n) std::cout << g.id(n) << std::endl; … … 366 366 \c Graph::Node that is why \c g.id(n) can be applied. 367 367 368 For other examples see also the documentation of NodeSubGraph Wrapper and369 EdgeSubGraph Wrapper.368 For other examples see also the documentation of NodeSubGraphAdaptor and 369 EdgeSubGraphAdaptor. 370 370 371 371 \author Marton Makai … … 373 373 template<typename _Graph, typename NodeFilterMap, 374 374 typename EdgeFilterMap> 375 class SubGraph Wrapper :375 class SubGraphAdaptor : 376 376 public IterableGraphExtender< 377 SubGraph WrapperBase<_Graph, NodeFilterMap, EdgeFilterMap> > {377 SubGraphAdaptorBase<_Graph, NodeFilterMap, EdgeFilterMap> > { 378 378 public: 379 379 typedef _Graph Graph; 380 380 typedef IterableGraphExtender< 381 SubGraph WrapperBase<_Graph, NodeFilterMap, EdgeFilterMap> > Parent;382 protected: 383 SubGraph Wrapper() { }384 public: 385 SubGraph Wrapper(_Graph& _graph, NodeFilterMap& _node_filter_map,381 SubGraphAdaptorBase<_Graph, NodeFilterMap, EdgeFilterMap> > Parent; 382 protected: 383 SubGraphAdaptor() { } 384 public: 385 SubGraphAdaptor(_Graph& _graph, NodeFilterMap& _node_filter_map, 386 386 EdgeFilterMap& _edge_filter_map) { 387 387 setGraph(_graph); … … 393 393 394 394 395 /*! \brief A wrapper for hiding nodes from a graph.396 397 \warning Graph wrappers are in even more experimental state than the other395 /*! \brief An adaptor for hiding nodes from a graph. 396 397 \warning Graph adaptors are in even more experimental state than the other 398 398 parts of the lib. Use them at you own risk. 399 399 400 A wrapper for hiding nodes from a graph.401 This wrapper specializes SubGraphWrapper in the way that only the node-set400 An adaptor for hiding nodes from a graph. 401 This adaptor specializes SubGraphAdaptor in the way that only the node-set 402 402 can be filtered. Note that this does not mean of considering induced 403 403 subgraph, the edge-iterators consider the original edge-set. … … 405 405 */ 406 406 template<typename Graph, typename NodeFilterMap> 407 class NodeSubGraph Wrapper :408 public SubGraph Wrapper<Graph, NodeFilterMap,407 class NodeSubGraphAdaptor : 408 public SubGraphAdaptor<Graph, NodeFilterMap, 409 409 ConstMap<typename Graph::Edge,bool> > { 410 410 public: 411 typedef SubGraph Wrapper<Graph, NodeFilterMap,411 typedef SubGraphAdaptor<Graph, NodeFilterMap, 412 412 ConstMap<typename Graph::Edge,bool> > Parent; 413 413 protected: 414 414 ConstMap<typename Graph::Edge, bool> const_true_map; 415 415 public: 416 NodeSubGraph Wrapper(Graph& _graph, NodeFilterMap& _node_filter_map) :416 NodeSubGraphAdaptor(Graph& _graph, NodeFilterMap& _node_filter_map) : 417 417 Parent(), const_true_map(true) { 418 418 Parent::setGraph(_graph); … … 423 423 424 424 425 /*! \brief A wrapper for hiding edges from a graph.426 427 \warning Graph wrappers are in even more experimental state than the other425 /*! \brief An adaptor for hiding edges from a graph. 426 427 \warning Graph adaptors are in even more experimental state than the other 428 428 parts of the lib. Use them at you own risk. 429 429 430 A wrapper for hiding edges from a graph.431 This wrapper specializes SubGraphWrapper in the way that only the edge-set432 can be filtered. The usefulness of this wrapper is demonstrated in the430 An adaptor for hiding edges from a graph. 431 This adaptor specializes SubGraphAdaptor in the way that only the edge-set 432 can be filtered. The usefulness of this adaptor is demonstrated in the 433 433 problem of searching a maximum number of edge-disjoint shortest paths 434 434 between … … 499 499 TightEdgeFilter tight_edge_filter(g, dijkstra.distMap(), length); 500 500 501 typedef EdgeSubGraph Wrapper<Graph, TightEdgeFilter> SubGW;501 typedef EdgeSubGraphAdaptor<Graph, TightEdgeFilter> SubGW; 502 502 SubGW gw(g, tight_edge_filter); 503 503 \endcode … … 550 550 */ 551 551 template<typename Graph, typename EdgeFilterMap> 552 class EdgeSubGraph Wrapper :553 public SubGraph Wrapper<Graph, ConstMap<typename Graph::Node,bool>,552 class EdgeSubGraphAdaptor : 553 public SubGraphAdaptor<Graph, ConstMap<typename Graph::Node,bool>, 554 554 EdgeFilterMap> { 555 555 public: 556 typedef SubGraph Wrapper<Graph, ConstMap<typename Graph::Node,bool>,556 typedef SubGraphAdaptor<Graph, ConstMap<typename Graph::Node,bool>, 557 557 EdgeFilterMap> Parent; 558 558 protected: 559 559 ConstMap<typename Graph::Node, bool> const_true_map; 560 560 public: 561 EdgeSubGraph Wrapper(Graph& _graph, EdgeFilterMap& _edge_filter_map) :561 EdgeSubGraphAdaptor(Graph& _graph, EdgeFilterMap& _edge_filter_map) : 562 562 Parent(), const_true_map(true) { 563 563 Parent::setGraph(_graph); … … 568 568 569 569 template <typename _Graph> 570 class UndirGraph WrapperBase :571 public UndirGraphExtender<Graph WrapperBase<_Graph> > {570 class UndirGraphAdaptorBase : 571 public UndirGraphExtender<GraphAdaptorBase<_Graph> > { 572 572 public: 573 573 typedef _Graph Graph; 574 typedef UndirGraphExtender<Graph WrapperBase<_Graph> > Parent;575 protected: 576 UndirGraph WrapperBase() : Parent() { }574 typedef UndirGraphExtender<GraphAdaptorBase<_Graph> > Parent; 575 protected: 576 UndirGraphAdaptorBase() : Parent() { } 577 577 public: 578 578 typedef typename Parent::UndirEdge UndirEdge; … … 585 585 class EdgeMap { 586 586 protected: 587 const UndirGraph WrapperBase<_Graph>* g;587 const UndirGraphAdaptorBase<_Graph>* g; 588 588 template <typename TT> friend class EdgeMap; 589 589 typename _Graph::template EdgeMap<T> forward_map, backward_map; … … 592 592 typedef Edge Key; 593 593 594 EdgeMap(const UndirGraph WrapperBase<_Graph>& _g) : g(&_g),594 EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g) : g(&_g), 595 595 forward_map(*(g->graph)), backward_map(*(g->graph)) { } 596 596 597 EdgeMap(const UndirGraph WrapperBase<_Graph>& _g, T a) : g(&_g),597 EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g, T a) : g(&_g), 598 598 forward_map(*(g->graph), a), backward_map(*(g->graph), a) { } 599 599 … … 621 621 typedef UndirEdge Key; 622 622 623 UndirEdgeMap(const UndirGraph WrapperBase<_Graph>& g) :623 UndirEdgeMap(const UndirGraphAdaptorBase<_Graph>& g) : 624 624 map(*(g.graph)) { } 625 625 626 UndirEdgeMap(const UndirGraph WrapperBase<_Graph>& g, T a) :626 UndirEdgeMap(const UndirGraphAdaptorBase<_Graph>& g, T a) : 627 627 map(*(g.graph), a) { } 628 628 … … 638 638 }; 639 639 640 /// \brief An undirected graph is made from a directed graph by a wrapper640 /// \brief An undirected graph is made from a directed graph by an adaptor 641 641 /// 642 642 /// Undocumented, untested!!! … … 645 645 /// \author Marton Makai 646 646 template<typename _Graph> 647 class UndirGraph Wrapper :647 class UndirGraphAdaptor : 648 648 public IterableUndirGraphExtender< 649 UndirGraph WrapperBase<_Graph> > {649 UndirGraphAdaptorBase<_Graph> > { 650 650 public: 651 651 typedef _Graph Graph; 652 652 typedef IterableUndirGraphExtender< 653 UndirGraph WrapperBase<_Graph> > Parent;654 protected: 655 UndirGraph Wrapper() { }656 public: 657 UndirGraph Wrapper(_Graph& _graph) {653 UndirGraphAdaptorBase<_Graph> > Parent; 654 protected: 655 UndirGraphAdaptor() { } 656 public: 657 UndirGraphAdaptor(_Graph& _graph) { 658 658 setGraph(_graph); 659 659 } … … 663 663 template <typename _Graph, 664 664 typename ForwardFilterMap, typename BackwardFilterMap> 665 class SubBidirGraph WrapperBase : public GraphWrapperBase<_Graph> {665 class SubBidirGraphAdaptorBase : public GraphAdaptorBase<_Graph> { 666 666 public: 667 667 typedef _Graph Graph; 668 typedef Graph WrapperBase<_Graph> Parent;668 typedef GraphAdaptorBase<_Graph> Parent; 669 669 protected: 670 670 ForwardFilterMap* forward_filter; 671 671 BackwardFilterMap* backward_filter; 672 SubBidirGraph WrapperBase() : Parent(),672 SubBidirGraphAdaptorBase() : Parent(), 673 673 forward_filter(0), backward_filter(0) { } 674 674 … … 681 681 682 682 public: 683 // SubGraph WrapperBase(Graph& _graph,683 // SubGraphAdaptorBase(Graph& _graph, 684 684 // NodeFilterMap& _node_filter_map, 685 685 // EdgeFilterMap& _edge_filter_map) : … … 691 691 typedef typename _Graph::Edge GraphEdge; 692 692 template <typename T> class EdgeMap; 693 /// SubBidirGraph WrapperBase<..., ..., ...>::Edge is inherited from693 /// SubBidirGraphAdaptorBase<..., ..., ...>::Edge is inherited from 694 694 /// _Graph::Edge. It contains an extra bool flag which is true 695 695 /// if and only if the 696 696 /// edge is the backward version of the original edge. 697 697 class Edge : public _Graph::Edge { 698 friend class SubBidirGraph WrapperBase<698 friend class SubBidirGraphAdaptorBase< 699 699 Graph, ForwardFilterMap, BackwardFilterMap>; 700 700 template<typename T> friend class EdgeMap; … … 850 850 851 851 template <typename T> 852 /// \c SubBidirGraph WrapperBase<..., ..., ...>::EdgeMap contains two852 /// \c SubBidirGraphAdaptorBase<..., ..., ...>::EdgeMap contains two 853 853 /// _Graph::EdgeMap one for the forward edges and 854 854 /// one for the backward edges. … … 860 860 typedef Edge Key; 861 861 862 EdgeMap(const SubBidirGraph WrapperBase<_Graph,862 EdgeMap(const SubBidirGraphAdaptorBase<_Graph, 863 863 ForwardFilterMap, BackwardFilterMap>& g) : 864 864 forward_map(*(g.graph)), backward_map(*(g.graph)) { } 865 865 866 EdgeMap(const SubBidirGraph WrapperBase<_Graph,866 EdgeMap(const SubBidirGraphAdaptorBase<_Graph, 867 867 ForwardFilterMap, BackwardFilterMap>& g, T a) : 868 868 forward_map(*(g.graph), a), backward_map(*(g.graph), a) { } … … 900 900 901 901 902 ///\brief A wrapper for composing a subgraph of a902 ///\brief An adaptor for composing a subgraph of a 903 903 /// bidirected graph made from a directed one. 904 904 /// 905 /// A wrapper for composing a subgraph of a905 /// An adaptor for composing a subgraph of a 906 906 /// bidirected graph made from a directed one. 907 907 /// 908 ///\warning Graph wrappers are in even more experimental state than the other908 ///\warning Graph adaptors are in even more experimental state than the other 909 909 ///parts of the lib. Use them at you own risk. 910 910 /// … … 914 914 /// maps on the edge-set, 915 915 /// \f$forward\_filter\f$, and \f$backward\_filter\f$. 916 /// SubBidirGraph Wrapper implements the graph structure with node-set916 /// SubBidirGraphAdaptor implements the graph structure with node-set 917 917 /// \f$V\f$ and edge-set 918 918 /// \f$\{e : e\in A \mbox{ and } forward\_filter(e) \mbox{ is true}\}+\{\bar e : e\in A \mbox{ and } backward\_filter(e) \mbox{ is true}\}\f$. … … 924 924 /// the maps are able to attach different values for them. 925 925 /// 926 /// An example for such a construction is \c RevGraph Wrapper where the926 /// An example for such a construction is \c RevGraphAdaptor where the 927 927 /// forward_filter is everywhere false and the backward_filter is 928 928 /// everywhere true. We note that for sake of efficiency, 929 /// \c RevGraph Wrapper is implemented in a different way.930 /// But BidirGraph Wrapper is obtained from931 /// SubBidirGraph Wrapper by considering everywhere true929 /// \c RevGraphAdaptor is implemented in a different way. 930 /// But BidirGraphAdaptor is obtained from 931 /// SubBidirGraphAdaptor by considering everywhere true 932 932 /// valued maps both for forward_filter and backward_filter. 933 933 /// 934 /// The most important application of SubBidirGraph Wrapper935 /// is ResGraph Wrapper, which stands for the residual graph in directed934 /// The most important application of SubBidirGraphAdaptor 935 /// is ResGraphAdaptor, which stands for the residual graph in directed 936 936 /// flow and circulation problems. 937 /// As wrappers usually, the SubBidirGraphWrapper implements the937 /// As adaptors usually, the SubBidirGraphAdaptor implements the 938 938 /// above mentioned graph structure without its physical storage, 939 939 /// that is the whole stuff is stored in constant memory. 940 940 template<typename _Graph, 941 941 typename ForwardFilterMap, typename BackwardFilterMap> 942 class SubBidirGraph Wrapper :942 class SubBidirGraphAdaptor : 943 943 public IterableGraphExtender< 944 SubBidirGraph WrapperBase<_Graph, ForwardFilterMap, BackwardFilterMap> > {944 SubBidirGraphAdaptorBase<_Graph, ForwardFilterMap, BackwardFilterMap> > { 945 945 public: 946 946 typedef _Graph Graph; 947 947 typedef IterableGraphExtender< 948 SubBidirGraph WrapperBase<948 SubBidirGraphAdaptorBase< 949 949 _Graph, ForwardFilterMap, BackwardFilterMap> > Parent; 950 950 protected: 951 SubBidirGraph Wrapper() { }952 public: 953 SubBidirGraph Wrapper(_Graph& _graph, ForwardFilterMap& _forward_filter,951 SubBidirGraphAdaptor() { } 952 public: 953 SubBidirGraphAdaptor(_Graph& _graph, ForwardFilterMap& _forward_filter, 954 954 BackwardFilterMap& _backward_filter) { 955 955 setGraph(_graph); … … 961 961 962 962 963 ///\brief A wrapper for composing bidirected graph from a directed one.963 ///\brief An adaptor for composing bidirected graph from a directed one. 964 964 /// 965 ///\warning Graph wrappers are in even more experimental state than the other965 ///\warning Graph adaptors are in even more experimental state than the other 966 966 ///parts of the lib. Use them at you own risk. 967 967 /// 968 /// A wrapper for composing bidirected graph from a directed one.968 /// An adaptor for composing bidirected graph from a directed one. 969 969 /// A bidirected graph is composed over the directed one without physical 970 970 /// storage. As the oppositely directed edges are logically different ones 971 971 /// the maps are able to attach different values for them. 972 972 template<typename Graph> 973 class BidirGraph Wrapper :974 public SubBidirGraph Wrapper<973 class BidirGraphAdaptor : 974 public SubBidirGraphAdaptor< 975 975 Graph, 976 976 ConstMap<typename Graph::Edge, bool>, 977 977 ConstMap<typename Graph::Edge, bool> > { 978 978 public: 979 typedef SubBidirGraph Wrapper<979 typedef SubBidirGraphAdaptor< 980 980 Graph, 981 981 ConstMap<typename Graph::Edge, bool>, … … 984 984 ConstMap<typename Graph::Edge, bool> cm; 985 985 986 BidirGraph Wrapper() : Parent(), cm(true) {986 BidirGraphAdaptor() : Parent(), cm(true) { 987 987 Parent::setForwardFilterMap(cm); 988 988 Parent::setBackwardFilterMap(cm); 989 989 } 990 990 public: 991 BidirGraph Wrapper(Graph& _graph) : Parent(), cm(true) {991 BidirGraphAdaptor(Graph& _graph) : Parent(), cm(true) { 992 992 Parent::setGraph(_graph); 993 993 Parent::setForwardFilterMap(cm); … … 998 998 return 2*this->graph->edgeNum(); 999 999 } 1000 // KEEP_MAPS(Parent, BidirGraph Wrapper);1000 // KEEP_MAPS(Parent, BidirGraphAdaptor); 1001 1001 }; 1002 1002 … … 1038 1038 1039 1039 1040 /*! \brief A wrapper for composing the residual graph for directed flow and circulation problems.1041 1042 A wrapper for composing the residual graph for directed flow and circulation problems.1040 /*! \brief An adaptor for composing the residual graph for directed flow and circulation problems. 1041 1042 An adaptor for composing the residual graph for directed flow and circulation problems. 1043 1043 Let \f$G=(V, A)\f$ be a directed graph and let \f$F\f$ be a 1044 1044 number type. Let moreover 1045 1045 \f$f,c:A\to F\f$, be functions on the edge-set. 1046 In the appications of ResGraph Wrapper, \f$f\f$ usually stands for a flow1046 In the appications of ResGraphAdaptor, \f$f\f$ usually stands for a flow 1047 1047 and \f$c\f$ for a capacity function. 1048 1048 Suppose that a graph instange \c g of type … … 1051 1051 ListGraph g; 1052 1052 \endcode 1053 Then RevGraph Wrapper implements the graph structure with node-set1053 Then RevGraphAdaptor implements the graph structure with node-set 1054 1054 \f$V\f$ and edge-set \f$A_{forward}\cup A_{backward}\f$, where 1055 1055 \f$A_{forward}=\{uv : uv\in A, f(uv)<c(uv)\}\f$ and … … 1058 1058 When we take the union \f$A_{forward}\cup A_{backward}\f$, 1059 1059 multilicities are counted, i.e. if an edge is in both 1060 \f$A_{forward}\f$ and \f$A_{backward}\f$, then in the wrapper it1060 \f$A_{forward}\f$ and \f$A_{backward}\f$, then in the adaptor it 1061 1061 appears twice. 1062 1062 The following code shows how … … 1066 1066 Graph::EdgeMap<int> f(g); 1067 1067 Graph::EdgeMap<int> c(g); 1068 ResGraph Wrapper<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > gw(g);1068 ResGraphAdaptor<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > gw(g); 1069 1069 \endcode 1070 1070 \author Marton Makai … … 1072 1072 template<typename Graph, typename Number, 1073 1073 typename CapacityMap, typename FlowMap> 1074 class ResGraph Wrapper :1075 public SubBidirGraph Wrapper<1074 class ResGraphAdaptor : 1075 public SubBidirGraphAdaptor< 1076 1076 Graph, 1077 1077 ResForwardFilter<Graph, Number, CapacityMap, FlowMap>, 1078 1078 ResBackwardFilter<Graph, Number, CapacityMap, FlowMap> > { 1079 1079 public: 1080 typedef SubBidirGraph Wrapper<1080 typedef SubBidirGraphAdaptor< 1081 1081 Graph, 1082 1082 ResForwardFilter<Graph, Number, CapacityMap, FlowMap>, … … 1087 1087 ResForwardFilter<Graph, Number, CapacityMap, FlowMap> forward_filter; 1088 1088 ResBackwardFilter<Graph, Number, CapacityMap, FlowMap> backward_filter; 1089 ResGraph Wrapper() : Parent(),1089 ResGraphAdaptor() : Parent(), 1090 1090 capacity(0), flow(0) { } 1091 1091 void setCapacityMap(const CapacityMap& _capacity) { … … 1100 1100 } 1101 1101 public: 1102 ResGraph Wrapper(Graph& _graph, const CapacityMap& _capacity,1102 ResGraphAdaptor(Graph& _graph, const CapacityMap& _capacity, 1103 1103 FlowMap& _flow) : 1104 1104 Parent(), capacity(&_capacity), flow(&_flow), … … 1125 1125 class ResCap { 1126 1126 protected: 1127 const ResGraph Wrapper<Graph, Number, CapacityMap, FlowMap>* res_graph;1127 const ResGraphAdaptor<Graph, Number, CapacityMap, FlowMap>* res_graph; 1128 1128 public: 1129 1129 typedef Number Value; 1130 1130 typedef Edge Key; 1131 ResCap(const ResGraph Wrapper<Graph, Number, CapacityMap, FlowMap>&1131 ResCap(const ResGraphAdaptor<Graph, Number, CapacityMap, FlowMap>& 1132 1132 _res_graph) : res_graph(&_res_graph) { } 1133 1133 Number operator[](const Edge& e) const { … … 1139 1139 }; 1140 1140 1141 // KEEP_MAPS(Parent, ResGraph Wrapper);1141 // KEEP_MAPS(Parent, ResGraphAdaptor); 1142 1142 }; 1143 1143 … … 1145 1145 1146 1146 template <typename _Graph, typename FirstOutEdgesMap> 1147 class ErasingFirstGraph WrapperBase : public GraphWrapperBase<_Graph> {1147 class ErasingFirstGraphAdaptorBase : public GraphAdaptorBase<_Graph> { 1148 1148 public: 1149 1149 typedef _Graph Graph; 1150 typedef Graph WrapperBase<_Graph> Parent;1150 typedef GraphAdaptorBase<_Graph> Parent; 1151 1151 protected: 1152 1152 FirstOutEdgesMap* first_out_edges; 1153 ErasingFirstGraph WrapperBase() : Parent(),1153 ErasingFirstGraphAdaptorBase() : Parent(), 1154 1154 first_out_edges(0) { } 1155 1155 … … 1178 1178 /// For blocking flows. 1179 1179 1180 ///\warning Graph wrappers are in even more experimental state than the other1180 ///\warning Graph adaptors are in even more experimental state than the other 1181 1181 ///parts of the lib. Use them at you own risk. 1182 1182 /// 1183 /// This graph wrapper is used for on-the-fly1183 /// This graph adaptor is used for on-the-fly 1184 1184 /// Dinits blocking flow computations. 1185 1185 /// For each node, an out-edge is stored which is used when the … … 1191 1191 /// \author Marton Makai 1192 1192 template <typename _Graph, typename FirstOutEdgesMap> 1193 class ErasingFirstGraph Wrapper :1193 class ErasingFirstGraphAdaptor : 1194 1194 public IterableGraphExtender< 1195 ErasingFirstGraph WrapperBase<_Graph, FirstOutEdgesMap> > {1195 ErasingFirstGraphAdaptorBase<_Graph, FirstOutEdgesMap> > { 1196 1196 public: 1197 1197 typedef _Graph Graph; 1198 1198 typedef IterableGraphExtender< 1199 ErasingFirstGraph WrapperBase<_Graph, FirstOutEdgesMap> > Parent;1200 ErasingFirstGraph Wrapper(Graph& _graph,1199 ErasingFirstGraphAdaptorBase<_Graph, FirstOutEdgesMap> > Parent; 1200 ErasingFirstGraphAdaptor(Graph& _graph, 1201 1201 FirstOutEdgesMap& _first_out_edges) { 1202 1202 setGraph(_graph); … … 1210 1210 } //namespace lemon 1211 1211 1212 #endif //LEMON_GRAPH_ WRAPPER_H1213 1212 #endif //LEMON_GRAPH_ADAPTOR_H 1213 -
src/lemon/min_cost_flow.h
r1359 r1401 24 24 25 25 #include <lemon/dijkstra.h> 26 #include <lemon/graph_ wrapper.h>26 #include <lemon/graph_adaptor.h> 27 27 #include <lemon/maps.h> 28 28 #include <vector> … … 69 69 typedef typename Graph::template EdgeMap<int> EdgeIntMap; 70 70 71 typedef ResGraph Wrapper<const Graph,int,CapacityMap,EdgeIntMap> ResGW;71 typedef ResGraphAdaptor<const Graph,int,CapacityMap,EdgeIntMap> ResGW; 72 72 typedef typename ResGW::Edge ResGraphEdge; 73 73 -
src/test/Makefile.am
r1387 r1401 17 17 dijkstra_test \ 18 18 graph_test \ 19 graph_ wrapper_test \19 graph_adaptor_test \ 20 20 graph_utils_test \ 21 21 kruskal_test \ … … 50 50 graph_test_SOURCES = graph_test.cc 51 51 graph_utils_test_SOURCES = graph_utils_test.cc 52 graph_ wrapper_test_SOURCES = graph_wrapper_test.cc52 graph_adaptor_test_SOURCES = graph_adaptor_test.cc 53 53 kruskal_test_SOURCES = kruskal_test.cc 54 54 maps_test_SOURCES = maps_test.cc -
src/test/graph_adaptor_test.cc
r1383 r1401 1 1 /* -*- C++ -*- 2 * src/test/graph_ wrapper_test.cc - Part of LEMON, a generic C++ optimization library2 * src/test/graph_adaptor_test.cc - Part of LEMON, a generic C++ optimization library 3 3 * 4 4 * Copyright (C) 2005 Egervary Jeno Kombinatorikus Optimalizalasi Kutatocsoport … … 24 24 #include<lemon/list_graph.h> 25 25 #include<lemon/full_graph.h> 26 #include<lemon/graph_ wrapper.h>26 #include<lemon/graph_adaptor.h> 27 27 28 28 #include"test/test_tools.h" … … 31 31 /** 32 32 \file 33 This test makes consistency checks of graph wrappers.33 This test makes consistency checks of graph adaptors. 34 34 35 35 \todo More extensive tests are needed … … 45 45 { 46 46 typedef StaticGraph Graph; 47 checkConcept<StaticGraph, Graph Wrapper<Graph> >();47 checkConcept<StaticGraph, GraphAdaptor<Graph> >(); 48 48 49 checkConcept<StaticGraph, RevGraph Wrapper<Graph> >();49 checkConcept<StaticGraph, RevGraphAdaptor<Graph> >(); 50 50 51 checkConcept<StaticGraph, SubGraph Wrapper<Graph,51 checkConcept<StaticGraph, SubGraphAdaptor<Graph, 52 52 Graph::NodeMap<bool> , Graph::EdgeMap<bool> > >(); 53 checkConcept<StaticGraph, NodeSubGraph Wrapper<Graph,53 checkConcept<StaticGraph, NodeSubGraphAdaptor<Graph, 54 54 Graph::NodeMap<bool> > >(); 55 checkConcept<StaticGraph, EdgeSubGraph Wrapper<Graph,55 checkConcept<StaticGraph, EdgeSubGraphAdaptor<Graph, 56 56 Graph::EdgeMap<bool> > >(); 57 57 58 checkConcept<StaticGraph, SubBidirGraph Wrapper<Graph,58 checkConcept<StaticGraph, SubBidirGraphAdaptor<Graph, 59 59 Graph::EdgeMap<bool>, Graph::EdgeMap<bool> > >(); 60 60 // checkConcept<StaticGraph, BidirGraph<Graph> >(); 61 checkConcept<StaticGraph, ResGraph Wrapper<Graph, int,61 checkConcept<StaticGraph, ResGraphAdaptor<Graph, int, 62 62 Graph::EdgeMap<int>, Graph::EdgeMap<int> > >(); 63 63 64 checkConcept<StaticGraph, ErasingFirstGraph Wrapper<Graph,64 checkConcept<StaticGraph, ErasingFirstGraphAdaptor<Graph, 65 65 Graph::NodeMap<Graph::Edge> > >(); 66 66 67 67 /// \bug why does not compile with StaticGraph 68 checkConcept<BaseIterableUndirGraphConcept, UndirGraph Wrapper<ListGraph> >();69 checkConcept<IterableUndirGraphConcept, UndirGraph Wrapper<ListGraph> >();70 checkConcept<MappableUndirGraphConcept, UndirGraph Wrapper<ListGraph> >();68 checkConcept<BaseIterableUndirGraphConcept, UndirGraphAdaptor<ListGraph> >(); 69 checkConcept<IterableUndirGraphConcept, UndirGraphAdaptor<ListGraph> >(); 70 checkConcept<MappableUndirGraphConcept, UndirGraphAdaptor<ListGraph> >(); 71 71 } 72 72 std::cout << __FILE__ ": All tests passed.\n";
Note: See TracChangeset
for help on using the changeset viewer.