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;
QVector< QVariant > strategies() const
Returns array of available strategies.
QVariant cost(int strategyIndex) const
Returns edge cost calculated using specified strategy.
A class to represent a 2D point.
QgsGraphEdgeIds outgoingEdges() const
Returns outgoing edge ids, i.e.
QgsPointXY point() const
Returns point associated with graph vertex.
int findVertex(const QgsPointXY &pt) const
Find vertex by associated point.
const QgsGraphEdge & edge(int idx) const
Returns edge at given index.
int toVertex() const
Returns the index of the vertex at the end of this edge.
int fromVertex() const
Returns the index of the vertex at the start of this edge.
This class implements a graph vertex.
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.
int edgeCount() const
Returns number of graph edges.
int addVertex(const QgsPointXY &pt)
Add a vertex to the graph.
QList< int > QgsGraphEdgeIds
const QgsGraphVertex & vertex(int idx) const
Returns vertex at given index.
int vertexCount() const
Returns number of graph vertices.
This class implements a graph edge.
QgsGraphVertex()=default
Default constructor.