doc/gwrappers.dox
changeset 1288 6cc7b573b7b5
parent 1172 37338ae42a2b
equal deleted inserted replaced
0:bb8813fd3700 1:8c5665ad50e1
     3    \brief This group contains several wrapper classes for graphs
     3    \brief This group contains several wrapper classes for graphs
     4    @ingroup graphs
     4    @ingroup graphs
     5    
     5    
     6    The main parts of LEMON are the different graph structures, 
     6    The main parts of LEMON are the different graph structures, 
     7    generic graph algorithms, graph concepts which couple these, and 
     7    generic graph algorithms, graph concepts which couple these, and 
     8    graph wrappers. While the previous ones are more or less clear, the 
     8    graph wrappers. While the previous notions are more or less clear, the 
     9    latter notion needs further explanation.
     9    latter one needs further explanation. 
    10    Graph wrappers are graph classes which serve for considering graph 
    10    Graph wrappers are graph classes which serve for considering graph 
    11    structures in different ways. A short example makes the notion much 
    11    structures in different ways. 
       
    12 
       
    13    A short example makes this much 
    12    clearer. 
    14    clearer. 
    13    Suppose that we have an instance \c g of a directed graph
    15    Suppose that we have an instance \c g of a directed graph
    14    type say \c ListGraph and an algorithm 
    16    type say ListGraph and an algorithm 
    15    \code template<typename Graph> int algorithm(const Graph&); \endcode 
    17    \code template<typename Graph> int algorithm(const Graph&); \endcode 
    16    is needed to run on the reversely oriented graph. 
    18    is needed to run on the reversed oriented graph. 
    17    It may be expensive (in time or in memory usage) to copy 
    19    It may be expensive (in time or in memory usage) to copy 
    18    \c g with the reverse orientation. 
    20    \c g with the reversed orientation. 
    19    Thus, a wrapper class
    21    In this case, a wrapper class is used, which 
    20    \code template<typename Graph> class RevGraphWrapper; \endcode is used. 
    22    (according to LEMON graph concepts) works as a graph. 
    21    The code looks as follows
    23    The wrapper uses 
       
    24    the original graph structure and graph operations when methods of the 
       
    25    reversed oriented graph are called. 
       
    26    This means that the wrapper have minor memory usage, 
       
    27    and do not perform sophisticated algorithmic actions. 
       
    28    The purpose of it is to give a tool for the cases when 
       
    29    a graph have to be used in a specific alteration. 
       
    30    If this alteration is obtained by a usual construction 
       
    31    like filtering the edge-set or considering a new orientation, then 
       
    32    a wrapper is worthwhile to use. 
       
    33    To come back to the reversed oriented graph, in this situation 
       
    34    \code template<typename Graph> class RevGraphWrapper; \endcode 
       
    35    template class can be used. 
       
    36    The code looks as follows 
    22    \code
    37    \code
    23    ListGraph g;
    38    ListGraph g;
    24    RevGraphWrapper<ListGraph> rgw(g);
    39    RevGraphWrapper<ListGraph> rgw(g);
    25    int result=algorithm(rgw);
    40    int result=algorithm(rgw);
    26    \endcode
    41    \endcode
    27    After running the algorithm, the original graph \c g 
    42    After running the algorithm, the original graph \c g 
    28    remains untouched. Thus the graph wrapper used above is to consider the 
    43    is untouched. 
    29    original graph with reverse orientation. 
       
    30    This techniques gives rise to an elegant code, and 
    44    This techniques gives rise to an elegant code, and 
    31    based on stable graph wrappers, complex algorithms can be 
    45    based on stable graph wrappers, complex algorithms can be 
    32    implemented easily. 
    46    implemented easily. 
       
    47 
    33    In flow, circulation and bipartite matching problems, the residual 
    48    In flow, circulation and bipartite matching problems, the residual 
    34    graph is of particular importance. Combining a wrapper implementing 
    49    graph is of particular importance. Combining a wrapper implementing 
    35    this, shortest path algorithms and minimum mean cycle algorithms, 
    50    this, shortest path algorithms and minimum mean cycle algorithms, 
    36    a range of weighted and cardinality optimization algorithms can be 
    51    a range of weighted and cardinality optimization algorithms can be 
    37    obtained. For lack of space, for other examples, 
    52    obtained. 
    38    the interested user is referred to the detailed documentation of graph 
    53    For other examples, 
    39    wrappers. 
    54    the interested user is referred to the detailed documentation of 
       
    55    particular wrappers. 
       
    56 
    40    The behavior of graph wrappers can be very different. Some of them keep 
    57    The behavior of graph wrappers can be very different. Some of them keep 
    41    capabilities of the original graph while in other cases this would be 
    58    capabilities of the original graph while in other cases this would be 
    42    meaningless. This means that the concepts that they are a model of depend 
    59    meaningless. This means that the concepts that they are models of depend 
    43    on the graph wrapper, and the wrapped graph(s). 
    60    on the graph wrapper, and the wrapped graph(s). 
    44    If an edge of \c rgw is deleted, this is carried out by 
    61    If an edge of \c rgw is deleted, this is carried out by 
    45    deleting the corresponding edge of \c g. But for a residual 
    62    deleting the corresponding edge of \c g, thus the wrapper modifies the 
       
    63    original graph. 
       
    64    But for a residual 
    46    graph, this operation has no sense. 
    65    graph, this operation has no sense. 
    47    Let we stand one more example here to simplify your work. 
    66    Let us stand one more example here to simplify your work. 
    48    wrapper class
    67    RevGraphWrapper has constructor 
    49    \code template<typename Graph> class RevGraphWrapper; \endcode 
    68    \code 
    50    has constructor 
    69    RevGraphWrapper(Graph& _g);
    51    <tt> RevGraphWrapper(Graph& _g)</tt>. 
    70    \endcode
    52    This means that in a situation, 
    71    This means that in a situation, 
    53    when a <tt> const ListGraph& </tt> reference to a graph is given, 
    72    when a <tt> const ListGraph& </tt> reference to a graph is given, 
    54    then it have to be instantiated with <tt>Graph=const ListGraph</tt>.
    73    then it have to be instantiated with <tt>Graph=const ListGraph</tt>.
    55    \code
    74    \code
    56    int algorithm1(const ListGraph& g) {
    75    int algorithm1(const ListGraph& g) {