COIN-OR::LEMON - Graph Library

Changeset 1842:8abf74160dc4 in lemon-0.x


Ignore:
Timestamp:
12/01/05 16:08:46 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2396
Message:

NewEdgeSetAdaptor? -> ListEdgeSet?
and moved to edge_set.h

Files:
1 added
8 edited

Legend:

Unmodified
Added
Removed
  • doc/graph_io.dox

    r1839 r1842  
    438438In our example there is a network with symmetric links and there are assymetric
    439439traffic request on the network. This construction can be stored in an
    440 undirected graph and in a directed \c NewEdgeSetAdaptor class. The example
     440undirected graph and in a directed \c ListEdgeSet class. The example
    441441shows the input with the \ref lemon::LemonReader "LemonReader" class:
    442442
     
    444444UndirListGraph network;
    445445UndirListGraph::UndirEdgeMap<double> capacity;
    446 NewEdgeSetAdaptor<UndirListGraph> traffic(network);
    447 NewEdgeSetAdaptor<UndirListGraph>::EdgeSet<double> request(network);
     446ListEdgeSet<UndirListGraph> traffic(network);
     447ListEdgeSet<UndirListGraph>::EdgeMap<double> request(network);
    448448
    449449LemonReader reader(std::cin);
     
    452452  undirEdgesetReader(reader, network, nodesetReader);
    453453undirEdgesetReader.readEdgeMap("capacity", capacity);
    454 EdgeSetReader<NewEdgeSetAdaptor<UndirListGraph> >
     454EdgeSetReader<ListEdgeSet<UndirListGraph> >
    455455  edgesetReader(reader, traffic, nodesetReader);
    456456edgesetReader.readEdgeMap("request", request);
     
    470470UndirListGraph network;
    471471UndirListGraph::UndirEdgeSet<double> capacity;
    472 NewEdgeSetAdaptor<UndirListGraph> traffic(network);
    473 NewEdgeSetAdaptor<UndirListGraph>::EdgeSet<double> request(network);
    474 
    475 UndirGraphReader reader(std::cin, network);
     472ListEdgeSet<UndirListGraph> traffic(network);
     473ListEdgeSet<UndirListGraph>::EdgeMap<double> request(network);
     474
     475UndirGraphReader<UndirListGraph> reader(std::cin, network);
    476476reader.readEdgeMap("capacity", capacity);
    477 EdgeSetReader edgesetReader(reader, traffic, reader);
     477EdgeSetReader<ListEdgeSet<UndirListGraph> >
     478  edgesetReader(reader, traffic, reader);
    478479edgesetReader.readEdgeMap("request", request);
    479480
  • lemon/Makefile.am

    r1835 r1842  
    3030        dijkstra.h \
    3131        dimacs.h \
     32        edge_set.h \
    3233        error.h \
    3334        fib_heap.h \
  • lemon/bits/alteration_notifier.h

    r1832 r1842  
    399399  };
    400400
     401
     402  template <typename _Base>
     403  class AlterableEdgeSetExtender : public _Base {
     404  public:
     405
     406    typedef AlterableEdgeSetExtender Graph;
     407    typedef _Base Parent;
     408
     409    typedef typename Parent::Edge Edge;
     410
     411    /// The edge observer registry.
     412    typedef AlterationNotifier<Edge> EdgeNotifier;
     413
     414  protected:
     415
     416    mutable EdgeNotifier edge_notifier;
     417
     418  public:
     419
     420    /// \brief Gives back the edge alteration notifier.
     421    ///
     422    /// Gives back the edge alteration notifier.
     423    EdgeNotifier& getNotifier(Edge) const {
     424      return edge_notifier;
     425    }
     426
     427    ~AlterableEdgeSetExtender() {
     428      edge_notifier.clear();
     429    }
     430   
     431  };
     432
    401433  /// \brief Class to extend an undirected graph with the functionality of
    402434  /// alteration observing.
     
    438470    }
    439471  };
     472
     473  template <typename _Base>
     474  class AlterableUndirEdgeSetExtender
     475    : public AlterableEdgeSetExtender<_Base> {
     476  public:
     477
     478    typedef AlterableUndirEdgeSetExtender Graph;
     479    typedef AlterableEdgeSetExtender<_Base> Parent;
     480
     481    typedef typename Parent::UndirEdge UndirEdge;
     482
     483    typedef AlterationNotifier<UndirEdge> UndirEdgeNotifier;
     484
     485  protected:
     486
     487    mutable UndirEdgeNotifier undir_edge_notifier;
     488
     489  public:
     490
     491    using Parent::getNotifier;
     492    UndirEdgeNotifier& getNotifier(UndirEdge) const {
     493      return undir_edge_notifier;
     494    }
     495
     496    ~AlterableUndirEdgeSetExtender() {
     497      undir_edge_notifier.clear();
     498    }
     499  };
     500
    440501
    441502
  • lemon/bits/clearable_graph_extender.h

    r1820 r1842  
    2727
    2828  template <typename _Base>
     29  class ClearableEdgeSetExtender : public _Base {
     30  public:
     31
     32    typedef ClearableEdgeSetExtender Graph;
     33    typedef _Base Parent;
     34    typedef typename Parent::Node Node;
     35    typedef typename Parent::Edge Edge;
     36
     37    void clear() {
     38      Parent::getNotifier(Edge()).clear();
     39      Parent::clear();
     40    }
     41
     42  };
     43
     44  template <typename _Base>
    2945  class ClearableUndirGraphExtender : public _Base {
    3046  public:
     
    3854    void clear() {
    3955      Parent::getNotifier(Node()).clear();
     56      Parent::getNotifier(UndirEdge()).clear();
     57      Parent::getNotifier(Edge()).clear();
     58      Parent::clear();
     59    }
     60  };
     61
     62  template <typename _Base>
     63  class ClearableUndirEdgeSetExtender : public _Base {
     64  public:
     65
     66    typedef ClearableUndirEdgeSetExtender Graph;
     67    typedef _Base Parent;
     68    typedef typename Parent::Node Node;
     69    typedef typename Parent::UndirEdge UndirEdge;
     70    typedef typename Parent::Edge Edge;
     71
     72    void clear() {
    4073      Parent::getNotifier(UndirEdge()).clear();
    4174      Parent::getNotifier(Edge()).clear();
  • lemon/bits/default_map.h

    r1820 r1842  
    226226  /// \e
    227227  template <typename _Base>
     228  class MappableEdgeSetExtender : public _Base {
     229  public:
     230
     231    typedef MappableEdgeSetExtender<_Base> Graph;
     232    typedef _Base Parent;
     233
     234    typedef typename Parent::Edge Edge;
     235    typedef typename Parent::EdgeIt EdgeIt;
     236
     237    template <typename _Value>
     238    class EdgeMap
     239      : public IterableMapExtender<DefaultMap<Graph, Edge, _Value> > {
     240    public:
     241      typedef MappableEdgeSetExtender Graph;
     242      typedef IterableMapExtender<DefaultMap<Graph, Edge, _Value> > Parent;
     243
     244      EdgeMap(const Graph& _g)
     245        : Parent(_g) {}
     246      EdgeMap(const Graph& _g, const _Value& _v)
     247        : Parent(_g, _v) {}
     248
     249      EdgeMap& operator=(const EdgeMap& cmap) {
     250        return operator=<EdgeMap>(cmap);
     251      }
     252
     253      template <typename CMap>
     254      EdgeMap& operator=(const CMap& cmap) {
     255        checkConcept<concept::ReadMap<Edge, _Value>, CMap>();
     256        const typename Parent::Graph* graph = Parent::getGraph();
     257        Edge it;
     258        for (graph->first(it); it != INVALID; graph->next(it)) {
     259          Parent::set(it, cmap[it]);
     260        }
     261        return *this;
     262      }
     263    };
     264   
     265  };
     266
     267  /// \e
     268  template <typename _Base>
    228269  class MappableUndirGraphExtender :
    229270    public MappableGraphExtender<_Base> {
     
    240281    public:
    241282      typedef MappableUndirGraphExtender Graph;
     283      typedef IterableMapExtender<
     284        DefaultMap<Graph, UndirEdge, _Value> > Parent;
     285
     286      UndirEdgeMap(const Graph& _g)
     287        : Parent(_g) {}
     288      UndirEdgeMap(const Graph& _g, const _Value& _v)
     289        : Parent(_g, _v) {}
     290
     291      UndirEdgeMap& operator=(const UndirEdgeMap& cmap) {
     292        return operator=<UndirEdgeMap>(cmap);
     293      }
     294
     295      template <typename CMap>
     296      UndirEdgeMap& operator=(const CMap& cmap) {
     297        checkConcept<concept::ReadMap<UndirEdge, _Value>, CMap>();
     298        const typename Parent::Graph* graph = Parent::getGraph();
     299        UndirEdge it;
     300        for (graph->first(it); it != INVALID; graph->next(it)) {
     301          Parent::set(it, cmap[it]);
     302        }
     303        return *this;
     304      }
     305    };
     306
     307
     308  };
     309
     310  /// \e
     311  template <typename _Base>
     312  class MappableUndirEdgeSetExtender :
     313    public MappableEdgeSetExtender<_Base> {
     314  public:
     315
     316    typedef MappableUndirEdgeSetExtender Graph;
     317    typedef MappableEdgeSetExtender<_Base> Parent;
     318
     319    typedef typename Parent::UndirEdge UndirEdge;
     320
     321    template <typename _Value>
     322    class UndirEdgeMap
     323      : public IterableMapExtender<DefaultMap<Graph, UndirEdge, _Value> > {
     324    public:
     325      typedef MappableUndirEdgeSetExtender Graph;
    242326      typedef IterableMapExtender<
    243327        DefaultMap<Graph, UndirEdge, _Value> > Parent;
  • lemon/bits/erasable_graph_extender.h

    r1627 r1842  
    4747
    4848  template <typename _Base>
     49  class ErasableEdgeSetExtender : public _Base {
     50  public:
     51
     52    typedef ErasableEdgeSetExtender Graph;
     53    typedef _Base Parent;
     54
     55    typedef typename Parent::Edge Edge;
     56
     57    void erase(const Edge& edge) {
     58      Parent::getNotifier(Edge()).erase(edge);
     59      Parent::erase(edge);
     60    }
     61
     62  };
     63
     64  template <typename _Base>
    4965  class ErasableUndirGraphExtender : public _Base {
    5066  public:
     
    8096  };
    8197
     98  template <typename _Base>
     99  class ErasableUndirEdgeSetExtender : public _Base {
     100  public:
     101
     102    typedef ErasableUndirEdgeSetExtender Graph;
     103    typedef _Base Parent;
     104
     105    typedef typename Parent::Node Node;
     106    typedef typename Parent::UndirEdge UndirEdge;
     107    typedef typename Parent::Edge Edge;
     108
     109    void erase(const UndirEdge& uedge) {
     110      std::vector<Edge> edges;
     111      edges.push_back(Parent::direct(uedge,true));
     112      edges.push_back(Parent::direct(uedge,false));
     113      Parent::getNotifier(Edge()).erase(edges);
     114      Parent::getNotifier(UndirEdge()).erase(uedge);
     115      Parent::erase(uedge);
     116    }
     117
     118  };
     119
    82120}
    83121
  • lemon/bits/extendable_graph_extender.h

    r1820 r1842  
    3131
    3232  template <typename _Base>
     33  class ExtendableEdgeSetExtender : public _Base {
     34  public:
     35
     36    typedef ExtendableEdgeSetExtender Graph;
     37    typedef _Base Parent;
     38
     39    typedef typename Parent::Edge Edge;
     40    typedef typename Parent::Node Node;
     41
     42    Edge addEdge(const Node& from, const Node& to) {
     43      Edge edge = Parent::addEdge(from, to);
     44      Parent::getNotifier(Edge()).add(edge);
     45      return edge;
     46    }
     47
     48  };
     49
     50  template <typename _Base>
    3351  class ExtendableUndirGraphExtender : public _Base {
    3452  public:
     
    4664      return node;
    4765    }
     66
     67    UndirEdge addEdge(const Node& from, const Node& to) {
     68      UndirEdge uedge = Parent::addEdge(from, to);
     69      Parent::getNotifier(UndirEdge()).add(uedge);
     70
     71      std::vector<Edge> edges;
     72      edges.push_back(Parent::direct(uedge, true));
     73      edges.push_back(Parent::direct(uedge, false));
     74      Parent::getNotifier(Edge()).add(edges);
     75
     76      return uedge;
     77    }
     78
     79  };
     80
     81  template <typename _Base>
     82  class ExtendableUndirEdgeSetExtender : public _Base {
     83  public:
     84
     85    typedef ExtendableUndirEdgeSetExtender Graph;
     86    typedef _Base Parent;
     87
     88    typedef typename Parent::Node Node;
     89    typedef typename Parent::Edge Edge;
     90    typedef typename Parent::UndirEdge UndirEdge;
    4891
    4992    UndirEdge addEdge(const Node& from, const Node& to) {
  • lemon/graph_adaptor.h

    r1839 r1842  
    16741674  };
    16751675
    1676   template <typename _Graph>
    1677   class NewEdgeSetAdaptorBase {
    1678   public:
    1679 
    1680     typedef _Graph Graph;
    1681     typedef typename Graph::Node Node;
    1682     typedef typename Graph::NodeIt NodeIt;
    1683 
    1684   protected:
    1685 
    1686     struct NodeT {
    1687       int first_out, first_in;
    1688       NodeT() : first_out(-1), first_in(-1) {}
    1689     };
    1690    
    1691     class NodesImpl : protected Graph::template NodeMap<NodeT> {
    1692 
    1693       typedef typename Graph::template NodeMap<NodeT> Parent;
    1694       typedef NewEdgeSetAdaptorBase<Graph> Adaptor;
    1695 
    1696       Adaptor& adaptor;
    1697 
    1698     public:
    1699 
    1700       NodesImpl(Adaptor& _adaptor, const Graph& _graph)
    1701         : Parent(_graph), adaptor(_adaptor) {}
    1702 
    1703       virtual ~NodesImpl() {}
    1704 
    1705       virtual void build() {
    1706         Parent::build();
    1707       }
    1708 
    1709       virtual void clear() {
    1710         adaptor._clear();
    1711         Parent::clear();
    1712       }
    1713      
    1714       virtual void add(const Node& node) {
    1715         Parent::add(node);
    1716         adaptor._add(node);
    1717       }
    1718      
    1719       virtual void erase(const Node& node) {
    1720         adaptor._erase(node);
    1721         Parent::erase(node);
    1722       }
    1723 
    1724       NodeT& operator[](const Node& node) {
    1725         return Parent::operator[](node);
    1726       }
    1727 
    1728       const NodeT& operator[](const Node& node) const {
    1729         return Parent::operator[](node);
    1730       }
    1731      
    1732     };
    1733 
    1734     NodesImpl* nodes;
    1735 
    1736     struct EdgeT {
    1737       Node source, target;
    1738       int next_out, next_in;
    1739       int prev_out, prev_in;
    1740       EdgeT() : prev_out(-1), prev_in(-1) {}
    1741     };
    1742 
    1743     std::vector<EdgeT> edges;
    1744 
    1745     int first_edge;
    1746     int first_free_edge;
    1747 
    1748     virtual void _clear() = 0;
    1749     virtual void _add(const Node& node) = 0;
    1750     virtual void _erase(const Node& node) = 0;
    1751    
    1752     const Graph* graph;
    1753 
    1754     void initalize(const Graph& _graph, NodesImpl& _nodes) {
    1755       graph = &_graph;
    1756       nodes = &_nodes;
    1757     }
    1758    
    1759   public:
    1760 
    1761     class Edge {
    1762       friend class NewEdgeSetAdaptorBase<Graph>;
    1763     protected:
    1764       Edge(int _id) : id(_id) {}
    1765       int id;
    1766     public:
    1767       Edge() {}
    1768       Edge(Invalid) : id(-1) {}
    1769       bool operator==(const Edge& edge) const { return id == edge.id; }
    1770       bool operator!=(const Edge& edge) const { return id != edge.id; }
    1771       bool operator<(const Edge& edge) const { return id < edge.id; }
    1772     };
    1773 
    1774     NewEdgeSetAdaptorBase() : first_edge(-1), first_free_edge(-1) {}
    1775     virtual ~NewEdgeSetAdaptorBase() {}
    1776 
    1777     Edge addEdge(const Node& source, const Node& target) {
    1778       int n;
    1779       if (first_free_edge == -1) {
    1780         n = edges.size();
    1781         edges.push_back(EdgeT());
    1782       } else {
    1783         n = first_free_edge;
    1784         first_free_edge = edges[first_free_edge].next_in;
    1785       }
    1786       edges[n].next_in = (*nodes)[target].first_in;
    1787       (*nodes)[target].first_in = n;
    1788       edges[n].next_out = (*nodes)[source].first_out;
    1789       (*nodes)[source].first_out = n;
    1790       edges[n].source = source;
    1791       edges[n].target = target;
    1792       return Edge(n);
    1793     }
    1794 
    1795     void erase(const Edge& edge) {
    1796       int n = edge.id;
    1797       if (edges[n].prev_in != -1) {
    1798         edges[edges[n].prev_in].next_in = edges[n].next_in;
    1799       } else {
    1800         (*nodes)[edges[n].target].first_in = edges[n].next_in;
    1801       }
    1802       if (edges[n].next_in != -1) {
    1803         edges[edges[n].next_in].prev_in = edges[n].prev_in;
    1804       }
    1805 
    1806       if (edges[n].prev_out != -1) {
    1807         edges[edges[n].prev_out].next_out = edges[n].next_out;
    1808       } else {
    1809         (*nodes)[edges[n].source].first_out = edges[n].next_out;
    1810       }
    1811       if (edges[n].next_out != -1) {
    1812         edges[edges[n].next_out].prev_out = edges[n].prev_out;
    1813       }
    1814            
    1815     }
    1816 
    1817     void first(Node& node) const {
    1818       graph->first(node);
    1819     }
    1820 
    1821     void next(Node& node) const {
    1822       graph->next(node);
    1823     }
    1824 
    1825     void first(Edge& edge) const {
    1826       Node node;
    1827       for (first(node); node != INVALID && (*nodes)[node].first_in == -1;
    1828            next(node));
    1829       edge.id = (node == INVALID) ? -1 : (*nodes)[node].first_in;
    1830     }
    1831 
    1832     void next(Edge& edge) const {
    1833       if (edges[edge.id].next_in != -1) {
    1834         edge.id = edges[edge.id].next_in;
    1835       } else {
    1836         Node node = edges[edge.id].target;
    1837         for (next(node); node != INVALID && (*nodes)[node].first_in == -1;
    1838              next(node));
    1839         edge.id = (node == INVALID) ? -1 : (*nodes)[node].first_in;
    1840       }     
    1841     }
    1842 
    1843     void firstOut(Edge& edge, const Node& node) const {
    1844       edge.id = (*nodes)[node].first_out;   
    1845     }
    1846    
    1847     void nextOut(Edge& edge) const {
    1848       edge.id = edges[edge.id].next_out;       
    1849     }
    1850 
    1851     void firstIn(Edge& edge, const Node& node) const {
    1852       edge.id = (*nodes)[node].first_in;         
    1853     }
    1854 
    1855     void nextIn(Edge& edge) const {
    1856       edge.id = edges[edge.id].next_in;   
    1857     }
    1858 
    1859     int id(const Node& node) const { return graph->id(node); }
    1860     int id(const Edge& edge) const { return edge.id; }
    1861 
    1862     Node nodeFromId(int id) const { return graph->fromId(id, Node()); }
    1863     Edge edgeFromId(int id) const { return Edge(id); }
    1864 
    1865     int maxNodeId() const { return graph->maxId(Node()); };
    1866     int maxEdgeId() const { return edges.size() - 1; }
    1867 
    1868     Node source(const Edge& edge) const { return edges[edge.id].source;}
    1869     Node target(const Edge& edge) const { return edges[edge.id].target;}
    1870 
    1871   };
    1872 
    1873 
    1874   /// \brief Graph adaptor using a node set of another graph and an
    1875   /// own edge set.
    1876   ///
    1877   /// This structure can be used to establish another graph over a node set
    1878   /// of an existing one. The node iterator will go through the nodes of the
    1879   /// original graph.
    1880   ///
    1881   /// \param _Graph The type of the graph which shares its node set with
    1882   /// this class. Its interface must conform to the \ref concept::StaticGraph
    1883   /// "StaticGraph" concept.
    1884   ///
    1885   /// In the edge extension and removing it conforms to the
    1886   /// \ref concept::ExtendableGraph "ExtendableGraph" concept.
    1887   template <typename _Graph>
    1888   class NewEdgeSetAdaptor :
    1889     public ErasableGraphExtender<
    1890     ClearableGraphExtender<
    1891     ExtendableGraphExtender<
    1892     MappableGraphExtender<
    1893     IterableGraphExtender<
    1894     AlterableGraphExtender<
    1895     GraphExtender<
    1896     NewEdgeSetAdaptorBase<_Graph> > > > > > > > {
    1897 
    1898   public:
    1899 
    1900     typedef ErasableGraphExtender<
    1901       ClearableGraphExtender<
    1902       ExtendableGraphExtender<
    1903       MappableGraphExtender<
    1904       IterableGraphExtender<
    1905       AlterableGraphExtender<
    1906       GraphExtender<
    1907       NewEdgeSetAdaptorBase<_Graph> > > > > > > > Parent;
    1908    
    1909 
    1910     typedef typename Parent::Node Node;
    1911     typedef typename Parent::Edge Edge;
    1912 
    1913   private:
    1914 
    1915     virtual void _clear() {
    1916       Parent::edges.clear();
    1917       Parent::first_edge = -1;
    1918       Parent::first_free_edge = -1;
    1919       Parent::getNotifier(Edge()).clear();
    1920       Parent::getNotifier(Node()).clear();
    1921     }
    1922 
    1923     virtual void _add(const Node& node) {
    1924       Parent::getNotifier(Node()).add(node);
    1925     }
    1926 
    1927     virtual void _erase(const Node& node) {
    1928       Edge edge;
    1929       Parent::firstOut(edge, node);
    1930       while (edge != INVALID) {
    1931         Parent::erase(edge);
    1932         Parent::firstOut(edge, node);
    1933       }
    1934 
    1935       Parent::firstIn(edge, node);
    1936       while (edge != INVALID) {
    1937         Parent::erase(edge);
    1938         Parent::firstIn(edge, node);
    1939       }
    1940      
    1941       Parent::getNotifier(Node()).erase(node);
    1942     }
    1943 
    1944 
    1945     typedef typename Parent::NodesImpl NodesImpl;
    1946 
    1947     NodesImpl nodes;
    1948    
    1949   public:
    1950 
    1951     /// \brief Constructor of the adaptor.
    1952     ///
    1953     /// Constructor of the adaptor.
    1954     NewEdgeSetAdaptor(const _Graph& _graph) : nodes(*this, _graph) {
    1955       Parent::initalize(_graph, nodes);
    1956     }
    1957 
    1958     void clear() {
    1959       Parent::getNotifier(Edge()).clear();     
    1960 
    1961       Parent::edges.clear();
    1962       Parent::first_edge = -1;
    1963       Parent::first_free_edge = -1;
    1964     }
    1965    
    1966   };
    1967 
    1968   /// \brief Graph adaptor using a node set of another graph and an
    1969   /// own undir edge set.
    1970   ///
    1971   /// This structure can be used to establish another undirected graph over
    1972   /// a node set of an existing one. The node iterator will go through the
    1973   /// nodes of the original graph.
    1974   ///
    1975   /// \param _Graph The type of the graph which shares its node set with
    1976   /// this class. Its interface must conform to the \ref concept::StaticGraph
    1977   /// "StaticGraph" concept.
    1978   ///
    1979   /// In the edge extension and removing it conforms to the
    1980   /// \ref concept::ExtendableGraph "ExtendableGraph" concept.
    1981   template <typename _Graph>
    1982   class NewUndirEdgeSetAdaptor :
    1983     public ErasableUndirGraphExtender<
    1984     ClearableUndirGraphExtender<
    1985     ExtendableUndirGraphExtender<
    1986     MappableUndirGraphExtender<
    1987     IterableUndirGraphExtender<
    1988     AlterableUndirGraphExtender<
    1989     UndirGraphExtender<
    1990     NewEdgeSetAdaptorBase<_Graph> > > > > > > > {
    1991 
    1992   public:
    1993 
    1994     typedef ErasableUndirGraphExtender<
    1995       ClearableUndirGraphExtender<
    1996       ExtendableUndirGraphExtender<
    1997       MappableUndirGraphExtender<
    1998       IterableUndirGraphExtender<
    1999       AlterableUndirGraphExtender<
    2000       UndirGraphExtender<
    2001       NewEdgeSetAdaptorBase<_Graph> > > > > > > > Parent;
    2002    
    2003 
    2004     typedef typename Parent::Node Node;
    2005     typedef typename Parent::Edge Edge;
    2006     typedef typename Parent::UndirEdge UndirEdge;
    2007 
    2008   private:
    2009 
    2010     virtual void _clear() {
    2011       Parent::edges.clear();
    2012       Parent::first_edge = -1;
    2013       Parent::first_free_edge = -1;
    2014       Parent::getNotifier(Edge()).clear();
    2015       Parent::getNotifier(Node()).clear();
    2016     }
    2017 
    2018     virtual void _add(const Node& node) {
    2019       Parent::getNotifier(Node()).add(node);
    2020     }
    2021 
    2022     virtual void _erase(const Node& node) {
    2023       Edge edge;
    2024       Parent::firstOut(edge, node);
    2025       while (edge != INVALID) {
    2026         Parent::erase(edge);
    2027         Parent::firstOut(edge, node);
    2028       }
    2029 
    2030       Parent::firstIn(edge, node);
    2031       while (edge != INVALID) {
    2032         Parent::erase(edge);
    2033         Parent::firstIn(edge, node);
    2034       }
    2035      
    2036       Parent::getNotifier(Node()).erase(node);
    2037     }
    2038 
    2039     typedef typename Parent::NodesImpl NodesImpl;
    2040 
    2041     NodesImpl nodes;
    2042    
    2043   public:
    2044 
    2045 
    2046     /// \brief Constructor of the adaptor.
    2047     ///
    2048     /// Constructor of the adaptor.
    2049     NewUndirEdgeSetAdaptor(const _Graph& _graph) : nodes(*this, _graph) {
    2050       Parent::initalize(_graph, nodes);
    2051     }
    2052 
    2053     void clear() {
    2054       Parent::getNotifier(Edge()).clear();     
    2055       Parent::getNotifier(UndirEdge()).clear();     
    2056 
    2057       Parent::edges.clear();
    2058       Parent::first_edge = -1;
    2059       Parent::first_free_edge = -1;
    2060     }
    2061    
    2062   };
    2063 
    20641676  ///@}
    20651677
Note: See TracChangeset for help on using the changeset viewer.