Changeset 1718:6a958ab38386 in lemon-0.x
- Timestamp:
- 10/14/05 12:44:49 (20 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2245
- Location:
- lemon
- Files:
-
- 3 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/bits/alteration_notifier.h
r1701 r1718 140 140 141 141 /// \brief The member function to notificate the observer about 142 /// simulitem is added to the container.143 /// 144 /// The add() member function notificates the observer about anitem142 /// more item is added to the container. 143 /// 144 /// The add() member function notificates the observer about more item 145 145 /// is added to the container. It have to be overrided in the 146 146 /// subclasses. … … 161 161 virtual void erase(const Item&) = 0; 162 162 163 /// \brief The member function to notificate the observer about 164 /// more item is erased from the container. 165 /// 166 /// The erase() member function notificates the observer about more item 167 /// is erased from the container. It have to be overrided in the 168 /// subclasses. 163 169 virtual void erase(const std::vector<Item>& items) { 164 170 for (int i = 0; i < (int)items.size(); ++i) { … … 166 172 } 167 173 } 174 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&) {} 168 190 169 191 /// \brief The member function to notificate the observer about the … … 304 326 } 305 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 } 306 353 307 354 /// \brief Notifies all the registered observers about the container is -
lemon/list_graph.h
r1702 r1718 309 309 }; 310 310 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;316 311 typedef ErasableGraphExtender< 317 312 ClearableGraphExtender< … … 321 316 AlterableGraphExtender<ListGraphBase> > > > > > ExtendedListGraphBase; 322 317 323 /// \addtogroup graphs324 /// @{318 /// \addtogroup graphs 319 /// @{ 325 320 326 321 ///A list graph class. … … 343 338 ///referencing the changed edge remain 344 339 ///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 } 346 345 /// Changes the source of \c e to \c n 347 346 … … 351 350 ///referencing the changed edge remain 352 351 ///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 } 354 357 355 358 /// Invert the direction of an edge. … … 360 363 void reverseEdge(Edge e) { 361 364 Node t=target(e); 365 getNotifier(Edge()).signalChange(e); 362 366 _changeTarget(e,source(e)); 363 367 _changeSource(e,t); 368 getNotifier(Edge()).commitChange(e); 364 369 } 365 370 … … 383 388 ///valid. However <tt>InEdge</tt>'s and <tt>OutEdge</tt>'s 384 389 ///may be invalidated. 385 void contract(Node a, Node b,bool r=true)390 void contract(Node a, Node b, bool r = true) 386 391 { 387 392 for(OutEdgeIt e(*this,b);e!=INVALID;) { … … 563 568 UndirGraphExtender<ListGraphBase> > > > > > > ExtendedUndirListGraphBase; 564 569 565 /// \addtogroup graphs566 /// @{570 /// \addtogroup graphs 571 /// @{ 567 572 568 573 ///An undirected list graph class. … … 579 584 /// 580 585 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 } 581 646 }; 582 647 -
lemon/smart_graph.h
r1692 r1718 76 76 77 77 SmartGraphBase() : nodes(), edges() { } 78 SmartGraphBase(const SmartGraphBase &_g) : nodes(_g.nodes), edges(_g.edges) { } 78 SmartGraphBase(const SmartGraphBase &_g) 79 : nodes(_g.nodes), edges(_g.edges) { } 79 80 80 81 typedef True NodeNumTag; … … 315 316 Node split(Node n, bool connect = true) 316 317 { 317 return _split(n,connect); 318 for (OutEdgeIt it(*this, n); it != INVALID; ++it) { 319 getNotifier(Edge()).signalChange(it); 320 } 321 Node b = _split(n,connect); 322 for (OutEdgeIt it(*this, b); it != INVALID; ++it) { 323 getNotifier(Edge()).commitChange(it); 324 } 325 return b; 318 326 } 319 327
Note: See TracChangeset
for help on using the changeset viewer.