2011-06-02 13:49:43 +06:00
|
|
|
/**
|
2016-11-16 16:48:41 +02:00
|
|
|
* \ingroup analysis
|
2016-11-17 17:30:10 +02:00
|
|
|
* \class QgsGraphEdge
|
2016-11-16 13:27:57 +02:00
|
|
|
* \brief This class implements a graph edge
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
2016-11-17 17:30:10 +02:00
|
|
|
class QgsGraphEdge
|
2011-06-02 13:49:43 +06:00
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsgraph.h>
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-06-02 13:49:43 +06:00
|
|
|
public:
|
2016-11-17 17:30:10 +02:00
|
|
|
QgsGraphEdge();
|
2011-06-02 13:49:43 +06:00
|
|
|
|
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Returns edge cost calculated using specified strategy
|
|
|
|
* @param strategyIndex strategy index
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
2016-11-17 17:30:10 +02:00
|
|
|
QVariant cost( int strategyIndex ) const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-06-02 13:49:43 +06:00
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Returns array of available strategies
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
2016-11-17 17:30:10 +02:00
|
|
|
QVector< QVariant > strategies() const;
|
2011-06-02 13:49:43 +06:00
|
|
|
|
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Returns index of the outgoing vertex
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
2011-09-27 18:50:40 +06:00
|
|
|
int outVertex() const;
|
2011-06-02 13:49:43 +06:00
|
|
|
|
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Returns index of the incoming vertex
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
2011-09-27 18:50:40 +06:00
|
|
|
int inVertex() const;
|
2011-06-02 13:49:43 +06:00
|
|
|
};
|
|
|
|
|
|
|
|
|
2016-11-17 17:30:10 +02:00
|
|
|
typedef QList< int > QgsGraphEdgeIds;
|
2011-06-02 13:49:43 +06:00
|
|
|
|
|
|
|
/**
|
2016-11-16 16:48:41 +02:00
|
|
|
* \ingroup analysis
|
2011-06-02 13:49:43 +06:00
|
|
|
* \class QgsGraphVertex
|
2016-11-16 13:27:57 +02:00
|
|
|
* \brief This class implements a graph vertex
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
|
|
|
class QgsGraphVertex
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsgraph.h>
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-06-02 13:49:43 +06:00
|
|
|
public:
|
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Default constructor. It is needed for Qt's container, e.g. QVector
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
|
|
|
QgsGraphVertex();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* This constructor initializes QgsGraphVertex object and associates a vertex with a point
|
|
|
|
*/
|
|
|
|
|
|
|
|
QgsGraphVertex( const QgsPoint& point );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-06-02 13:49:43 +06:00
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Returns outgoing edges ids
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
2016-11-17 17:30:10 +02:00
|
|
|
QgsGraphEdgeIds outEdges() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-06-02 13:49:43 +06:00
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Return incoming edges ids
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
2016-11-17 17:30:10 +02:00
|
|
|
QgsGraphEdgeIds inEdges() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-06-02 13:49:43 +06:00
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Returns point associated with graph vertex
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
2012-09-24 02:28:15 +02:00
|
|
|
QgsPoint point() const;
|
2011-06-02 13:49:43 +06:00
|
|
|
};
|
|
|
|
|
|
|
|
/**
|
2016-11-16 16:48:41 +02:00
|
|
|
* \ingroup analysis
|
2011-06-02 13:49:43 +06:00
|
|
|
* \class QgsGraph
|
2016-11-21 16:44:44 +02:00
|
|
|
* \brief Mathematical graph representation
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
|
|
|
|
|
|
|
class QgsGraph
|
|
|
|
{
|
|
|
|
%TypeHeaderCode
|
|
|
|
#include <qgsgraph.h>
|
|
|
|
%End
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-06-02 13:49:43 +06:00
|
|
|
public:
|
|
|
|
QgsGraph();
|
|
|
|
|
2016-11-17 17:30:10 +02:00
|
|
|
// Graph constructing methods
|
|
|
|
|
2011-06-02 13:49:43 +06:00
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Add a vertex to the graph
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
|
|
|
int addVertex( const QgsPoint& pt );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-06-02 13:49:43 +06:00
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Add an edge to the graph
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
2016-11-17 17:30:10 +02:00
|
|
|
int addEdge( int outVertexIdx, int inVertexIdx, const QVector< QVariant >& strategies );
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-06-02 13:49:43 +06:00
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Returns number of graph vertices
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
|
|
|
int vertexCount() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
2011-06-02 13:49:43 +06:00
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Returns vertex at given index
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
|
|
|
const QgsGraphVertex& vertex( int idx ) const;
|
|
|
|
|
2012-09-24 02:28:15 +02:00
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Returns number of graph edges
|
2012-09-24 02:28:15 +02:00
|
|
|
*/
|
2016-11-17 17:30:10 +02:00
|
|
|
int edgeCount() const;
|
2012-09-24 02:28:15 +02:00
|
|
|
|
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Returns edge at given index
|
2011-06-02 13:49:43 +06:00
|
|
|
*/
|
2016-11-17 17:30:10 +02:00
|
|
|
const QgsGraphEdge& edge( int idx ) const;
|
2011-06-02 13:49:43 +06:00
|
|
|
|
|
|
|
/**
|
2016-11-17 17:30:10 +02:00
|
|
|
* Find vertex by associated point
|
2011-06-02 13:49:43 +06:00
|
|
|
* \return vertex index
|
|
|
|
*/
|
|
|
|
int findVertex( const QgsPoint& pt ) const;
|
|
|
|
};
|