COIN-OR::LEMON - Graph Library

Changeset 1718:6a958ab38386 in lemon-0.x for lemon/list_graph.h


Ignore:
Timestamp:
10/14/05 12:44:49 (19 years ago)
Author:
Balazs Dezso
Branch:
default
Phase:
public
Convert:
svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2245
Message:

Extending observer interface
It will be used in the indegmap, outdegmap types

File:
1 edited

Legend:

Unmodified
Added
Removed
  • lemon/list_graph.h

    r1702 r1718  
    309309  };
    310310
    311   typedef AlterableGraphExtender<ListGraphBase> AlterableListGraphBase;
    312   typedef IterableGraphExtender<AlterableListGraphBase> IterableListGraphBase;
    313   typedef MappableGraphExtender<IterableListGraphBase> MappableListGraphBase;
    314   typedef ExtendableGraphExtender<MappableListGraphBase> ExtendableListGraphBase;
    315   typedef ClearableGraphExtender<ExtendableListGraphBase> ClearableListGraphBase;
    316311  typedef ErasableGraphExtender<
    317312    ClearableGraphExtender<
     
    321316    AlterableGraphExtender<ListGraphBase> > > > > > ExtendedListGraphBase;
    322317
    323 /// \addtogroup graphs
    324 /// @{
     318  /// \addtogroup graphs
     319  /// @{
    325320
    326321  ///A list graph class.
     
    343338    ///referencing the changed edge remain
    344339    ///valid. However <tt>InEdge</tt>'s are invalidated.
    345     void changeTarget(Edge e, Node n) { _changeTarget(e,n); }
     340    void changeTarget(Edge e, Node n) {
     341      getNotifier(Edge()).signalChange(e);
     342      _changeTarget(e,n);
     343      getNotifier(Edge()).commitChange(e);
     344    }
    346345    /// Changes the source of \c e to \c n
    347346
     
    351350    ///referencing the changed edge remain
    352351    ///valid. However <tt>OutEdge</tt>'s are invalidated.
    353     void changeSource(Edge e, Node n) { _changeSource(e,n); }
     352    void changeSource(Edge e, Node n) {
     353      getNotifier(Edge()).signalChange(e);
     354      _changeSource(e,n);
     355      getNotifier(Edge()).commitChange(e);
     356    }
    354357
    355358    /// Invert the direction of an edge.
     
    360363    void reverseEdge(Edge e) {
    361364      Node t=target(e);
     365      getNotifier(Edge()).signalChange(e);
    362366      _changeTarget(e,source(e));
    363367      _changeSource(e,t);
     368      getNotifier(Edge()).commitChange(e);
    364369    }
    365370
     
    383388    ///valid. However <tt>InEdge</tt>'s and <tt>OutEdge</tt>'s
    384389    ///may be invalidated.
    385     void contract(Node a,Node b,bool r=true)
     390    void contract(Node a, Node b, bool r = true)
    386391    {
    387392      for(OutEdgeIt e(*this,b);e!=INVALID;) {
     
    563568    UndirGraphExtender<ListGraphBase> > > > > > > ExtendedUndirListGraphBase;
    564569
    565 /// \addtogroup graphs
    566 /// @{
     570  /// \addtogroup graphs
     571  /// @{
    567572
    568573  ///An undirected list graph class.
     
    579584  ///
    580585  class UndirListGraph : public ExtendedUndirListGraphBase {
     586  public:
     587    typedef ExtendedUndirListGraphBase Parent;
     588    /// \brief Changes the target of \c e to \c n
     589    ///
     590    /// Changes the target of \c e to \c n
     591    ///
     592    /// \note The <tt>Edge</tt>'s and <tt>OutEdge</tt>'s
     593    /// referencing the changed edge remain
     594    /// valid. However <tt>InEdge</tt>'s are invalidated.
     595    void changeTarget(UndirEdge e, Node n) {
     596      getNotifier(UndirEdge()).signalChange(e);
     597      getNotifier(Edge()).signalChange(direct(e, true));
     598      getNotifier(Edge()).signalChange(direct(e, false));
     599      _changeTarget(e,n);
     600      getNotifier(UndirEdge()).commitChange(e);
     601      getNotifier(Edge()).commitChange(direct(e, true));
     602      getNotifier(Edge()).commitChange(direct(e, false));
     603    }
     604    /// Changes the source of \c e to \c n
     605    ///
     606    /// Changes the source of \c e to \c n
     607    ///
     608    ///\note The <tt>Edge</tt>'s and <tt>InEdge</tt>'s
     609    ///referencing the changed edge remain
     610    ///valid. However <tt>OutEdge</tt>'s are invalidated.
     611    void changeSource(UndirEdge e, Node n) {
     612      getNotifier(UndirEdge()).signalChange(e);
     613      getNotifier(Edge()).signalChange(direct(e, true));
     614      getNotifier(Edge()).signalChange(direct(e, false));
     615      _changeSource(e,n);
     616      getNotifier(UndirEdge()).commitChange(e);
     617      getNotifier(Edge()).commitChange(direct(e, true));
     618      getNotifier(Edge()).commitChange(direct(e, false));
     619    }
     620    /// \brief Contract two nodes.
     621    ///
     622    /// This function contracts two nodes.
     623    ///
     624    /// Node \p b will be removed but instead of deleting
     625    /// its neighboring edges, they will be joined to \p a.
     626    /// The last parameter \p r controls whether to remove loops. \c true
     627    /// means that loops will be removed.
     628    ///
     629    /// \note The <tt>Edge</tt>s
     630    /// referencing a moved edge remain
     631    /// valid.
     632    void contract(Node a, Node b, bool r = true) {
     633      for(IncEdgeIt e(*this, b); e!=INVALID;) {
     634        IncEdgeIt f = e; ++f;
     635        if (r && runningNode(e) == a) {
     636          erase(e);
     637        } else if (source(e) == b) {
     638          changeSource(e, a);
     639        } else {
     640          changeTarget(e, a);
     641        }
     642        e = f;
     643      }
     644      erase(b);
     645    }
    581646  };
    582647
Note: See TracChangeset for help on using the changeset viewer.