Skip to content

Commit

Permalink
fix dijkstra alogorithm return. Shortest three contain wrong edge.
Browse files Browse the repository at this point in the history
  • Loading branch information
stopa85milk committed May 30, 2011
1 parent ca3cf83 commit fc3104f
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions src/analysis/network/qgsgraphanalyzer.cpp
Expand Up @@ -43,7 +43,7 @@ void QgsGraphAnalyzer::shortestpath( const QgsGraph* source, int startPointIdx,
{
result.push_back( QPair<double, int> ( std::numeric_limits<double>::infinity() , i ) );
}
result.push_back ( QPair<double, int>( 0.0, -1 ) );
result[ startPointIdx ] = QPair<double, int> ( 0.0, -1 );

not_begin.insert( 0.0, startPointIdx );

Expand All @@ -55,9 +55,10 @@ void QgsGraphAnalyzer::shortestpath( const QgsGraph* source, int startPointIdx,
int curVertex = it.value();
not_begin.erase( it );

// edge index list
QgsGraphEdgeList l = source->vertex( curVertex ).outEdges();
QgsGraphEdgeList::iterator edgeIt;
for (edgeIt = l.begin(); edgeIt != l.end(); ++edgeIt)
for ( edgeIt = l.begin(); edgeIt != l.end(); ++edgeIt )
{
const QgsGraphEdge& edge = source->edge( *edgeIt );
double cost = edge.property( criterionNum ).toDouble() + curCost;
Expand All @@ -69,7 +70,7 @@ void QgsGraphAnalyzer::shortestpath( const QgsGraph* source, int startPointIdx,
}
}
}

// fill shortestpath tree
if ( treeResult != NULL )
{
Expand Down

0 comments on commit fc3104f

Please sign in to comment.