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