QGIS API Documentation  2.99.0-Master (b698612)
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.h>
22 #include "qgis_analysis.h"
23 
24 class QgsGraph;
25 
31 class ANALYSIS_EXPORT QgsGraphAnalyzer
32 {
33  public:
34 
43  static void SIP_PYALTERNATIVETYPE( SIP_PYLIST ) dijkstra( const QgsGraph *source, int startVertexIdx, int criterionNum, QVector<int> *resultTree = nullptr, QVector<double> *resultCost = nullptr );
44 
45 #ifdef SIP_RUN
46  % MethodCode
47  QVector< int > treeResult;
48  QVector< double > costResult;
49  QgsGraphAnalyzer::dijkstra( a0, a1, a2, &treeResult, &costResult );
50 
51  PyObject *l1 = PyList_New( treeResult.size() );
52  if ( l1 == NULL )
53  {
54  return NULL;
55  }
56  PyObject *l2 = PyList_New( costResult.size() );
57  if ( l2 == NULL )
58  {
59  return NULL;
60  }
61  int i;
62  for ( i = 0; i < costResult.size(); ++i )
63  {
64  PyObject *Int = PyLong_FromLong( treeResult[i] );
65  PyList_SET_ITEM( l1, i, Int );
66  PyObject *Float = PyFloat_FromDouble( costResult[i] );
67  PyList_SET_ITEM( l2, i, Float );
68  }
69 
70  sipRes = PyTuple_New( 2 );
71  PyTuple_SET_ITEM( sipRes, 0, l1 );
72  PyTuple_SET_ITEM( sipRes, 1, l2 );
73  % End
74 #endif
75 
82  static QgsGraph *shortestTree( const QgsGraph *source, int startVertexIdx, int criterionNum );
83 };
84 
85 #endif // QGSGRAPHANALYZER_H
This class performs graph analysis, e.g.
Mathematical graph representation.
Definition: qgsgraph.h:131
#define SIP_PYALTERNATIVETYPE(type)
Definition: qgis_sip.h:117
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.