QGIS API Documentation  3.10.0-A Coruña (6c816b4204)
qgsgraphanalyzer.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsgraphanalyzer.h
3  --------------------------------------
4  Date : 2011-04-14
5  Copyright : (C) 2010 by Yakushev Sergey
6  Email : YakushevS <at> list.ru
7 ****************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15 
16 #ifndef QGSGRAPHANALYZER_H
17 #define QGSGRAPHANALYZER_H
18 
19 #include <QVector>
20 
21 #include "qgis_sip.h"
22 #include "qgis_analysis.h"
23 
24 class QgsGraph;
25 
32 class ANALYSIS_EXPORT QgsGraphAnalyzer
33 {
34  public:
35 
45  static void SIP_PYALTERNATIVETYPE( SIP_PYLIST ) dijkstra( const QgsGraph *source, int startVertexIdx, int criterionNum, QVector<int> *resultTree = nullptr, QVector<double> *resultCost = nullptr );
46 
47 #ifdef SIP_RUN
48  % MethodCode
49  QVector< int > treeResult;
50  QVector< double > costResult;
51  QgsGraphAnalyzer::dijkstra( a0, a1, a2, &treeResult, &costResult );
52 
53  PyObject *l1 = PyList_New( treeResult.size() );
54  if ( l1 == NULL )
55  {
56  return NULL;
57  }
58  PyObject *l2 = PyList_New( costResult.size() );
59  if ( l2 == NULL )
60  {
61  return NULL;
62  }
63  int i;
64  for ( i = 0; i < costResult.size(); ++i )
65  {
66  PyObject *Int = PyLong_FromLong( treeResult[i] );
67  PyList_SET_ITEM( l1, i, Int );
68  PyObject *Float = PyFloat_FromDouble( costResult[i] );
69  PyList_SET_ITEM( l2, i, Float );
70  }
71 
72  sipRes = PyTuple_New( 2 );
73  PyTuple_SET_ITEM( sipRes, 0, l1 );
74  PyTuple_SET_ITEM( sipRes, 1, l2 );
75  % End
76 #endif
77 
84  static QgsGraph *shortestTree( const QgsGraph *source, int startVertexIdx, int criterionNum );
85 };
86 
87 #endif // QGSGRAPHANALYZER_H
This class performs graph analysis, e.g.
Mathematical graph representation.
Definition: qgsgraph.h:141
#define SIP_PYALTERNATIVETYPE(type)
Definition: qgis_sip.h:136
static void dijkstra(const QgsGraph *source, int startVertexIdx, int criterionNum, QVector< int > *resultTree=nullptr, QVector< double > *resultCost=nullptr)
Solve shortest path problem using Dijkstra algorithm.