Documentation for UndirGraphAdaptor
authordeba
Tue, 17 Oct 2006 11:02:05 +0000
changeset 225137fa5f83251e
parent 2250 b8fbffd35445
child 2252 133028e83940
Documentation for UndirGraphAdaptor
lemon/graph_adaptor.h
     1.1 --- a/lemon/graph_adaptor.h	Tue Oct 17 11:01:35 2006 +0000
     1.2 +++ b/lemon/graph_adaptor.h	Tue Oct 17 11:02:05 2006 +0000
     1.3 @@ -1276,10 +1276,47 @@
     1.4    ///
     1.5    /// \brief An undirected graph is made from a directed graph by an adaptor
     1.6    ///
     1.7 -  /// Undocumented, untested!!!
     1.8 -  /// If somebody knows nice demo application, let's polulate it.
     1.9 +  /// This adaptor makes an undirected graph from a directed
    1.10 +  /// graph. All edge of the underlying will be showed in the adaptor
    1.11 +  /// as an undirected edge. Let's see an informal example about using
    1.12 +  /// this adaptor:
    1.13 +  ///
    1.14 +  /// There is a network of the streets of a town. Of course there are
    1.15 +  /// some one-way street in the town hence the network is a directed
    1.16 +  /// one. There is a crazy driver who go oppositely in the one-way
    1.17 +  /// street without moral sense. Of course he can pass this streets
    1.18 +  /// slower than the regular way, in fact his speed is half of the
    1.19 +  /// normal speed. How long should he drive to get from a source
    1.20 +  /// point to the target? Let see the example code which calculate it:
    1.21 +  ///
    1.22 +  ///\code
    1.23 +  /// typedef UndirGraphAdaptor<Graph> UGraph;
    1.24 +  /// UGraph ugraph(graph);
    1.25 +  ///
    1.26 +  /// typedef SimpleMap<LengthMap> FLengthMap;
    1.27 +  /// FLengthMap flength(length);
    1.28 +  ///
    1.29 +  /// typedef ScaleMap<LengthMap> RLengthMap;
    1.30 +  /// RLengthMap rlength(length, 2.0);
    1.31 +  ///
    1.32 +  /// typedef UGraph::CombinedEdgeMap<FLengthMap, RLengthMap > ULengthMap;
    1.33 +  /// ULengthMap ulength(flength, rlength);
    1.34    /// 
    1.35 -  /// \author Marton Makai
    1.36 +  /// Dijkstra<UGraph, ULengthMap> dijkstra(ugraph, ulength);
    1.37 +  /// std::cout << "Driving time : " << dijkstra.run(src, trg) << std::endl;
    1.38 +  ///\endcode
    1.39 +  ///
    1.40 +  /// The combined edge map makes the length map for the undirected
    1.41 +  /// graph. It is created from a forward and reverse map. The forward
    1.42 +  /// map is created from the original length map with a SimpleMap
    1.43 +  /// adaptor which just makes a read-write map from the reference map
    1.44 +  /// i.e. it forgets that it can be return reference to values. The
    1.45 +  /// reverse map is just the scaled original map with the ScaleMap
    1.46 +  /// adaptor. The combination solves that passing the reverse way
    1.47 +  /// takes double time than the original. To get the driving time we
    1.48 +  /// run the dijkstra algorithm on the undirected graph.
    1.49 +  ///
    1.50 +  /// \author Marton Makai and Balazs Dezso
    1.51    template<typename _Graph>
    1.52    class UndirGraphAdaptor : public AlterableUndirGraphAdaptor<_Graph> {
    1.53    public:
    1.54 @@ -1288,10 +1325,18 @@
    1.55    protected:
    1.56      UndirGraphAdaptor() { }
    1.57    public:
    1.58 +
    1.59 +    /// \brief Constructor
    1.60 +    ///
    1.61 +    /// Constructor
    1.62      UndirGraphAdaptor(_Graph& _graph) { 
    1.63        setGraph(_graph);
    1.64      }
    1.65  
    1.66 +    /// \brief EdgeMap combined from two original EdgeMap
    1.67 +    ///
    1.68 +    /// This class adapts two original graph EdgeMap to
    1.69 +    /// get an edge map on the adaptor.
    1.70      template <typename _ForwardMap, typename _BackwardMap>
    1.71      class CombinedEdgeMap {
    1.72      public:
    1.73 @@ -1303,12 +1348,22 @@
    1.74  
    1.75        typedef typename ForwardMap::Value Value;
    1.76        typedef typename Parent::Edge Key;
    1.77 -      
    1.78 +
    1.79 +      /// \brief Constructor      
    1.80 +      ///
    1.81 +      /// Constructor      
    1.82        CombinedEdgeMap() : forward_map(0), backward_map(0) {}
    1.83  
    1.84 +      /// \brief Constructor      
    1.85 +      ///
    1.86 +      /// Constructor      
    1.87        CombinedEdgeMap(ForwardMap& _forward_map, BackwardMap& _backward_map) 
    1.88          : forward_map(&_forward_map), backward_map(&_backward_map) {}
    1.89        
    1.90 +
    1.91 +      /// \brief Sets the value associated with a key.
    1.92 +      ///
    1.93 +      /// Sets the value associated with a key.
    1.94        void set(const Key& e, const Value& a) { 
    1.95  	if (Parent::direction(e)) {
    1.96  	  forward_map->set(e, a); 
    1.97 @@ -1317,6 +1372,9 @@
    1.98          } 
    1.99        }
   1.100  
   1.101 +      /// \brief Returns the value associated with a key.
   1.102 +      ///
   1.103 +      /// Returns the value associated with a key.
   1.104        typename MapTraits<ForwardMap>::ConstReturnValue 
   1.105        operator[](const Key& e) const { 
   1.106  	if (Parent::direction(e)) {
   1.107 @@ -1326,6 +1384,9 @@
   1.108          }
   1.109        }
   1.110  
   1.111 +      /// \brief Returns the value associated with a key.
   1.112 +      ///
   1.113 +      /// Returns the value associated with a key.
   1.114        typename MapTraits<ForwardMap>::ReturnValue 
   1.115        operator[](const Key& e) { 
   1.116  	if (Parent::direction(e)) {
   1.117 @@ -1335,10 +1396,16 @@
   1.118          }
   1.119        }
   1.120  
   1.121 +      /// \brief Sets the forward map
   1.122 +      ///
   1.123 +      /// Sets the forward map
   1.124        void setForwardMap(ForwardMap& _forward_map) {
   1.125          forward_map = &_forward_map;
   1.126        }
   1.127  
   1.128 +      /// \brief Sets the backward map
   1.129 +      ///
   1.130 +      /// Sets the backward map
   1.131        void setBackwardMap(BackwardMap& _backward_map) {
   1.132          backward_map = &_backward_map;
   1.133        }