QGIS API Documentation
3.14.0-Pi (9f7028fd23)
|
Go to the documentation of this file.
26 return mGraphVertices.size() - 1;
29 int QgsGraph::addEdge(
int fromVertexIdx,
int toVertexIdx,
const QVector< QVariant > &strategies )
33 e.mStrategies = strategies;
34 e.mToIdx = toVertexIdx;
35 e.mFromIdx = fromVertexIdx;
36 mGraphEdges.push_back( e );
37 int edgeIdx = mGraphEdges.size() - 1;
39 mGraphVertices[ toVertexIdx ].mIncomingEdges.push_back( edgeIdx );
40 mGraphVertices[ fromVertexIdx ].mOutgoingEdges.push_back( edgeIdx );
42 return mGraphEdges.size() - 1;
47 return mGraphVertices[ idx ];
52 return mGraphEdges[ idx ];
57 return mGraphVertices.size();
62 return mGraphEdges.size();
68 for ( i = 0; i < mGraphVertices.size(); ++i )
70 if ( mGraphVertices[ i ].point() == pt )
80 return mStrategies[ i ];
99 : mCoordinate( point )
106 return mIncomingEdges;
111 return mOutgoingEdges;
QgsGraphEdgeIds outgoingEdges() const
Returns outgoing edge ids, i.e.
QgsPointXY point() const
Returns point associated with graph vertex.
This class implements a graph edge.
This class implements a graph vertex.
int addVertex(const QgsPointXY &pt)
Add a vertex to the graph.
QVector< QVariant > strategies() const
Returns array of available strategies.
int edgeCount() const
Returns number of graph edges.
int fromVertex() const
Returns the index of the vertex at the start of this edge.
const QgsGraphVertex & vertex(int idx) const
Returns vertex at given index.
QList< int > QgsGraphEdgeIds
const QgsGraphEdge & edge(int idx) const
Returns edge at given index.
QVariant cost(int strategyIndex) const
Returns edge cost calculated using specified strategy.
int toVertex() const
Returns the index of the vertex at the end of this edge.
int findVertex(const QgsPointXY &pt) const
Find vertex by associated point.
int vertexCount() const
Returns number of graph vertices.
int addEdge(int fromVertexIdx, int toVertexIdx, const QVector< QVariant > &strategies)
Add an edge to the graph, going from the fromVertexIdx to toVertexIdx.
QgsGraphEdgeIds incomingEdges() const
Returns the incoming edge ids, i.e.
QgsGraphVertex()=default
Default constructor.