COIN-OR::LEMON - Graph Library

Changeset 1729:06f939455cb1 in lemon-0.x


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

Removing signal/commit Change from alteration notifier

It makes slower the change Target/Source? functions
and used only by the In/Out? DegMap?

Files:
5 edited

Legend:

Unmodified
Added
Removed
  • lemon/bits/alteration_notifier.h

    r1718 r1729  
    173173      }
    174174
    175       /// \brief Signal a property change on the given item.
    176       ///
    177       /// Signal a property change on the given item. It should
    178       /// be used always with the commitChange() function.
    179       /// This function is called always the property change.
    180       /// The commitChange() is called always after the change.
    181       virtual void signalChange(const Item&) {}
    182 
    183       /// \brief Commit the property change on the given item.
    184       ///
    185       /// Commit the property change on the given item. It should
    186       /// be used always with the signalChange() function.
    187       /// This function is called always the property change.
    188       /// The commitChange() is called always after the change.
    189       virtual void commitChange(const Item&) {}
    190 
    191175      /// \brief The member function to notificate the observer about the
    192176      /// container is built.
     
    325309      }
    326310    }
    327    
    328     /// \brief Signal a property change on the given item.
    329     ///
    330     /// Signal a property change on the given item. It should
    331     /// be used always with the commitChange() function.
    332     /// This function is called always the property change.
    333     /// The commitChange() is called always after the change.
    334     void signalChange(const Item& item) {
    335       typename Container::iterator it;
    336       for (it = container.begin(); it != container.end(); ++it) {
    337         (*it)->signalChange(item);
    338       }
    339     }
    340    
    341     /// \brief Commit the property change on the given item.
    342     ///
    343     /// Commit the property change on the given item. It should
    344     /// be used always with the signalChange() function.
    345     /// This function is called always the property change.
    346     /// The commitChange() is called always after the change.
    347     void commitChange(const Item& item) {
    348       typename Container::iterator it;
    349       for (it = container.begin(); it != container.end(); ++it) {
    350         (*it)->commitChange(item);
    351       }
    352     }
    353311
    354312    /// \brief Notifies all the registered observers about the container is
  • lemon/graph_utils.h

    r1720 r1729  
    13261326  /// whenever the graph changes.
    13271327  ///
     1328  /// \warning Besides addNode() and addEdge(), a graph structure may provide
     1329  /// alternative ways to mogify the graph. The correct behavior of InDegMap
     1330  /// is not guarantied if these additional featureas are used. For example
     1331  /// the funstions \ref ListGraph::changeSource() "changeSource()",
     1332  /// \ref ListGraph::changeTarget() "changeTarget()" and
     1333  /// \ref ListGraph::reverseEdge() "reverseEdge()"
     1334  /// of \ref ListGraph will \e not update the degree values correctly.
     1335  ///
    13281336  /// \sa OutDegMap
    13291337
     
    14241432  /// whenever the graph changes.
    14251433  ///
     1434  /// \warning Besides addNode() and addEdge(), a graph structure may provide
     1435  /// alternative ways to mogify the graph. The correct behavior of OutDegMap
     1436  /// is not guarantied if these additional featureas are used. For example
     1437  /// the funstions \ref ListGraph::changeSource() "changeSource()",
     1438  /// \ref ListGraph::changeTarget() "changeTarget()" and
     1439  /// \ref ListGraph::reverseEdge() "reverseEdge()"
     1440  /// of \ref ListGraph will \e not update the degree values correctly.
     1441  ///
    14261442  /// \sa InDegMap
    14271443
  • lemon/list_graph.h

    r1718 r1729  
    339339    ///valid. However <tt>InEdge</tt>'s are invalidated.
    340340    void changeTarget(Edge e, Node n) {
    341       getNotifier(Edge()).signalChange(e);
    342341      _changeTarget(e,n);
    343       getNotifier(Edge()).commitChange(e);
    344342    }
    345343    /// Changes the source of \c e to \c n
     
    351349    ///valid. However <tt>OutEdge</tt>'s are invalidated.
    352350    void changeSource(Edge e, Node n) {
    353       getNotifier(Edge()).signalChange(e);
    354351      _changeSource(e,n);
    355       getNotifier(Edge()).commitChange(e);
    356352    }
    357353
     
    363359    void reverseEdge(Edge e) {
    364360      Node t=target(e);
    365       getNotifier(Edge()).signalChange(e);
    366361      _changeTarget(e,source(e));
    367362      _changeSource(e,t);
    368       getNotifier(Edge()).commitChange(e);
    369363    }
    370364
     
    594588    /// valid. However <tt>InEdge</tt>'s are invalidated.
    595589    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));
    599590      _changeTarget(e,n);
    600       getNotifier(UndirEdge()).commitChange(e);
    601       getNotifier(Edge()).commitChange(direct(e, true));
    602       getNotifier(Edge()).commitChange(direct(e, false));
    603591    }
    604592    /// Changes the source of \c e to \c n
     
    610598    ///valid. However <tt>OutEdge</tt>'s are invalidated.
    611599    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));
    615600      _changeSource(e,n);
    616       getNotifier(UndirEdge()).commitChange(e);
    617       getNotifier(Edge()).commitChange(direct(e, true));
    618       getNotifier(Edge()).commitChange(direct(e, false));
    619601    }
    620602    /// \brief Contract two nodes.
  • lemon/smart_graph.h

    r1718 r1729  
    316316    Node split(Node n, bool connect = true)
    317317    {
    318       for (OutEdgeIt it(*this, n); it != INVALID; ++it) {
    319         getNotifier(Edge()).signalChange(it);
    320       }
    321318      Node b = _split(n,connect);
    322       for (OutEdgeIt it(*this, b); it != INVALID; ++it) {
    323         getNotifier(Edge()).commitChange(it);
    324       }
    325319      return b;
    326320    }
  • test/graph_utils_test.cc

    r1728 r1729  
    8383    ListGraph graph;
    8484    InDegMap<ListGraph> inDeg(graph);
     85    OutDegMap<ListGraph> outDeg(graph);
    8586    std::vector<ListGraph::Node> nodes(nodeNum);
    8687    for (int i = 0; i < nodeNum; ++i) {
     
    9697            "Wrong in degree map");
    9798    }
    98     for (int i = 0; i < edgeNum; ++i) {
    99       graph.changeTarget(edges[i], nodes[urandom(nodeNum)]);
    100     }
    10199    for (int i = 0; i < nodeNum; ++i) {
    102       check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]),
    103             "Wrong in degree map");
    104     }
    105     for (int i = 0; i < edgeNum; ++i) {
    106       graph.changeSource(edges[i], nodes[urandom(nodeNum)]);
    107     }
    108     for (int i = 0; i < nodeNum; ++i) {
    109       check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]),
    110             "Wrong in degree map");
    111     }
    112     for (int i = 0; i < edgeNum; ++i) {
    113       graph.reverseEdge(edges[i]);
    114     }
    115     for (int i = 0; i < nodeNum; ++i) {
    116       check(inDeg[nodes[i]] == countInEdges(graph, nodes[i]),
     100      check(outDeg[nodes[i]] == countOutEdges(graph, nodes[i]),
    117101            "Wrong in degree map");
    118102    }
Note: See TracChangeset for help on using the changeset viewer.