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&);
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;
ListGraph g;
RevGraphAdaptor<ListGraph> rga(g);
int result=algorithm(rga);
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 rga
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);
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> rga(g); return algorithm2(rga); }
Classes | |
class | BpUGraphAdaptorBase< _BpUGraph > |
Base type for the Bipartite Undirected Graph Adaptors. More... | |
class | BpUGraphAdaptor< _BpUGraph > |
Trivial Bipartite Undirected Graph Adaptor. More... | |
class | SwapBpUGraphAdaptor< _BpUGraph > |
Bipartite graph adaptor which swaps the two nodeset. More... | |
class | MatchingBpUGraphAdaptor< _BpUGraph, _ANMatchingMap, _BNMatchingMap > |
Bipartite graph adaptor to implement matching algorithms. More... | |
class | GraphAdaptor< _Graph > |
Trivial Graph Adaptor. More... | |
class | RevGraphAdaptor< _Graph > |
A graph adaptor which reverses the orientation of the edges. More... | |
class | SubGraphAdaptor< _Graph, NodeFilterMap, EdgeFilterMap, checked > |
A graph adaptor for hiding nodes and edges from a graph. More... | |
class | NodeSubGraphAdaptor< Graph, NodeFilterMap, checked > |
An adaptor for hiding nodes from a graph. More... | |
class | EdgeSubGraphAdaptor< Graph, EdgeFilterMap > |
An adaptor for hiding edges from a graph. More... | |
class | UndirGraphAdaptor< _Graph > |
An undirected graph is made from a directed graph by an adaptor. More... | |
class | ResGraphAdaptor< Graph, Number, CapacityMap, FlowMap, Tol > |
An adaptor for composing the residual graph for directed flow and circulation problems. More... | |
class | ErasingFirstGraphAdaptor< _Graph, FirstOutEdgesMap > |
For blocking flows. More... | |
class | SplitGraphAdaptor< _Graph > |
Split graph adaptor class. More... | |
class | UGraphAdaptor< _UGraph > |
Trivial undirected graph adaptor. More... | |
class | SubUGraphAdaptor< _UGraph, NodeFilterMap, UEdgeFilterMap, checked > |
A graph adaptor for hiding nodes and edges from an undirected graph. More... | |
class | NodeSubUGraphAdaptor< _UGraph, NodeFilterMap, checked > |
An adaptor for hiding nodes from an undirected graph. More... | |
class | EdgeSubUGraphAdaptor< _UGraph, UEdgeFilterMap > |
An adaptor for hiding undirected edges from an undirected graph. More... | |
class | DirUGraphAdaptor< _Graph, DirectionMap > |
A directed graph is made from an undirected graph by an adaptor. More... | |
Files | |
file | bpugraph_adaptor.h |
Several graph adaptors. | |
file | graph_adaptor.h |
Several graph adaptors. | |
file | ugraph_adaptor.h |
Several graph adaptors. |