Changeset 2519:a7376f7ed899 in lemon-0.x for lemon/dynamic_tree.h
- Timestamp:
- 11/21/07 14:35:10 (16 years ago)
- Branch:
- default
- Phase:
- public
- Convert:
- svn:c9d7d8f5-90d6-0310-b91f-818b3a526b0e/lemon/trunk@3395
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
lemon/dynamic_tree.h
r2514 r2519 144 144 /// \brief Add \e x value to the cost of every node on the path from 145 145 /// \e item to findRoot(item). 146 void addCost(const Item &item, Value x) {146 void addCost(const Item &item, Value x) { 147 147 addPathCost(expose(_iim[item]), x); 148 148 } … … 201 201 } 202 202 203 int findPath(int v) {203 int findPath(int v) { 204 204 splay(v); 205 205 return v; 206 206 } 207 207 208 int findPathCost(int p, Value &d) {208 int findPathCost(int p, Value &d) { 209 209 while ((_data[p].right != -1 && 210 210 !_tolerance.less(0, _data[_data[p].right].dmin)) || … … 214 214 p = _data[p].right; 215 215 } else if (_data[p].left != -1 && 216 !_tolerance.less(0, _data[_data[p].left].dmin)) {216 !_tolerance.less(0, _data[_data[p].left].dmin)) { 217 217 p = _data[p].left; 218 218 } … … 231 231 } 232 232 233 void addPathCost(int p, Value x) {233 void addPathCost(int p, Value x) { 234 234 if (!_tolerance.less(x, _max_value)) { 235 _data[p].dmin = x;_data[p].dcost = x; 235 _data[p].dmin = x; 236 _data[p].dcost = x; 236 237 } else if (!_tolerance.less(-x, _max_value)) { 237 238 _data[p].dmin = 0; … … 364 365 Value aa = _data[a].dcost; 365 366 if (_tolerance.less(aa, _max_value)) { 366 aa += min;367 aa += min; 367 368 } 368 369 … … 372 373 Value bb = _data[b].dcost; 373 374 if (_tolerance.less(bb, _max_value)) { 374 bb += ab;375 bb += ab; 375 376 } 376 377 … … 381 382 cc = _data[c].dmin; 382 383 if (_tolerance.less(cc, _max_value)) { 383 cc +=min;384 cc += min; 384 385 } 385 386 } … … 687 688 } 688 689 689 int findPath(int v) {690 int findPath(int v) { 690 691 splay(v); 691 692 return v; 692 693 } 693 694 694 int findPathCost(int p, Value &d) {695 int findPathCost(int p, Value &d) { 695 696 while ((_data[p].right != -1 && 696 697 !_tolerance.less(0, _data[_data[p].right].dmin)) || … … 709 710 } 710 711 711 int findTail(int p) {712 int findTail(int p) { 712 713 while (_data[p].right != -1) { 713 714 p = _data[p].right; … … 717 718 } 718 719 719 void addPathCost(int p, Value x) {720 void addPathCost(int p, Value x) { 720 721 if (!_tolerance.less(x, _max_value)) { 721 722 _data[p].dmin = x;_data[p].dcost = x; … … 756 757 _data[p].dmin -= min; 757 758 } 758 if (q !=-1){759 if (q != -1){ 759 760 _data[q].parent = v; 760 761 if (_tolerance.less(_data[q].dmin,_max_value)) { … … 764 765 _data[v].left = p; 765 766 _data[v].right = q; 766 if (_tolerance.less(min, _max_value)) {767 if (_tolerance.less(min, _max_value)) { 767 768 _data[v].dcost = _data[v].dmin - min; 768 769 }
Note: See TracChangeset
for help on using the changeset viewer.