COIN-OR::LEMON - Graph Library

Changeset 1980:a954b780e3ab in lemon-0.x


Ignore:
Timestamp:
02/23/06 09:55:54 (14 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2573
Message:

Renaming to be convient to the naming of the adaptors
Concept checking of the ugraph adaptors

Files:
4 edited

Legend:

Unmodified
Added
Removed
  • lemon/concept/ugraph.h

    r1979 r1980  
    865865
    866866
     867      void firstInc(UEdge &, bool &, const Node &) const {}
     868
     869      void nextInc(UEdge &, bool &) const {}
     870
    867871      /// \brief Base node of the iterator
    868872      ///
  • lemon/graph_adaptor.h

    r1979 r1980  
    699699
    700700  template <typename _Graph>
    701   class UndirectGraphAdaptorBase :
     701  class UndirGraphAdaptorBase :
    702702    public UGraphBaseExtender<GraphAdaptorBase<_Graph> > {
    703703  public:
     
    705705    typedef UGraphBaseExtender<GraphAdaptorBase<_Graph> > Parent;
    706706  protected:
    707     UndirectGraphAdaptorBase() : Parent() { }
     707    UndirGraphAdaptorBase() : Parent() { }
    708708  public:
    709709    typedef typename Parent::UEdge UEdge;
     
    713713    class EdgeMap {
    714714    protected:
    715       const UndirectGraphAdaptorBase<_Graph>* g;
     715      const UndirGraphAdaptorBase<_Graph>* g;
    716716      template <typename TT> friend class EdgeMap;
    717717      typename _Graph::template EdgeMap<T> forward_map, backward_map;
     
    720720      typedef Edge Key;
    721721     
    722       EdgeMap(const UndirectGraphAdaptorBase<_Graph>& _g) : g(&_g),
     722      EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g) : g(&_g),
    723723        forward_map(*(g->graph)), backward_map(*(g->graph)) { }
    724724
    725       EdgeMap(const UndirectGraphAdaptorBase<_Graph>& _g, T a) : g(&_g),
     725      EdgeMap(const UndirGraphAdaptorBase<_Graph>& _g, T a) : g(&_g),
    726726        forward_map(*(g->graph), a), backward_map(*(g->graph), a) { }
    727727     
     
    749749      typedef UEdge Key;
    750750     
    751       UEdgeMap(const UndirectGraphAdaptorBase<_Graph>& g) :
     751      UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g) :
    752752        map(*(g.graph)) { }
    753753
    754       UEdgeMap(const UndirectGraphAdaptorBase<_Graph>& g, T a) :
     754      UEdgeMap(const UndirGraphAdaptorBase<_Graph>& g, T a) :
    755755        map(*(g.graph), a) { }
    756756     
     
    774774  /// \author Marton Makai
    775775  template<typename _Graph>
    776   class UndirectGraphAdaptor :
     776  class UndirGraphAdaptor :
    777777    public UGraphAdaptorExtender<
    778     UndirectGraphAdaptorBase<_Graph> > {
     778    UndirGraphAdaptorBase<_Graph> > {
    779779  public:
    780780    typedef _Graph Graph;
    781781    typedef UGraphAdaptorExtender<
    782       UndirectGraphAdaptorBase<_Graph> > Parent;
     782      UndirGraphAdaptorBase<_Graph> > Parent;
    783783  protected:
    784     UndirectGraphAdaptor() { }
    785   public:
    786     UndirectGraphAdaptor(_Graph& _graph) {
     784    UndirGraphAdaptor() { }
     785  public:
     786    UndirGraphAdaptor(_Graph& _graph) {
    787787      setGraph(_graph);
    788788    }
  • lemon/ugraph_adaptor.h

    r1979 r1980  
    512512  /// graph.
    513513  ///
    514   /// \warning Graph adaptors are in even more experimental state than the
    515   /// other parts of the lib. Use them at you own risk.
    516   ///
    517514  /// SubUGraphAdaptor shows the undirected graph with filtered node-set and
    518515  /// edge-set. If the \c checked parameter is true then it filters the edgeset
     
    529526  /// \c Graph::Node that is why \c g.id(n) can be applied.
    530527  ///
    531   /// For examples see also the documentation of NodeSubUGraphAdaptor and
    532   /// EdgeSubUGraphAdaptor.
    533   ///
    534   /// \author Marton Makai
    535 
    536528  template<typename _UGraph, typename NodeFilterMap,
    537529           typename UEdgeFilterMap, bool checked = true>
     
    554546  };
    555547
     548  template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap>
     549  SubUGraphAdaptor<const UGraph, NodeFilterMap, EdgeFilterMap>
     550  subUGraphAdaptor(const UGraph& graph,
     551                   NodeFilterMap& nfm, EdgeFilterMap& efm) {
     552    return SubUGraphAdaptor<const UGraph, NodeFilterMap, EdgeFilterMap>
     553      (graph, nfm, efm);
     554  }
     555
     556  template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap>
     557  SubUGraphAdaptor<const UGraph, const NodeFilterMap, EdgeFilterMap>
     558  subUGraphAdaptor(const UGraph& graph,
     559                   NodeFilterMap& nfm, EdgeFilterMap& efm) {
     560    return SubUGraphAdaptor<const UGraph, const NodeFilterMap, EdgeFilterMap>
     561      (graph, nfm, efm);
     562  }
     563
     564  template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap>
     565  SubUGraphAdaptor<const UGraph, NodeFilterMap, const EdgeFilterMap>
     566  subUGraphAdaptor(const UGraph& graph,
     567                   NodeFilterMap& nfm, EdgeFilterMap& efm) {
     568    return SubUGraphAdaptor<const UGraph, NodeFilterMap, const EdgeFilterMap>
     569      (graph, nfm, efm);
     570  }
     571
     572  template<typename UGraph, typename NodeFilterMap, typename EdgeFilterMap>
     573  SubUGraphAdaptor<const UGraph, const NodeFilterMap, const EdgeFilterMap>
     574  subUGraphAdaptor(const UGraph& graph,
     575                   NodeFilterMap& nfm, EdgeFilterMap& efm) {
     576    return SubUGraphAdaptor<const UGraph, const NodeFilterMap,
     577      const EdgeFilterMap>(graph, nfm, efm);
     578  }
     579
    556580  /// \ingroup graph_adaptors
    557581  ///
    558   /// \brief An adaptor for hiding nodes from an undorected graph.
    559   ///
    560   /// \warning Graph adaptors are in even more experimental state
    561   /// than the other
    562   /// parts of the lib. Use them at you own risk.
     582  /// \brief An adaptor for hiding nodes from an undirected graph.
     583  ///
    563584  ///
    564585  /// An adaptor for hiding nodes from an undirected graph.
     
    568589  /// induced subgraph. But if the checked parameter is false then we can only
    569590  /// filter only isolated nodes.
    570   /// \author Marton Makai
    571591  template<typename _UGraph, typename NodeFilterMap, bool checked = true>
    572592  class NodeSubUGraphAdaptor :
     
    610630  /// only the edge-set
    611631  /// can be filtered.
    612   ///
    613   ///\author Marton Makai
    614632  template<typename _UGraph, typename UEdgeFilterMap>
    615633  class EdgeSubUGraphAdaptor :
     
    644662
    645663  template <typename _UGraph, typename _DirectionMap>
    646   class DirectUGraphAdaptorBase {
     664  class DirUGraphAdaptorBase {
    647665  public:
    648666   
     
    737755    public:
    738756      typedef typename _UGraph::template NodeMap<_Value> Parent;
    739       explicit NodeMap(const DirectUGraphAdaptorBase& ga)
     757      explicit NodeMap(const DirUGraphAdaptorBase& ga)
    740758        : Parent(*ga.graph) { }
    741       NodeMap(const DirectUGraphAdaptorBase& ga, const _Value& value)
     759      NodeMap(const DirUGraphAdaptorBase& ga, const _Value& value)
    742760        : Parent(*ga.graph, value) { }
    743761    };
     
    746764    class EdgeMap : public _UGraph::template UEdgeMap<_Value> {
    747765    public:
    748       typedef typename _UGraph::template EdgeMap<_Value> Parent;
    749       explicit EdgeMap(const DirectUGraphAdaptorBase& ga)
     766      typedef typename _UGraph::template UEdgeMap<_Value> Parent;
     767      explicit EdgeMap(const DirUGraphAdaptorBase& ga)
    750768        : Parent(*ga.graph) { }
    751       EdgeMap(const DirectUGraphAdaptorBase& ga, const _Value& value)
     769      EdgeMap(const DirUGraphAdaptorBase& ga, const _Value& value)
    752770        : Parent(*ga.graph, value) { }
    753771    };
     
    770788
    771789
    772   template<typename _Graph, typename DirectionMap>
    773   class DirectUGraphAdaptor :
     790  /// \ingroup graph_adaptors
     791  /// \brief A directed graph is made from a undirected graph by an adaptor
     792  ///
     793  /// This adaptor gives a direction for each uedge in the undirected graph.
     794  /// The direction of the edges stored in the DirectionMap. This map is
     795  /// a bool map on the undirected edges. If the uedge is mapped to true
     796  /// then the direction of the directed edge will be the same as the
     797  /// default direction of the uedge. The edges can be easily reverted
     798  /// by the reverseEdge member in the adaptor. 
     799  template<typename _Graph,
     800           typename DirectionMap = typename _Graph::template UEdgeMap<bool> >
     801  class DirUGraphAdaptor :
    774802    public GraphAdaptorExtender<
    775     DirectUGraphAdaptorBase<_Graph, DirectionMap> > {
     803    DirUGraphAdaptorBase<_Graph, DirectionMap> > {
    776804  public:
    777805    typedef _Graph Graph;
    778806    typedef GraphAdaptorExtender<
    779       DirectUGraphAdaptorBase<_Graph, DirectionMap> > Parent;
     807      DirUGraphAdaptorBase<_Graph, DirectionMap> > Parent;
    780808  protected:
    781     DirectUGraphAdaptor() { }
    782   public:
    783     DirectUGraphAdaptor(_Graph& _graph, DirectionMap& _direction_map) {
     809    DirUGraphAdaptor() { }
     810  public:
     811    DirUGraphAdaptor(_Graph& _graph, DirectionMap& _direction_map) {
    784812      setGraph(_graph);
    785813      setDirectionMap(_direction_map);
     
    788816
    789817  template<typename UGraph, typename DirectionMap>
    790   DirectUGraphAdaptor<const UGraph, DirectionMap>
    791   directUGraphAdaptor(const UGraph& graph, DirectionMap& dm) {
    792     return DirectUGraphAdaptor<const UGraph, DirectionMap>(graph, dm);
     818  DirUGraphAdaptor<const UGraph, DirectionMap>
     819  dirUGraphAdaptor(const UGraph& graph, DirectionMap& dm) {
     820    return DirUGraphAdaptor<const UGraph, DirectionMap>(graph, dm);
    793821  }
    794822
    795823  template<typename UGraph, typename DirectionMap>
    796   DirectUGraphAdaptor<const UGraph, const DirectionMap>
    797   directUGraphAdaptor(const UGraph& graph, const DirectionMap& dm) {
    798     return DirectUGraphAdaptor<const UGraph, const DirectionMap>(graph, dm);
     824  DirUGraphAdaptor<const UGraph, const DirectionMap>
     825  dirUGraphAdaptor(const UGraph& graph, const DirectionMap& dm) {
     826    return DirUGraphAdaptor<const UGraph, const DirectionMap>(graph, dm);
    799827  }
    800828
  • test/graph_adaptor_test.cc

    r1979 r1980  
    2727#include<lemon/full_graph.h>
    2828#include<lemon/graph_adaptor.h>
     29#include<lemon/ugraph_adaptor.h>
    2930
    3031#include"test/test_tools.h"
     
    6768      Graph::NodeMap<Graph::Edge> > >();
    6869
    69     /// \bug why does not compile with StaticGraph
    70     checkConcept<UGraph, UndirectGraphAdaptor<ListGraph> >();
     70    checkConcept<UGraph, UndirGraphAdaptor<Graph> >();
     71
     72    checkConcept<UGraph, SubUGraphAdaptor<UGraph,
     73      UGraph::NodeMap<bool> , UGraph::UEdgeMap<bool> > >();
     74    checkConcept<UGraph, NodeSubUGraphAdaptor<UGraph,
     75      UGraph::NodeMap<bool> > >();
     76    checkConcept<UGraph, EdgeSubUGraphAdaptor<UGraph,
     77      UGraph::UEdgeMap<bool> > >();
     78
     79    checkConcept<StaticGraph, DirUGraphAdaptor<UGraph,
     80      UGraph::UEdgeMap<bool> > >();
    7181  }
    7282  std::cout << __FILE__ ": All tests passed.\n";
Note: See TracChangeset for help on using the changeset viewer.