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