Main Page | Modules | Namespace List | Class Hierarchy | Alphabetical List | Class List | Directories | File List | Namespace Members | Class Members | File Members | Related Pages

Adaptor Classes for Graphs
[Graph Structures]


Detailed Description

A short example makes this much clearer. Suppose that we have an instance g of a directed graph type say ListGraph and an algorithm
 template<typename Graph> int algorithm(const Graph&); 
is needed to run on the reversed oriented graph. It may be expensive (in time or in memory usage) to copy g with the reversed orientation. In this case, an adaptor class is used, which (according to LEMON graph concepts) works as a graph. The adaptor uses the original graph structure and graph operations when methods of the reversed oriented graph are called. This means that the adaptor have minor memory usage, and do not perform sophisticated algorithmic actions. The purpose of it is to give a tool for the cases when a graph have to be used in a specific alteration. If this alteration is obtained by a usual construction like filtering the edge-set or considering a new orientation, then an adaptor is worthwhile to use. To come back to the reversed oriented graph, in this situation
 template<typename Graph> class RevGraphAdaptor; 
template class can be used. The code looks as follows
   ListGraph g;
   RevGraphAdaptor<ListGraph> rgw(g);
   int result=algorithm(rgw);
After running the algorithm, the original graph g is untouched. This techniques gives rise to an elegant code, and based on stable graph adaptors, complex algorithms can be implemented easily.

In flow, circulation and bipartite matching problems, the residual graph is of particular importance. Combining an adaptor implementing this, shortest path algorithms and minimum mean cycle algorithms, a range of weighted and cardinality optimization algorithms can be obtained. For other examples, the interested user is referred to the detailed documentation of particular adaptors.

The behavior of graph adaptors can be very different. Some of them keep capabilities of the original graph while in other cases this would be meaningless. This means that the concepts that they are models of depend on the graph adaptor, and the wrapped graph(s). If an edge of rgw is deleted, this is carried out by deleting the corresponding edge of g, thus the adaptor modifies the original graph. But for a residual graph, this operation has no sense. Let us stand one more example here to simplify your work. RevGraphAdaptor has constructor

   RevGraphAdaptor(Graph& _g);
This means that in a situation, when a const ListGraph& reference to a graph is given, then it have to be instantiated with Graph=const ListGraph.
   int algorithm1(const ListGraph& g) {
   RevGraphAdaptor<const ListGraph> rgw(g);
   return algorithm2(rgw);
   }


Files

file  graph_adaptor.h
 Several graph adaptors.

Classes

class  GraphAdaptorBase
class  RevGraphAdaptor
 A graph adaptor which reverses the orientation of the edges. More...
class  SubGraphAdaptor
 A graph adaptor for hiding nodes and edges from a graph. More...
class  NodeSubGraphAdaptor
 An adaptor for hiding nodes from a graph. More...
class  EdgeSubGraphAdaptor
 An adaptor for hiding edges from a graph. More...
class  UndirGraphAdaptor
 An undirected graph is made from a directed graph by an adaptor. More...
class  SubBidirGraphAdaptor
 An adaptor for composing a subgraph of a bidirected graph made from a directed one. More...
class  BidirGraphAdaptor
 An adaptor for composing bidirected graph from a directed one. More...
class  ResGraphAdaptor
 An adaptor for composing the residual graph for directed flow and circulation problems. More...
class  ErasingFirstGraphAdaptor
 For blocking flows. More...
class  NewEdgeSetAdaptor
 Graph adaptor using a node set of another graph and an own edge set. More...
class  NewUndirEdgeSetAdaptor
 Graph adaptor using a node set of another graph and an own undir edge set. More...


Generated on Sat Aug 27 14:14:56 2005 for LEMON by  doxygen 1.4.4