COIN-OR::LEMON - Graph Library

Changeset 998:89969b303727 in lemon-0.x


Ignore:
Timestamp:
11/16/04 14:03:47 (20 years ago)
Author:
marci
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@1388
Message:

ErasingFirstGraphWrapper?

Location:
src
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • src/lemon/graph_wrapper.h

    r997 r998  
    18001800
    18011801
     1802
     1803  template <typename _Graph, typename FirstOutEdgesMap>
     1804  class ErasingFirstGraphWrapperBase : public GraphWrapperBase<_Graph> {
     1805  public:
     1806    typedef _Graph Graph;
     1807    typedef GraphWrapperBase<_Graph> Parent;
     1808  protected:
     1809    FirstOutEdgesMap* first_out_edges;
     1810    ErasingFirstGraphWrapperBase() : Parent(),
     1811                                     first_out_edges(0) { }
     1812
     1813    void setFirstOutEdgesMap(FirstOutEdgesMap& _first_out_edges) {
     1814      first_out_edges=&_first_out_edges;
     1815    }
     1816
     1817  public:
     1818
     1819    typedef typename Parent::Node Node;
     1820    typedef typename Parent::Edge Edge;
     1821
     1822//     using Parent::first;
     1823//     void first(Node& i) const {
     1824//       Parent::first(i);
     1825//       while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i);
     1826//     }
     1827//     void first(Edge& i) const {
     1828//       Parent::first(i);
     1829//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::next(i);
     1830//     }
     1831//     void firstIn(Edge& i, const Node& n) const {
     1832//       Parent::firstIn(i, n);
     1833//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextIn(i);
     1834//     }
     1835    void firstOut(Edge& i, const Node& n) const {
     1836      i=(*first_out_edges)[n];
     1837    }
     1838
     1839    void erase(const Edge& e) const {
     1840      Node n=source(e);
     1841      Edge f=e;
     1842      Parent::nextOut(f);
     1843      first_out_edges->set(n, f);
     1844    }   
     1845//     void next(Node& i) const {
     1846//       Parent::next(i);
     1847//       while (i!=INVALID && !(*node_filter_map)[i]) Parent::next(i);
     1848//     }
     1849//     void next(Edge& i) const {
     1850//       Parent::next(i);
     1851//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::next(i);
     1852//     }
     1853//     void nextIn(Edge& i) const {
     1854//       Parent::nextIn(i);
     1855//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextIn(i);
     1856//     }
     1857//     void nextOut(Edge& i) const {
     1858//       Parent::nextOut(i);
     1859//       while (i!=INVALID && !(*edge_filter_map)[i]) Parent::nextOut(i);
     1860//     }
     1861  };
     1862
     1863
    18021864  /// For blocking flows.
    18031865
     
    18141876  ///
    18151877  /// \author Marton Makai
    1816   template<typename Graph, typename FirstOutEdgesMap>
    1817   class ErasingFirstGraphWrapper : public GraphWrapper<Graph> {
    1818   public:
    1819     typedef GraphWrapper<Graph> Parent;
    1820   protected:
    1821     FirstOutEdgesMap* first_out_edges;
    1822   public:
     1878  template <typename _Graph, typename FirstOutEdgesMap>
     1879  class ErasingFirstGraphWrapper :
     1880    public IterableGraphExtender<
     1881    ErasingFirstGraphWrapperBase<_Graph, FirstOutEdgesMap> > {
     1882  public:
     1883    typedef _Graph Graph;
     1884    typedef IterableGraphExtender<
     1885      ErasingFirstGraphWrapperBase<_Graph, FirstOutEdgesMap> > Parent;
    18231886    ErasingFirstGraphWrapper(Graph& _graph,
    1824                              FirstOutEdgesMap& _first_out_edges) :
    1825       GraphWrapper<Graph>(_graph), first_out_edges(&_first_out_edges) { } 
    1826 
    1827     typedef typename GraphWrapper<Graph>::Node Node;
    1828     typedef typename GraphWrapper<Graph>::Edge Edge;
    1829     class OutEdgeIt : public Edge {
    1830       friend class GraphWrapper<Graph>;
    1831       friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
    1832       const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>* gw;
    1833     public:
    1834       OutEdgeIt() { }
    1835       OutEdgeIt(Invalid i) : Edge(i) { }
    1836       OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw,
    1837                 const Node& n) :
    1838         Edge((*(_gw.first_out_edges))[n]), gw(&_gw) { }
    1839       OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw,
    1840                 const Edge& e) :
    1841         Edge(e), gw(&_gw) { }
    1842       OutEdgeIt& operator++() {
    1843         *(static_cast<Edge*>(this))=
    1844           ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
    1845         return *this;
    1846       }
    1847     };
    1848 
     1887                             FirstOutEdgesMap& _first_out_edges) {
     1888      setGraph(_graph);
     1889      setFirstOutEdgesMap(_first_out_edges);
     1890    }
    18491891//     using GraphWrapper<Graph>::first;
    18501892//     OutEdgeIt& first(OutEdgeIt& i, const Node& p) const {
    18511893//       i=OutEdgeIt(*this, p); return i;
    18521894//     }
    1853     void erase(const Edge& e) const {
    1854       Node n=source(e);
    1855       typename Graph::OutEdgeIt f(*Parent::graph, n);
    1856       ++f;
    1857       first_out_edges->set(n, f);
    1858     }
    1859 
    1860     //    KEEP_MAPS(Parent, ErasingFirstGraphWrapper);
    18611895  };
     1896//   template<typename Graph, typename FirstOutEdgesMap>
     1897//   class ErasingFirstGraphWrapper : public GraphWrapper<Graph> {
     1898//   public:
     1899//     typedef GraphWrapper<Graph> Parent;
     1900//   protected:
     1901//     FirstOutEdgesMap* first_out_edges;
     1902//   public:
     1903//     ErasingFirstGraphWrapper(Graph& _graph,
     1904//                           FirstOutEdgesMap& _first_out_edges) :
     1905//       GraphWrapper<Graph>(_graph), first_out_edges(&_first_out_edges) { } 
     1906
     1907//     typedef typename GraphWrapper<Graph>::Node Node;
     1908//     typedef typename GraphWrapper<Graph>::Edge Edge;
     1909//     class OutEdgeIt : public Edge {
     1910//       friend class GraphWrapper<Graph>;
     1911//       friend class ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>;
     1912//       const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>* gw;
     1913//     public:
     1914//       OutEdgeIt() { }
     1915//       OutEdgeIt(Invalid i) : Edge(i) { }
     1916//       OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw,
     1917//              const Node& n) :
     1918//      Edge((*(_gw.first_out_edges))[n]), gw(&_gw) { }
     1919//       OutEdgeIt(const ErasingFirstGraphWrapper<Graph, FirstOutEdgesMap>& _gw,
     1920//              const Edge& e) :
     1921//      Edge(e), gw(&_gw) { }
     1922//       OutEdgeIt& operator++() {
     1923//      *(static_cast<Edge*>(this))=
     1924//        ++(typename Graph::OutEdgeIt(*(gw->graph), *this));
     1925//      return *this;
     1926//       }
     1927//     };
     1928
     1929// //     using GraphWrapper<Graph>::first;
     1930// //     OutEdgeIt& first(OutEdgeIt& i, const Node& p) const {
     1931// //       i=OutEdgeIt(*this, p); return i;
     1932// //     }
     1933//     void erase(const Edge& e) const {
     1934//       Node n=source(e);
     1935//       typename Graph::OutEdgeIt f(*Parent::graph, n);
     1936//       ++f;
     1937//       first_out_edges->set(n, f);
     1938//     }
     1939
     1940//     //    KEEP_MAPS(Parent, ErasingFirstGraphWrapper);
     1941//   };
    18621942
    18631943  ///@}
  • src/test/graph_wrapper_test.cc

    r997 r998  
    4343{
    4444  {
    45     checkConcept<StaticGraph, GraphWrapper<StaticGraph> >();
     45    typedef StaticGraph Graph;
     46    checkConcept<StaticGraph, GraphWrapper<Graph> >();
    4647
    47     checkConcept<StaticGraph, RevGraphWrapper<StaticGraph> >();
     48    checkConcept<StaticGraph, RevGraphWrapper<Graph> >();
    4849
    49     checkConcept<StaticGraph, SubGraphWrapper<StaticGraph,
    50       StaticGraph::NodeMap<bool> , StaticGraph::EdgeMap<bool> > >();
    51     checkConcept<StaticGraph, NodeSubGraphWrapper<StaticGraph,
    52       StaticGraph::NodeMap<bool> > >();
    53     checkConcept<StaticGraph, EdgeSubGraphWrapper<StaticGraph,
    54       StaticGraph::EdgeMap<bool> > >();
     50    checkConcept<StaticGraph, SubGraphWrapper<Graph,
     51      Graph::NodeMap<bool> , Graph::EdgeMap<bool> > >();
     52    checkConcept<StaticGraph, NodeSubGraphWrapper<Graph,
     53      Graph::NodeMap<bool> > >();
     54    checkConcept<StaticGraph, EdgeSubGraphWrapper<Graph,
     55      Graph::EdgeMap<bool> > >();
    5556   
    56     checkConcept<StaticGraph, SubBidirGraphWrapper<StaticGraph,
    57       StaticGraph::EdgeMap<bool>, StaticGraph::EdgeMap<bool> > >();
     57    checkConcept<StaticGraph, SubBidirGraphWrapper<Graph,
     58      Graph::EdgeMap<bool>, Graph::EdgeMap<bool> > >();
     59    checkConcept<StaticGraph, BidirGraph<Graph> >();
     60    checkConcept<StaticGraph, ResGraphWrapper<Graph, int,
     61      Graph::EdgeMap<int>, Graph::EdgeMap<int> > >();
    5862
    59     checkConcept<StaticGraph, BidirGraph<StaticGraph> >();
    60 
    61     checkConcept<StaticGraph, ResGraphWrapper<StaticGraph, int,
    62       StaticGraph::EdgeMap<int>, StaticGraph::EdgeMap<int> > >();
    63 
    64 //     function_requires<StaticGraphConcept<ErasingFirstGraphWrapper<Graph, Graph::NodeMap<Graph::Edge> > > >();
     63    checkConcept<StaticGraph, ErasingFirstGraphWrapper<Graph,
     64      Graph::NodeMap<Graph::Edge> > >();
    6565  }
    6666  std::cout << __FILE__ ": All tests passed.\n";
Note: See TracChangeset for help on using the changeset viewer.