QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
analysis
network
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 "qgis_analysis.h"
20
#include "
qgis_sip.h
"
21
22
#include <QVector>
23
24
class
QgsGraph
;
25
31
class
ANALYSIS_EXPORT
QgsGraphAnalyzer
32
{
33
public
:
43
#ifndef SIP_RUN
44
static
void
dijkstra
(
const
QgsGraph
*source,
int
startVertexIdx,
int
criterionNum, QVector<int> *resultTree =
nullptr
, QVector<double> *resultCost =
nullptr
);
45
#else
46
54
static
SIP_PYOBJECT
dijkstra
(
55
const
QgsGraph
*source,
int
startVertexIdx,
int
criterionNum, QVector<int> *resultTree
SIP_DOCSTRING_OUT
=
nullptr
, QVector<double> *resultCost
SIP_DOCSTRING_OUT
=
nullptr
56
)
SIP_TYPEHINT
( Tuple[List[
int
], List[
float
]] );
57
//%MethodCode
58
QVector<int> treeResult;
59
QVector<double> costResult;
60
QgsGraphAnalyzer::dijkstra
( a0, a1, a2, &treeResult, &costResult );
61
62
PyObject *l1 = PyList_New( treeResult.size() );
63
if
( l1 == NULL )
64
{
65
return
NULL;
66
}
67
PyObject *l2 = PyList_New( costResult.size() );
68
if
( l2 == NULL )
69
{
70
return
NULL;
71
}
72
int
i;
73
for
( i = 0; i < costResult.size(); ++i )
74
{
75
PyObject *Int = PyLong_FromLong( treeResult[i] );
76
PyList_SET_ITEM( l1, i, Int );
77
PyObject *Float = PyFloat_FromDouble( costResult[i] );
78
PyList_SET_ITEM( l2, i, Float );
79
}
80
81
sipRes = PyTuple_New( 2 );
82
PyTuple_SET_ITEM( sipRes, 0, l1 );
83
PyTuple_SET_ITEM( sipRes, 1, l2 );
84
//%End
85
#endif
86
93
static
QgsGraph
*
shortestTree
(
const
QgsGraph
*source,
int
startVertexIdx,
int
criterionNum );
94
};
95
96
#endif
// QGSGRAPHANALYZER_H
QgsGraphAnalyzer
Performs graph analysis, e.g.
Definition
qgsgraphanalyzer.h:32
QgsGraphAnalyzer::dijkstra
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.
Definition
qgsgraphanalyzer.cpp:26
QgsGraphAnalyzer::shortestTree
static QgsGraph * shortestTree(const QgsGraph *source, int startVertexIdx, int criterionNum)
Returns shortest path tree with root-node in startVertexIdx.
Definition
qgsgraphanalyzer.cpp:92
QgsGraph
Mathematical graph representation.
Definition
qgsgraph.h:131
qgis_sip.h
SIP_TYPEHINT
#define SIP_TYPEHINT(type)
Definition
qgis_sip.h:242
SIP_DOCSTRING_OUT
#define SIP_DOCSTRING_OUT
Definition
qgis_sip.h:65
Generated on
for QGIS API Documentation by
1.17.0