Changeset 1729:06f939455cb1 in lemon-0.x
- Timestamp:
- 10/17/05 12:28:48 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2256
- Files:
-
- 5 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/alteration_notifier.h
r1718 r1729 173 173 } 174 174 175 /// \brief Signal a property change on the given item.176 ///177 /// Signal a property change on the given item. It should178 /// 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 should186 /// 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 191 175 /// \brief The member function to notificate the observer about the 192 176 /// container is built. … … 325 309 } 326 310 } 327 328 /// \brief Signal a property change on the given item.329 ///330 /// Signal a property change on the given item. It should331 /// 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 should344 /// 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 }353 311 354 312 /// \brief Notifies all the registered observers about the container is -
lemon/graph_utils.h
r1720 r1729 1326 1326 /// whenever the graph changes. 1327 1327 /// 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 /// 1328 1336 /// \sa OutDegMap 1329 1337 … … 1424 1432 /// whenever the graph changes. 1425 1433 /// 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 /// 1426 1442 /// \sa InDegMap 1427 1443 -
lemon/list_graph.h
r1718 r1729 339 339 ///valid. However <tt>InEdge</tt>'s are invalidated. 340 340 void changeTarget(Edge e, Node n) { 341 getNotifier(Edge()).signalChange(e);342 341 _changeTarget(e,n); 343 getNotifier(Edge()).commitChange(e);344 342 } 345 343 /// Changes the source of \c e to \c n … … 351 349 ///valid. However <tt>OutEdge</tt>'s are invalidated. 352 350 void changeSource(Edge e, Node n) { 353 getNotifier(Edge()).signalChange(e);354 351 _changeSource(e,n); 355 getNotifier(Edge()).commitChange(e);356 352 } 357 353 … … 363 359 void reverseEdge(Edge e) { 364 360 Node t=target(e); 365 getNotifier(Edge()).signalChange(e);366 361 _changeTarget(e,source(e)); 367 362 _changeSource(e,t); 368 getNotifier(Edge()).commitChange(e);369 363 } 370 364 … … 594 588 /// valid. However <tt>InEdge</tt>'s are invalidated. 595 589 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 590 _changeTarget(e,n); 600 getNotifier(UndirEdge()).commitChange(e);601 getNotifier(Edge()).commitChange(direct(e, true));602 getNotifier(Edge()).commitChange(direct(e, false));603 591 } 604 592 /// Changes the source of \c e to \c n … … 610 598 ///valid. However <tt>OutEdge</tt>'s are invalidated. 611 599 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 600 _changeSource(e,n); 616 getNotifier(UndirEdge()).commitChange(e);617 getNotifier(Edge()).commitChange(direct(e, true));618 getNotifier(Edge()).commitChange(direct(e, false));619 601 } 620 602 /// \brief Contract two nodes. -
lemon/smart_graph.h
r1718 r1729 316 316 Node split(Node n, bool connect = true) 317 317 { 318 for (OutEdgeIt it(*this, n); it != INVALID; ++it) {319 getNotifier(Edge()).signalChange(it);320 }321 318 Node b = _split(n,connect); 322 for (OutEdgeIt it(*this, b); it != INVALID; ++it) {323 getNotifier(Edge()).commitChange(it);324 }325 319 return b; 326 320 } -
test/graph_utils_test.cc
r1728 r1729 83 83 ListGraph graph; 84 84 InDegMap<ListGraph> inDeg(graph); 85 OutDegMap<ListGraph> outDeg(graph); 85 86 std::vector<ListGraph::Node> nodes(nodeNum); 86 87 for (int i = 0; i < nodeNum; ++i) { … … 96 97 "Wrong in degree map"); 97 98 } 98 for (int i = 0; i < edgeNum; ++i) {99 graph.changeTarget(edges[i], nodes[urandom(nodeNum)]);100 }101 99 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]), 117 101 "Wrong in degree map"); 118 102 }
Note: See TracChangeset
for help on using the changeset viewer.