Reverting change that made path unpacking impossible

This commit is contained in:
Dennis Luxen 2010-08-25 09:33:41 +00:00
parent dc889cfe80
commit b3fded0725
3 changed files with 15 additions and 8 deletions

View File

@ -16,7 +16,7 @@ You should have received a copy of the GNU Affero General Public License
along with this program; if not, write to the Free Software along with this program; if not, write to the Free Software
Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
or see http://www.gnu.org/licenses/agpl.txt. or see http://www.gnu.org/licenses/agpl.txt.
*/ */
#ifndef BINARYHEAP_H_INCLUDED #ifndef BINARYHEAP_H_INCLUDED
#define BINARYHEAP_H_INCLUDED #define BINARYHEAP_H_INCLUDED
@ -91,17 +91,17 @@ private:
template< typename NodeID, typename Key > template< typename NodeID, typename Key >
class SparseStorage { class SparseStorage {
public: public:
SparseStorage( size_t size = 0 ) { } SparseStorage( size_t size = 0 ) { }
Key &operator[]( NodeID node ) { Key &operator[]( NodeID node ) {
return nodes[node]; return nodes[node];
} }
void Clear() { void Clear() {
nodes.clear(); nodes.clear();
} }
private: private:
google::sparse_hash_map< NodeID, Key > nodes; google::sparse_hash_map< NodeID, Key > nodes;
}; };
@ -184,6 +184,13 @@ public:
return insertedNodes[removedIndex].node; return insertedNodes[removedIndex].node;
} }
void DeleteAll() {
for ( typename std::vector< HeapElement >::iterator i = heap.begin() + 1, iend = heap.end(); i != iend; ++i )
insertedNodes[i->index].key = 0;
heap.resize( 1 );
heap[0].weight = 0;
}
void DecreaseKey( NodeID node, Weight weight ) { void DecreaseKey( NodeID node, Weight weight ) {
const Key index = nodeIndex[node]; const Key index = nodeIndex[node];
Key key = insertedNodes[index].key; Key key = insertedNodes[index].key;

View File

@ -253,7 +253,7 @@ private:
} }
if ( distance > *targetDistance ) { if ( distance > *targetDistance ) {
heapForward->Clear(); heapForward->DeleteAll();
return; return;
} }
for ( int edge = _firstEdge[node], endEdges = _firstEdge[node + 1]; edge != endEdges; ++edge ) { for ( int edge = _firstEdge[node], endEdges = _firstEdge[node + 1]; edge != endEdges; ++edge ) {

View File

@ -126,7 +126,7 @@ private:
} }
} }
if ( distance > *_upperbound ) { if ( distance > *_upperbound ) {
_forwardHeap->Clear(); _forwardHeap->DeleteAll();
return; return;
} }
for ( typename GraphT::EdgeIterator edge = _graph->BeginEdges( node ); edge < _graph->EndEdges(node); edge++ ) { for ( typename GraphT::EdgeIterator edge = _graph->BeginEdges( node ); edge < _graph->EndEdges(node); edge++ ) {
@ -184,7 +184,7 @@ private:
} }
} }
assert(smallestWeight != SPECIAL_EDGEID); assert(smallestWeight != SPECIAL_EDGEID); //no edge found. This should not happen at all!
const EdgeData ed = _graph->GetEdgeData(smallestEdge); const EdgeData ed = _graph->GetEdgeData(smallestEdge);
if(ed.shortcut) if(ed.shortcut)