QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
qgsgraph.h
Go to the documentation of this file.
1 /***************************************************************************
2  graph.h
3  --------------------------------------
4  Date : 2011-04-01
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 /*
17  * This file describes the built-in QGIS classes modeling a mathematical graph.
18  * Vertex is identified by its geographic coordinates (but you can add two vertex
19  * with unique coordinate), no additional properties it can not be assigned.
20  * Count the number of properties not limited along the arc. Graph may
21  * be have incidence arcs.
22  *
23  * \file qgsgraph.h
24  */
25 
26 #ifndef QGSGRAPHH
27 #define QGSGRAPHH
28 
29 // QT4 includes
30 #include <QList>
31 #include <QVector>
32 #include <QVariant>
33 
34 // QGIS includes
35 #include "qgspoint.h"
36 
37 class QgsGraphVertex;
38 
44 class ANALYSIS_EXPORT QgsGraphArc
45 {
46  public:
47  QgsGraphArc();
48 
53  QVariant property( int propertyIndex ) const;
54 
58  QVector< QVariant > properties() const;
59 
63  int outVertex() const;
64 
68  int inVertex() const;
69 
70  private:
71 
72  QVector< QVariant > mProperties;
73 
74  int mOut;
75  int mIn;
76 
77  friend class QgsGraph;
78 };
79 
80 
82 
88 class ANALYSIS_EXPORT QgsGraphVertex
89 {
90  public:
95 
100  QgsGraphVertex( const QgsPoint& point );
101 
105  QgsGraphArcIdList outArc() const;
106 
110  QgsGraphArcIdList inArc() const;
111 
115  QgsPoint point() const;
116 
117  private:
118  QgsPoint mCoordinate;
119  QgsGraphArcIdList mOutArc;
120  QgsGraphArcIdList mInArc;
121 
122  friend class QgsGraph;
123 };
124 
131 class ANALYSIS_EXPORT QgsGraph
132 {
133  public:
134  QgsGraph();
135 
136  // begin graph constructing methods
140  int addVertex( const QgsPoint& pt );
141 
145  int addArc( int outVertexIdx, int inVertexIdx, const QVector< QVariant >& properties );
146 
150  int vertexCount() const;
151 
155  const QgsGraphVertex& vertex( int idx ) const;
156 
160  int arcCount() const;
161 
165  const QgsGraphArc& arc( int idx ) const;
166 
171  int findVertex( const QgsPoint& pt ) const;
172 
173  private:
174  QVector<QgsGraphVertex> mGraphVertexes;
175 
176  QVector<QgsGraphArc> mGraphArc;
177 };
178 
179 #endif //QGSGRAPHH
This class implement a graph edge.
Definition: qgsgraph.h:44
A class to represent a point.
Definition: qgspoint.h:117
Mathematics graph representation.
Definition: qgsgraph.h:131
This class implement a graph vertex.
Definition: qgsgraph.h:88
QgsGraphVertex()
default constructor.
Definition: qgsgraph.h:94
QList< int > QgsGraphArcIdList
Definition: qgsgraph.h:81