Changeset 1718:6a958ab38386 in lemon-0.x for lemon/list_graph.h
- Timestamp:
- 10/14/05 12:44:49 (18 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@2245
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
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
Note: See TracChangeset
for help on using the changeset viewer.