Changeset 998:89969b303727 in lemon0.x for src/lemon/graph_wrapper.h
 Timestamp:
 11/16/04 14:03:47 (16 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1388
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/lemon/graph_wrapper.h
r997 r998 1800 1800 1801 1801 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 1802 1864 /// For blocking flows. 1803 1865 … … 1814 1876 /// 1815 1877 /// \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; 1823 1886 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 } 1849 1891 // using GraphWrapper<Graph>::first; 1850 1892 // OutEdgeIt& first(OutEdgeIt& i, const Node& p) const { 1851 1893 // i=OutEdgeIt(*this, p); return i; 1852 1894 // } 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);1861 1895 }; 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 // }; 1862 1942 1863 1943 ///@}
Note: See TracChangeset
for help on using the changeset viewer.