mirror of
				https://github.com/qgis/QGIS.git
				synced 2025-10-31 00:06:02 -04:00 
			
		
		
		
	
		
			
				
	
	
		
			85 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
			
		
		
	
	
			85 lines
		
	
	
		
			3.0 KiB
		
	
	
	
		
			Plaintext
		
	
	
	
	
	
| /************************************************************************
 | |
|  * This file has been generated automatically from                      *
 | |
|  *                                                                      *
 | |
|  * src/analysis/network/qgsgraphanalyzer.h                              *
 | |
|  *                                                                      *
 | |
|  * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | |
|  ************************************************************************/
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| 
 | |
| class QgsGraphAnalyzer
 | |
| {
 | |
| %Docstring(signature="appended")
 | |
| Performs graph analysis, e.g. calculates shortest path between two
 | |
| points using different strategies with Dijkstra's algorithm.
 | |
| %End
 | |
| 
 | |
| %TypeHeaderCode
 | |
| #include "qgsgraphanalyzer.h"
 | |
| %End
 | |
|   public:
 | |
|     static SIP_PYOBJECT dijkstra( const QgsGraph *source, int startVertexIdx, int criterionNum, QVector<int> *resultTree  = 0, QVector<double> *resultCost  = 0 ) /TypeHint="Tuple[List[int], List[float]]"/;
 | |
| %Docstring
 | |
| Solve shortest path problem using Dijkstra algorithm
 | |
| 
 | |
| :param source: source graph
 | |
| :param startVertexIdx: index of the start vertex
 | |
| :param criterionNum: index of the optimization strategy
 | |
| 
 | |
| :return: - resultTree: array that represents shortest path tree.
 | |
|            resultTree[ vertexIndex ] == inboundingArcIndex if vertex
 | |
|            reachable, otherwise resultTree[ vertexIndex ] == -1. Note
 | |
|            that the startVertexIdx will also have a value of -1 and may
 | |
|            need special handling by callers.
 | |
|          - resultCost: array of the path's costs
 | |
| %End
 | |
| %MethodCode
 | |
|     QVector<int> treeResult;
 | |
|     QVector<double> costResult;
 | |
|     QgsGraphAnalyzer::dijkstra( a0, a1, a2, &treeResult, &costResult );
 | |
| 
 | |
|     PyObject *l1 = PyList_New( treeResult.size() );
 | |
|     if ( l1 == NULL )
 | |
|     {
 | |
|       return NULL;
 | |
|     }
 | |
|     PyObject *l2 = PyList_New( costResult.size() );
 | |
|     if ( l2 == NULL )
 | |
|     {
 | |
|       return NULL;
 | |
|     }
 | |
|     int i;
 | |
|     for ( i = 0; i < costResult.size(); ++i )
 | |
|     {
 | |
|       PyObject *Int = PyLong_FromLong( treeResult[i] );
 | |
|       PyList_SET_ITEM( l1, i, Int );
 | |
|       PyObject *Float = PyFloat_FromDouble( costResult[i] );
 | |
|       PyList_SET_ITEM( l2, i, Float );
 | |
|     }
 | |
| 
 | |
|     sipRes = PyTuple_New( 2 );
 | |
|     PyTuple_SET_ITEM( sipRes, 0, l1 );
 | |
|     PyTuple_SET_ITEM( sipRes, 1, l2 );
 | |
| %End
 | |
| 
 | |
|     static QgsGraph *shortestTree( const QgsGraph *source, int startVertexIdx, int criterionNum );
 | |
| %Docstring
 | |
| Returns shortest path tree with root-node in startVertexIdx
 | |
| 
 | |
| :param source: source graph
 | |
| :param startVertexIdx: index of the start vertex
 | |
| :param criterionNum: index of the optimization strategy
 | |
| %End
 | |
| };
 | |
| 
 | |
| /************************************************************************
 | |
|  * This file has been generated automatically from                      *
 | |
|  *                                                                      *
 | |
|  * src/analysis/network/qgsgraphanalyzer.h                              *
 | |
|  *                                                                      *
 | |
|  * Do not edit manually ! Edit header and run scripts/sipify.py again   *
 | |
|  ************************************************************************/
 |