1.1 --- a/lemon/list_graph.h Fri Oct 14 10:40:00 2005 +0000
1.2 +++ b/lemon/list_graph.h Fri Oct 14 10:44:49 2005 +0000
1.3 @@ -308,11 +308,6 @@
1.4
1.5 };
1.6
1.7 - typedef AlterableGraphExtender<ListGraphBase> AlterableListGraphBase;
1.8 - typedef IterableGraphExtender<AlterableListGraphBase> IterableListGraphBase;
1.9 - typedef MappableGraphExtender<IterableListGraphBase> MappableListGraphBase;
1.10 - typedef ExtendableGraphExtender<MappableListGraphBase> ExtendableListGraphBase;
1.11 - typedef ClearableGraphExtender<ExtendableListGraphBase> ClearableListGraphBase;
1.12 typedef ErasableGraphExtender<
1.13 ClearableGraphExtender<
1.14 ExtendableGraphExtender<
1.15 @@ -320,8 +315,8 @@
1.16 IterableGraphExtender<
1.17 AlterableGraphExtender<ListGraphBase> > > > > > ExtendedListGraphBase;
1.18
1.19 -/// \addtogroup graphs
1.20 -/// @{
1.21 + /// \addtogroup graphs
1.22 + /// @{
1.23
1.24 ///A list graph class.
1.25
1.26 @@ -342,7 +337,11 @@
1.27 ///\note The <tt>Edge</tt>'s and <tt>OutEdge</tt>'s
1.28 ///referencing the changed edge remain
1.29 ///valid. However <tt>InEdge</tt>'s are invalidated.
1.30 - void changeTarget(Edge e, Node n) { _changeTarget(e,n); }
1.31 + void changeTarget(Edge e, Node n) {
1.32 + getNotifier(Edge()).signalChange(e);
1.33 + _changeTarget(e,n);
1.34 + getNotifier(Edge()).commitChange(e);
1.35 + }
1.36 /// Changes the source of \c e to \c n
1.37
1.38 /// Changes the source of \c e to \c n
1.39 @@ -350,7 +349,11 @@
1.40 ///\note The <tt>Edge</tt>'s and <tt>InEdge</tt>'s
1.41 ///referencing the changed edge remain
1.42 ///valid. However <tt>OutEdge</tt>'s are invalidated.
1.43 - void changeSource(Edge e, Node n) { _changeSource(e,n); }
1.44 + void changeSource(Edge e, Node n) {
1.45 + getNotifier(Edge()).signalChange(e);
1.46 + _changeSource(e,n);
1.47 + getNotifier(Edge()).commitChange(e);
1.48 + }
1.49
1.50 /// Invert the direction of an edge.
1.51
1.52 @@ -359,8 +362,10 @@
1.53 ///valid. However <tt>OutEdge</tt>'s and <tt>InEdge</tt>'s are invalidated.
1.54 void reverseEdge(Edge e) {
1.55 Node t=target(e);
1.56 + getNotifier(Edge()).signalChange(e);
1.57 _changeTarget(e,source(e));
1.58 _changeSource(e,t);
1.59 + getNotifier(Edge()).commitChange(e);
1.60 }
1.61
1.62 ///Using this it possible to avoid the superfluous memory allocation.
1.63 @@ -382,7 +387,7 @@
1.64 ///referencing a moved edge remain
1.65 ///valid. However <tt>InEdge</tt>'s and <tt>OutEdge</tt>'s
1.66 ///may be invalidated.
1.67 - void contract(Node a,Node b,bool r=true)
1.68 + void contract(Node a, Node b, bool r = true)
1.69 {
1.70 for(OutEdgeIt e(*this,b);e!=INVALID;) {
1.71 OutEdgeIt f=e;
1.72 @@ -562,8 +567,8 @@
1.73 AlterableUndirGraphExtender<
1.74 UndirGraphExtender<ListGraphBase> > > > > > > ExtendedUndirListGraphBase;
1.75
1.76 -/// \addtogroup graphs
1.77 -/// @{
1.78 + /// \addtogroup graphs
1.79 + /// @{
1.80
1.81 ///An undirected list graph class.
1.82
1.83 @@ -578,6 +583,66 @@
1.84 ///haven't been implemented yet.
1.85 ///
1.86 class UndirListGraph : public ExtendedUndirListGraphBase {
1.87 + public:
1.88 + typedef ExtendedUndirListGraphBase Parent;
1.89 + /// \brief Changes the target of \c e to \c n
1.90 + ///
1.91 + /// Changes the target of \c e to \c n
1.92 + ///
1.93 + /// \note The <tt>Edge</tt>'s and <tt>OutEdge</tt>'s
1.94 + /// referencing the changed edge remain
1.95 + /// valid. However <tt>InEdge</tt>'s are invalidated.
1.96 + void changeTarget(UndirEdge e, Node n) {
1.97 + getNotifier(UndirEdge()).signalChange(e);
1.98 + getNotifier(Edge()).signalChange(direct(e, true));
1.99 + getNotifier(Edge()).signalChange(direct(e, false));
1.100 + _changeTarget(e,n);
1.101 + getNotifier(UndirEdge()).commitChange(e);
1.102 + getNotifier(Edge()).commitChange(direct(e, true));
1.103 + getNotifier(Edge()).commitChange(direct(e, false));
1.104 + }
1.105 + /// Changes the source of \c e to \c n
1.106 + ///
1.107 + /// Changes the source of \c e to \c n
1.108 + ///
1.109 + ///\note The <tt>Edge</tt>'s and <tt>InEdge</tt>'s
1.110 + ///referencing the changed edge remain
1.111 + ///valid. However <tt>OutEdge</tt>'s are invalidated.
1.112 + void changeSource(UndirEdge e, Node n) {
1.113 + getNotifier(UndirEdge()).signalChange(e);
1.114 + getNotifier(Edge()).signalChange(direct(e, true));
1.115 + getNotifier(Edge()).signalChange(direct(e, false));
1.116 + _changeSource(e,n);
1.117 + getNotifier(UndirEdge()).commitChange(e);
1.118 + getNotifier(Edge()).commitChange(direct(e, true));
1.119 + getNotifier(Edge()).commitChange(direct(e, false));
1.120 + }
1.121 + /// \brief Contract two nodes.
1.122 + ///
1.123 + /// This function contracts two nodes.
1.124 + ///
1.125 + /// Node \p b will be removed but instead of deleting
1.126 + /// its neighboring edges, they will be joined to \p a.
1.127 + /// The last parameter \p r controls whether to remove loops. \c true
1.128 + /// means that loops will be removed.
1.129 + ///
1.130 + /// \note The <tt>Edge</tt>s
1.131 + /// referencing a moved edge remain
1.132 + /// valid.
1.133 + void contract(Node a, Node b, bool r = true) {
1.134 + for(IncEdgeIt e(*this, b); e!=INVALID;) {
1.135 + IncEdgeIt f = e; ++f;
1.136 + if (r && runningNode(e) == a) {
1.137 + erase(e);
1.138 + } else if (source(e) == b) {
1.139 + changeSource(e, a);
1.140 + } else {
1.141 + changeTarget(e, a);
1.142 + }
1.143 + e = f;
1.144 + }
1.145 + erase(b);
1.146 + }
1.147 };
1.148
1.149