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