lemon/graph_adaptor.h
changeset 2058 0b1fc1566fdb
parent 2037 32e4bebee616
child 2079 7fe378247fea
equal deleted inserted replaced
32:bb4caa63aa8c 33:c5cc9e634454
    43   ///\brief Base type for the Graph Adaptors
    43   ///\brief Base type for the Graph Adaptors
    44   ///\ingroup graph_adaptors
    44   ///\ingroup graph_adaptors
    45   ///
    45   ///
    46   ///Base type for the Graph Adaptors
    46   ///Base type for the Graph Adaptors
    47   ///
    47   ///
    48   ///\warning Graph adaptors are in even
       
    49   ///more experimental state than the other
       
    50   ///parts of the lib. Use them at you own risk.
       
    51   ///
       
    52   ///This is the base type for most of LEMON graph adaptors. 
    48   ///This is the base type for most of LEMON graph adaptors. 
    53   ///This class implements a trivial graph adaptor i.e. it only wraps the 
    49   ///This class implements a trivial graph adaptor i.e. it only wraps the 
    54   ///functions and types of the graph. The purpose of this class is to 
    50   ///functions and types of the graph. The purpose of this class is to 
    55   ///make easier implementing graph adaptors. E.g. if an adaptor is 
    51   ///make easier implementing graph adaptors. E.g. if an adaptor is 
    56   ///considered which differs from the wrapped graph only in some of its 
    52   ///considered which differs from the wrapped graph only in some of its 
   249   };
   245   };
   250     
   246     
   251 
   247 
   252   ///\brief A graph adaptor which reverses the orientation of the edges.
   248   ///\brief A graph adaptor which reverses the orientation of the edges.
   253   ///\ingroup graph_adaptors
   249   ///\ingroup graph_adaptors
   254   ///
       
   255   ///\warning Graph adaptors are in even more experimental 
       
   256   ///state than the other
       
   257   ///parts of the lib. Use them at you own risk.
       
   258   ///
   250   ///
   259   /// If \c g is defined as
   251   /// If \c g is defined as
   260   ///\code
   252   ///\code
   261   /// ListGraph g;
   253   /// ListGraph g;
   262   ///\endcode
   254   ///\endcode
   645 
   637 
   646   };
   638   };
   647 
   639 
   648   /// \brief A graph adaptor for hiding nodes and edges from a graph.
   640   /// \brief A graph adaptor for hiding nodes and edges from a graph.
   649   /// \ingroup graph_adaptors
   641   /// \ingroup graph_adaptors
   650   /// 
       
   651   /// \warning Graph adaptors are in even more experimental state than the
       
   652   /// other parts of the lib. Use them at you own risk.
       
   653   /// 
   642   /// 
   654   /// SubGraphAdaptor shows the graph with filtered node-set and 
   643   /// SubGraphAdaptor shows the graph with filtered node-set and 
   655   /// edge-set. If the \c checked parameter is true then it filters the edgeset
   644   /// edge-set. If the \c checked parameter is true then it filters the edgeset
   656   /// to do not get invalid edges without source or target.
   645   /// to do not get invalid edges without source or target.
   657   /// Let \f$ G=(V, A) \f$ be a directed graph
   646   /// Let \f$ G=(V, A) \f$ be a directed graph
   768 
   757 
   769 
   758 
   770   ///\brief An adaptor for hiding nodes from a graph.
   759   ///\brief An adaptor for hiding nodes from a graph.
   771   ///\ingroup graph_adaptors
   760   ///\ingroup graph_adaptors
   772   ///
   761   ///
   773   ///\warning Graph adaptors are in even more experimental state
       
   774   ///than the other
       
   775   ///parts of the lib. Use them at you own risk.
       
   776   ///
       
   777   ///An adaptor for hiding nodes from a graph.
   762   ///An adaptor for hiding nodes from a graph.
   778   ///This adaptor specializes SubGraphAdaptor in the way that only
   763   ///This adaptor specializes SubGraphAdaptor in the way that only
   779   ///the node-set 
   764   ///the node-set 
   780   ///can be filtered. In usual case the checked parameter is true, we get the
   765   ///can be filtered. In usual case the checked parameter is true, we get the
   781   ///induced subgraph. But if the checked parameter is false then we can only
   766   ///induced subgraph. But if the checked parameter is false then we can only
   824   nodeSubGraphAdaptor(const Graph& graph, const NodeFilterMap& nfm) {
   809   nodeSubGraphAdaptor(const Graph& graph, const NodeFilterMap& nfm) {
   825     return NodeSubGraphAdaptor<const Graph, const NodeFilterMap>(graph, nfm);
   810     return NodeSubGraphAdaptor<const Graph, const NodeFilterMap>(graph, nfm);
   826   }
   811   }
   827 
   812 
   828   ///\brief An adaptor for hiding edges from a graph.
   813   ///\brief An adaptor for hiding edges from a graph.
   829   ///
       
   830   ///\warning Graph adaptors are in even more experimental state
       
   831   ///than the other parts of the lib. Use them at you own risk.
       
   832   ///
   814   ///
   833   ///An adaptor for hiding edges from a graph.
   815   ///An adaptor for hiding edges from a graph.
   834   ///This adaptor specializes SubGraphAdaptor in the way that
   816   ///This adaptor specializes SubGraphAdaptor in the way that
   835   ///only the edge-set 
   817   ///only the edge-set 
   836   ///can be filtered. The usefulness of this adaptor is demonstrated in the 
   818   ///can be filtered. The usefulness of this adaptor is demonstrated in the 
  1477   ///\brief An adaptor for composing the residual
  1459   ///\brief An adaptor for composing the residual
  1478   ///graph for directed flow and circulation problems.
  1460   ///graph for directed flow and circulation problems.
  1479   ///
  1461   ///
  1480   ///\ingroup graph_adaptors
  1462   ///\ingroup graph_adaptors
  1481   ///
  1463   ///
  1482   ///An adaptor for composing the residual graph for
  1464   ///An adaptor for composing the residual graph for directed flow and
  1483   ///directed flow and circulation problems. 
  1465   ///circulation problems.  Let \f$ G=(V, A) \f$ be a directed graph
  1484 //   ///Let \f$ G=(V, A) \f$ be a directed graph and let \f$ F \f$ be a 
  1466   ///and let \f$ F \f$ be a number type. Let moreover \f$ f,c:A\to F \f$,
  1485 //   ///number type. Let moreover 
  1467   ///be functions on the edge-set.
  1486 //   ///\f$ f,c:A\to F \f$, be functions on the edge-set. 
  1468   ///
  1487 //   ///In the appications of ResGraphAdaptor, \f$ f \f$ usually stands for a 
  1469   ///In the appications of ResGraphAdaptor, \f$ f \f$ usually stands
  1488 //   ///flow and \f$ c \f$ for a capacity function.   
  1470   ///for a flow and \f$ c \f$ for a capacity function.  Suppose that a
  1489 //   ///Suppose that a graph instange \c g of type 
  1471   ///graph instange \c g of type \c ListGraph implements \f$ G \f$.
  1490 //   ///\c ListGraph implements \f$ G \f$.
  1472   ///
  1491 //   ///\code
  1473   ///\code 
  1492 //   /// ListGraph g;
  1474   ///  ListGraph g;
  1493 //   ///\endcode
  1475   ///\endcode 
  1494 //   ///Then RevGraphAdaptor implements the graph structure with node-set 
  1476   ///
  1495 //   ///\f$ V \f$ and edge-set \f$ A_{forward}\cup A_{backward} \f$, where 
  1477   ///Then RevGraphAdaptor implements the graph structure with node-set
  1496 //   ///\f$ A_{forward}=\{uv : uv\in A, f(uv)<c(uv)\} \f$ and 
  1478   /// \f$ V \f$ and edge-set \f$ A_{forward}\cup A_{backward} \f$,
  1497 //   ///\f$ A_{backward}=\{vu : uv\in A, f(uv)>0\} \f$, 
  1479   ///where \f$ A_{forward}=\{uv : uv\in A, f(uv)<c(uv)\} \f$ and 
  1498 //   ///i.e. the so called residual graph. 
  1480   /// \f$ A_{backward}=\{vu : uv\in A, f(uv)>0\} \f$, i.e. the so called
  1499 //   ///When we take the union \f$ A_{forward}\cup A_{backward} \f$, 
  1481   ///residual graph.  When we take the union 
  1500 //   ///multilicities are counted, i.e. if an edge is in both 
  1482   /// \f$ A_{forward}\cup A_{backward} \f$, multilicities are counted, i.e. 
  1501 //   ///\f$ A_{forward} \f$ and \f$ A_{backward} \f$, then in the adaptor it 
  1483   ///if an edge is in both \f$ A_{forward} \f$ and \f$ A_{backward} \f$, 
  1502 //   ///appears twice. The following code shows how such an instance can be 
  1484   ///then in the adaptor it appears twice. The following code shows how 
  1503 //   ///constructed.
  1485   ///such an instance can be constructed.
  1504 //   ///\code
  1486   ///
  1505 //   /// typedef ListGraph Graph;
  1487   ///\code 
  1506 //   /// Graph::EdgeMap<int> f(g);
  1488   ///  typedef ListGraph Graph; 
  1507 //   /// Graph::EdgeMap<int> c(g);
  1489   ///  Graph::EdgeMap<int> f(g);
  1508 //   /// ResGraphAdaptor<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > ga(g);
  1490   ///  Graph::EdgeMap<int> c(g); 
  1509 //   ///\endcode
  1491   ///  ResGraphAdaptor<Graph, int, Graph::EdgeMap<int>, Graph::EdgeMap<int> > ga(g); 
  1510 //   ///\author Marton Makai
  1492   ///\endcode
  1511 //   ///
  1493   ///\author Marton Makai
       
  1494   ///
  1512   template<typename Graph, typename Number, 
  1495   template<typename Graph, typename Number, 
  1513 	   typename CapacityMap, typename FlowMap,
  1496 	   typename CapacityMap, typename FlowMap,
  1514            typename Tolerance = Tolerance<Number> >
  1497            typename Tolerance = Tolerance<Number> >
  1515   class ResGraphAdaptor : 
  1498   class ResGraphAdaptor : 
  1516     public EdgeSubGraphAdaptor< 
  1499     public EdgeSubGraphAdaptor< 
  1683 
  1666 
  1684 
  1667 
  1685   ///\brief For blocking flows.
  1668   ///\brief For blocking flows.
  1686   ///\ingroup graph_adaptors
  1669   ///\ingroup graph_adaptors
  1687   ///
  1670   ///
  1688   ///\warning Graph adaptors are in even more
       
  1689   ///experimental state than the other
       
  1690   ///parts of the lib. Use them at you own risk.
       
  1691   ///
       
  1692   ///This graph adaptor is used for on-the-fly 
  1671   ///This graph adaptor is used for on-the-fly 
  1693   ///Dinits blocking flow computations.
  1672   ///Dinits blocking flow computations.
  1694   ///For each node, an out-edge is stored which is used when the 
  1673   ///For each node, an out-edge is stored which is used when the 
  1695   ///\code
  1674   ///\code
  1696   ///OutEdgeIt& first(OutEdgeIt&, const Node&)
  1675   ///OutEdgeIt& first(OutEdgeIt&, const Node&)