diff --git a/DataStructures/SearchEngine.h b/DataStructures/SearchEngine.h index 077367a49..f1d56771b 100644 --- a/DataStructures/SearchEngine.h +++ b/DataStructures/SearchEngine.h @@ -36,7 +36,7 @@ struct _HeapData { _HeapData( NodeID p ) : parent(p) { } }; -typedef boost::thread_specific_ptr > HeapPtr; +typedef boost::thread_specific_ptr > HeapPtr; template class SearchEngine { @@ -58,12 +58,12 @@ public: inline void InitializeThreadLocalStorageIfNecessary() { if(!_forwardHeap.get()) - _forwardHeap.reset(new BinaryHeap< NodeID, NodeID, int, _HeapData >(nodeHelpDesk->getNumberOfNodes())); + _forwardHeap.reset(new BinaryHeap< NodeID, NodeID, int, _HeapData>(nodeHelpDesk->getNumberOfNodes())); else _forwardHeap->Clear(); if(!_backwardHeap.get()) - _backwardHeap.reset(new BinaryHeap< NodeID, NodeID, int, _HeapData >(nodeHelpDesk->getNumberOfNodes())); + _backwardHeap.reset(new BinaryHeap< NodeID, NodeID, int, _HeapData>(nodeHelpDesk->getNumberOfNodes())); else _backwardHeap->Clear(); } @@ -89,19 +89,19 @@ public: _backwardHeap->Insert(phantomNodes.targetPhantom.edgeBasedNode+1, phantomNodes.targetPhantom.weight2, phantomNodes.targetPhantom.edgeBasedNode+1); // INFO("d) back insert " << phantomNodes.targetPhantom.edgeBasedNode+1 << ", weight: " << phantomNodes.targetPhantom.weight2); } - int startOffset = (phantomNodes.startPhantom.isBidirected() ? std::max(phantomNodes.startPhantom.weight1, phantomNodes.startPhantom.weight2) : phantomNodes.startPhantom.weight1) ; - int targetOffset = (phantomNodes.targetPhantom.isBidirected() ? std::max(phantomNodes.targetPhantom.weight1, phantomNodes.targetPhantom.weight2) : phantomNodes.targetPhantom.weight1) ; + int offset = (phantomNodes.startPhantom.isBidirected() ? std::max(phantomNodes.startPhantom.weight1, phantomNodes.startPhantom.weight2) : phantomNodes.startPhantom.weight1) ; + offset += (phantomNodes.targetPhantom.isBidirected() ? std::max(phantomNodes.targetPhantom.weight1, phantomNodes.targetPhantom.weight2) : phantomNodes.targetPhantom.weight1) ; while(_forwardHeap->Size() + _backwardHeap->Size() > 0){ if(_forwardHeap->Size() > 0){ - _RoutingStep(_forwardHeap, _backwardHeap, true, &middle, &_upperbound, startOffset+targetOffset); + _RoutingStep(_forwardHeap, _backwardHeap, true, &middle, &_upperbound, 2*offset); } if(_backwardHeap->Size() > 0){ - _RoutingStep(_backwardHeap, _forwardHeap, false, &middle, &_upperbound, startOffset+targetOffset); + _RoutingStep(_backwardHeap, _forwardHeap, false, &middle, &_upperbound, 2*offset); } } - INFO("-> dist " << _upperbound); +// INFO("-> dist " << _upperbound); if ( _upperbound == INT_MAX ) { return _upperbound; } @@ -158,7 +158,7 @@ public: return GetEscapedNameForNameID(nameID); } private: - inline void _RoutingStep(HeapPtr & _forwardHeap, HeapPtr & _backwardHeap, const bool & forwardDirection, NodeID *middle, int *_upperbound, const int negativeOffset) const { + inline void _RoutingStep(HeapPtr & _forwardHeap, HeapPtr & _backwardHeap, const bool & forwardDirection, NodeID *middle, int *_upperbound, const int edgeBasedOffset) const { const NodeID node = _forwardHeap->DeleteMin(); const int distance = _forwardHeap->GetKey(node); // INFO((forwardDirection ? "[forw]" : "[back]") << " settled node " << node << " at distance " << distance); @@ -176,7 +176,7 @@ private: } } - if(distance-negativeOffset > *_upperbound){ + if(distance-edgeBasedOffset > *_upperbound){ _forwardHeap->DeleteAll(); return; } @@ -217,7 +217,7 @@ private: } //Found a shorter Path -> Update distance else if ( toDistance < _forwardHeap->GetKey( to ) ) { -// INFO((forwardDirection ? "[forw]" : "[back]") << " decrease and scanning edge (" << node << "," << to << ") with distance " << toDistance << ", edge length: " << data.distance); +// INFO((forwardDirection ? "[forw]" : "[back]") << " decrease and scanning edge (" << node << "," << to << ") from " << _forwardHeap->GetKey(to) << "to " << toDistance << ", edge length: " << data.distance); _forwardHeap->GetData( to ).parent = node; _forwardHeap->DecreaseKey( to, toDistance ); //new parent