Python bindings. Part 3

This commit is contained in:
Sergey Yakushevs 2011-06-03 15:21:02 +06:00
parent 032937ff7d
commit 38aa771b7e
4 changed files with 47 additions and 2 deletions

View File

@ -10,3 +10,4 @@
%Include qgsgraphbuilder.sip
%Include qgsgraphdirector.sip
%Include qgslinevectorlayerdirector.sip
%Include qgsgraphanalyzer.sip

View File

@ -0,0 +1,27 @@
class QgsGraphAnalyzer
{
%TypeHeaderCode
#include <qgsgraphanalyzer.h>
%End
public:
/**
* solve shortest path problem using dijkstra algorithm
* @param source The source graph
* @param startVertexIdx index of start vertex
* @param criterionNum index of edge property as optimization criterion
* @param destPointCost array of vertex indexes. Function calculating shortest path costs for vertices with these indexes
* @param cost array of cost paths
* @param treeResult return shortest path tree
*/
// static void shortestpath( const QgsGraph* source, int startVertexIdx, int criterionNum, const QVector<int>& destPointCost, QVector<double>& cost, QgsGraph* treeResult );
/**
* return shortest path tree with root-node in startVertexIdx
* @param source The source graph
* @param startVertexIdx index of start vertex
* @param criterionNum index of edge property as optimization criterion
*/
static QgsGraph* shortestTree( const QgsGraph* source, int startVertexIdx, int criterionNum );
};

View File

@ -102,3 +102,13 @@ void QgsGraphAnalyzer::shortestpath( const QgsGraph* source, int startPointIdx,
cost[i] = result[ destPointCost[i] ].first;
}
}
QgsGraph* QgsGraphAnalyzer::shortestTree( const QgsGraph* source, int startVertexIdx, int criterionNum)
{
QgsGraph *g = new QgsGraph;
QVector<int> v;
QVector<double> vv;
QgsGraphAnalyzer::shortestpath( source, startVertexIdx, criterionNum, v, vv, g );
return g;
}

View File

@ -28,7 +28,7 @@ class QgsGraph;
* The QGis class provides graph analysis functions
*/
class QgsGraphAnalyzer
class ANALYSIS_EXPORT QgsGraphAnalyzer
{
public:
/**
@ -41,6 +41,13 @@ class QgsGraphAnalyzer
* @param treeResult return shortest path tree
*/
static void shortestpath( const QgsGraph* source, int startVertexIdx, int criterionNum, const QVector<int>& destPointCost, QVector<double>& cost, QgsGraph* treeResult );
/**
* return shortest path tree with root-node in startVertexIdx
* @param source The source graph
* @param startVertexIdx index of start vertex
* @param criterionNum index of edge property as optimization criterion
*/
static QgsGraph* shortestTree( const QgsGraph* source, int startVertexIdx, int criterionNum );
};
#endif //QGSGRAPHANALYZERH