COIN-OR::LEMON - Graph Library

Changeset 1538:777834118f73 in lemon-0.x for lemon/graph_adaptor.h


Ignore:
Timestamp:
07/04/05 19:22:03 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2030
Message:

NewUndirEdgeSetAdaptor? class
some doc
some bug fix

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/graph_adaptor.h

    r1536 r1538  
    12161216  };
    12171217
    1218   /// \e
    12191218  template <typename _Graph>
    12201219  class NewEdgeSetAdaptorBase {
     
    14141413  };
    14151414
     1415
     1416  /// \brief Graph adaptor using a node set of another graph and an
     1417  /// own edge set.
     1418  ///
     1419  /// This structure can be used to establish another graph over a node set
     1420  /// of an existing one. The node iterator will go through the nodes of the
     1421  /// original graph.
     1422  ///
     1423  /// \param _Graph The type of the graph which shares its node set with
     1424  /// this class. Its interface must conform to the \ref skeleton::StaticGraph
     1425  /// "StaticGraph" concept.
     1426  ///
     1427  /// In the edge extension and removing it conforms to the
     1428  /// \ref skeleton::ExtendableGraph "ExtendableGraph" concept.
    14161429  template <typename _Graph>
    14171430  class NewEdgeSetAdaptor :
     
    14761489  public:
    14771490
     1491    /// \brief Constructor of the adaptor.
     1492    ///
     1493    /// Constructor of the adaptor.
    14781494    NewEdgeSetAdaptor(const _Graph& _graph) : nodes(*this, _graph) {
    14791495      Parent::initalize(_graph, nodes);
     
    14811497
    14821498    void clear() {
     1499      Parent::getNotifier(Edge()).clear();     
     1500
    14831501      Parent::edges.clear();
    14841502      Parent::first_edge = -1;
    14851503      Parent::first_free_edge = -1;
    1486 
     1504    }
     1505   
     1506  };
     1507
     1508  /// \brief Graph adaptor using a node set of another graph and an
     1509  /// own undir edge set.
     1510  ///
     1511  /// This structure can be used to establish another undirected graph over
     1512  /// a node set of an existing one. The node iterator will go through the
     1513  /// nodes of the original graph.
     1514  ///
     1515  /// \param _Graph The type of the graph which shares its node set with
     1516  /// this class. Its interface must conform to the \ref skeleton::StaticGraph
     1517  /// "StaticGraph" concept.
     1518  ///
     1519  /// In the edge extension and removing it conforms to the
     1520  /// \ref skeleton::ExtendableGraph "ExtendableGraph" concept.
     1521  template <typename _Graph>
     1522  class NewUndirEdgeSetAdaptor :
     1523    public ErasableUndirGraphExtender<
     1524    ClearableUndirGraphExtender<
     1525    ExtendableUndirGraphExtender<
     1526    MappableUndirGraphExtender<
     1527    IterableUndirGraphExtender<
     1528    AlterableUndirGraphExtender<
     1529    UndirGraphExtender<
     1530    NewEdgeSetAdaptorBase<_Graph> > > > > > > > {
     1531
     1532  public:
     1533
     1534    typedef ErasableUndirGraphExtender<
     1535      ClearableUndirGraphExtender<
     1536      ExtendableUndirGraphExtender<
     1537      MappableUndirGraphExtender<
     1538      IterableUndirGraphExtender<
     1539      AlterableUndirGraphExtender<
     1540      UndirGraphExtender<
     1541      NewEdgeSetAdaptorBase<_Graph> > > > > > > > Parent;
     1542   
     1543
     1544    typedef typename Parent::Node Node;
     1545    typedef typename Parent::Edge Edge;
     1546    typedef typename Parent::UndirEdge UndirEdge;
     1547
     1548  private:
     1549
     1550    virtual void _clear() {
     1551      Parent::edges.clear();
     1552      Parent::first_edge = -1;
     1553      Parent::first_free_edge = -1;
     1554      Parent::getNotifier(Edge()).clear();
     1555      Parent::getNotifier(Node()).clear();
     1556    }
     1557
     1558    virtual void _add(const Node& node) {
     1559      Parent::getNotifier(Node()).add(node);
     1560    }
     1561
     1562    virtual void _erase(const Node& node) {
     1563      Edge edge;
     1564      Parent::firstOut(edge, node);
     1565      while (edge != INVALID) {
     1566        Parent::erase(edge);
     1567        Parent::firstOut(edge, node);
     1568      }
     1569
     1570      Parent::firstIn(edge, node);
     1571      while (edge != INVALID) {
     1572        Parent::erase(edge);
     1573        Parent::firstIn(edge, node);
     1574      }
     1575     
     1576      Parent::getNotifier(Node()).erase(node);
     1577    }
     1578
     1579    typedef typename Parent::NodesImpl NodesImpl;
     1580
     1581    NodesImpl nodes;
     1582   
     1583  public:
     1584
     1585
     1586    /// \brief Constructor of the adaptor.
     1587    ///
     1588    /// Constructor of the adaptor.
     1589    NewUndirEdgeSetAdaptor(const _Graph& _graph) : nodes(*this, _graph) {
     1590      Parent::initalize(_graph, nodes);
     1591    }
     1592
     1593    void clear() {
    14871594      Parent::getNotifier(Edge()).clear();     
     1595      Parent::getNotifier(UndirEdge()).clear();     
     1596
     1597      Parent::edges.clear();
     1598      Parent::first_edge = -1;
     1599      Parent::first_free_edge = -1;
    14881600    }
    14891601   
Note: See TracChangeset for help on using the changeset viewer.