Changeset 986:e997802b855c in lemon0.x for src/lemon/list_graph.h
 Timestamp:
 11/13/04 13:53:28 (16 years ago)
 Branch:
 default
 Phase:
 public
 Convert:
 svn:c9d7d8f590d60310b91f818b3a526b0e/lemon/trunk@1376
 File:

 1 edited
Legend:
 Unmodified
 Added
 Removed

src/lemon/list_graph.h
r980 r986 44 44 45 45 struct EdgeT { 46 int head, tail;46 int target, source; 47 47 int prev_in, prev_out; 48 48 int next_in, next_out; … … 112 112 int maxId(Edge = INVALID) const { return edges.size()1; } 113 113 114 Node tail(Edge e) const { return edges[e.id].tail; }115 Node head(Edge e) const { return edges[e.id].head; }114 Node source(Edge e) const { return edges[e.id].source; } 115 Node target(Edge e) const { return edges[e.id].target; } 116 116 117 117 … … 138 138 } else { 139 139 int n; 140 for(n = nodes[edges[edge.id]. head].next;140 for(n = nodes[edges[edge.id].target].next; 141 141 n!=1 && nodes[n].first_in == 1; 142 142 n = nodes[n].next); … … 199 199 } 200 200 201 edges[n]. tail= u.id;202 edges[n]. head= v.id;201 edges[n].source = u.id; 202 edges[n].target = v.id; 203 203 204 204 edges[n].next_out = nodes[u.id].first_out; … … 247 247 edges[edges[n].prev_in].next_in = edges[n].next_in; 248 248 } else { 249 nodes[edges[n]. head].first_in = edges[n].next_in;249 nodes[edges[n].target].first_in = edges[n].next_in; 250 250 } 251 251 … … 258 258 edges[edges[n].prev_out].next_out = edges[n].next_out; 259 259 } else { 260 nodes[edges[n]. tail].first_out = edges[n].next_out;260 nodes[edges[n].source].first_out = edges[n].next_out; 261 261 } 262 262 … … 273 273 274 274 protected: 275 void _move Head(Edge e, Node n)275 void _moveTarget(Edge e, Node n) 276 276 { 277 277 if(edges[e.id].next_in != 1) … … 279 279 if(edges[e.id].prev_in != 1) 280 280 edges[edges[e.id].prev_in].next_in = edges[e.id].next_in; 281 else nodes[edges[e.id]. head].first_in = edges[e.id].next_in;282 edges[e.id]. head= n.id;281 else nodes[edges[e.id].target].first_in = edges[e.id].next_in; 282 edges[e.id].target = n.id; 283 283 edges[e.id].prev_in = 1; 284 284 edges[e.id].next_in = nodes[n.id].first_in; 285 285 nodes[n.id].first_in = e.id; 286 286 } 287 void _move Tail(Edge e, Node n)287 void _moveSource(Edge e, Node n) 288 288 { 289 289 if(edges[e.id].next_out != 1) … … 291 291 if(edges[e.id].prev_out != 1) 292 292 edges[edges[e.id].prev_out].next_out = edges[e.id].next_out; 293 else nodes[edges[e.id]. tail].first_out = edges[e.id].next_out;294 edges[e.id]. tail= n.id;293 else nodes[edges[e.id].source].first_out = edges[e.id].next_out; 294 edges[e.id].source = n.id; 295 295 edges[e.id].prev_out = 1; 296 296 edges[e.id].next_out = nodes[n.id].first_out; … … 321 321 { 322 322 public: 323 /// Moves the headof \c e to \c n324 325 /// Moves the headof \c e to \c n323 /// Moves the target of \c e to \c n 324 325 /// Moves the target of \c e to \c n 326 326 /// 327 void move Head(Edge e, Node n) { _moveHead(e,n); }328 /// Moves the tailof \c e to \c n329 330 /// Moves the tailof \c e to \c n327 void moveTarget(Edge e, Node n) { _moveTarget(e,n); } 328 /// Moves the source of \c e to \c n 329 330 /// Moves the source of \c e to \c n 331 331 /// 332 void move Tail(Edge e, Node n) { _moveTail(e,n); }332 void moveSource(Edge e, Node n) { _moveSource(e,n); } 333 333 334 334 ///Using this it possible to avoid the superfluous memory allocation.
Note: See TracChangeset
for help on using the changeset viewer.