Skip to content
Permalink
Browse files

Python bindings. Part 3

  • Loading branch information
Sergey Yakushevs
Sergey Yakushevs committed Jun 3, 2011
1 parent 032937f commit 38aa771b7e810b859c4c7703aae92147f6d3ec6b
@@ -10,3 +10,4 @@
%Include qgsgraphbuilder.sip
%Include qgsgraphdirector.sip
%Include qgslinevectorlayerdirector.sip
%Include qgsgraphanalyzer.sip
@@ -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 );
};

@@ -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;
}
@@ -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

0 comments on commit 38aa771

Please sign in to comment.
You can’t perform that action at this time.