Skip to content

Commit

Permalink
Python bindings. Part 3
Browse files Browse the repository at this point in the history
  • Loading branch information
stopa85milk committed Jun 3, 2011
1 parent 032937f commit 38aa771
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 2 deletions.
1 change: 1 addition & 0 deletions python/analysis/network/networkanalysis.sip
Expand Up @@ -10,3 +10,4 @@
%Include qgsgraphbuilder.sip
%Include qgsgraphdirector.sip
%Include qgslinevectorlayerdirector.sip
%Include qgsgraphanalyzer.sip
27 changes: 27 additions & 0 deletions python/analysis/network/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 );
};

10 changes: 10 additions & 0 deletions src/analysis/network/qgsgraphanalyzer.cpp
Expand Up @@ -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;
}
11 changes: 9 additions & 2 deletions src/analysis/network/qgsgraphanalyzer.h
Expand Up @@ -28,7 +28,7 @@ class QgsGraph;
* The QGis class provides graph analysis functions
*/

class QgsGraphAnalyzer
class ANALYSIS_EXPORT QgsGraphAnalyzer
{
public:
/**
Expand All @@ -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.