File: qgsgraphanalyzer.sip

package info (click to toggle)
qgis 2.4.0-1
  • links: PTS, VCS
  • area: main
  • in suites: jessie, jessie-kfreebsd
  • size: 374,696 kB
  • ctags: 66,263
  • sloc: cpp: 396,139; ansic: 241,070; python: 130,609; xml: 14,884; perl: 1,290; sh: 1,287; sql: 500; yacc: 268; lex: 242; makefile: 168
file content (53 lines) | stat: -rw-r--r-- 1,780 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
class QgsGraphAnalyzer
{
%TypeHeaderCode
#include <qgsgraphanalyzer.h>
%End

  public:
    /**
     * solve shortest path problem using dijkstra algorithm
     * @param source The source graph
     * @param startVertexIdx index of start vertex
     * @param criterionNum index of arc property as optimization criterion
     * @param resultTree array represents the shortest path tree. resultTree[ vertexIndex ] == inboundingArcIndex if vertex reacheble and resultTree[ vertexIndex ] == -1 others.
     * @param resultCost array of cost paths
     */
    static SIP_PYLIST dijkstra( const QgsGraph* source, int startVertexIdx, int criterionNum );
%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 = PyInt_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

    /**
     * return shortest path tree with root-node in startVertexIdx
     * @param source The source graph
     * @param startVertexIdx index of start vertex
     * @param criterionNum index of edge property as optimization criterion
     */
    static QgsGraph* shortestTree( const QgsGraph* source, int startVertexIdx, int criterionNum );
};