QGIS API Documentation 3.32.0-Lima (311a8cb8a6)
|
Mathematical graph representation. More...
#include <qgsgraph.h>
Public Member Functions | |
QgsGraph ()=default | |
Constructor for QgsGraph. More... | |
int | addEdge (int fromVertexIdx, int toVertexIdx, const QVector< QVariant > &strategies) |
Add an edge to the graph, going from the fromVertexIdx to toVertexIdx. More... | |
int | addVertex (const QgsPointXY &pt) |
Add a vertex to the graph. More... | |
const QgsGraphEdge & | edge (int idx) const |
Returns the edge at the given index. More... | |
int | edgeCount () const |
Returns number of graph edges. More... | |
int | findOppositeEdge (int index) const |
Finds the first edge which is the opposite of the edge with the specified index. More... | |
int | findVertex (const QgsPointXY &pt) const |
Find vertex by associated point. More... | |
bool | hasEdge (int index) const |
Returns whether the edge of the given index exists. More... | |
bool | hasVertex (int index) const |
Returns whether the vertex of the given index exists. More... | |
void | removeEdge (int index) |
Removes the edge at specified index. More... | |
void | removeVertex (int index) |
Removes the vertex at specified index. More... | |
const QgsGraphVertex & | vertex (int idx) const |
Returns the vertex at the given index. More... | |
int | vertexCount () const |
Returns number of graph vertices. More... | |
Protected Attributes | |
QHash< int, QgsGraphEdge > | mGraphEdges |
Graph edges. More... | |
QHash< int, QgsGraphVertex > | mGraphVertices |
Graph vertices. More... | |
|
default |
Constructor for QgsGraph.
int QgsGraph::addEdge | ( | int | fromVertexIdx, |
int | toVertexIdx, | ||
const QVector< QVariant > & | strategies | ||
) |
Add an edge to the graph, going from the fromVertexIdx to toVertexIdx.
Definition at line 30 of file qgsgraph.cpp.
int QgsGraph::addVertex | ( | const QgsPointXY & | pt | ) |
Add a vertex to the graph.
Definition at line 24 of file qgsgraph.cpp.
const QgsGraphEdge & QgsGraph::edge | ( | int | idx | ) | const |
Returns the edge at the given index.
Definition at line 76 of file qgsgraph.cpp.
int QgsGraph::edgeCount | ( | ) | const |
Returns number of graph edges.
Definition at line 120 of file qgsgraph.cpp.
int QgsGraph::findOppositeEdge | ( | int | index | ) | const |
Finds the first edge which is the opposite of the edge with the specified index.
This represents the edge which has the same vertices as the specified edge, but the opposite direction in the graph.(I.e. the edge which starts at the "from" vertex of the specified edge and ends at the "to" vertex.)
Returns -1 if no opposite edge exists.
Definition at line 150 of file qgsgraph.cpp.
int QgsGraph::findVertex | ( | const QgsPointXY & | pt | ) | const |
bool QgsGraph::hasEdge | ( | int | index | ) | const |
Returns whether the edge of the given index exists.
Definition at line 144 of file qgsgraph.cpp.
bool QgsGraph::hasVertex | ( | int | index | ) | const |
Returns whether the vertex of the given index exists.
Definition at line 138 of file qgsgraph.cpp.
void QgsGraph::removeEdge | ( | int | index | ) |
Removes the edge at specified index.
The incoming and outgoing edges for all graph vertices will be updated accordingly. Vertices which no longer have any incoming or outgoing edges as a result will be removed from the graph automatically.
Definition at line 87 of file qgsgraph.cpp.
void QgsGraph::removeVertex | ( | int | index | ) |
Removes the vertex at specified index.
All edges which are incoming or outgoing edges for the vertex will also be removed.
Definition at line 58 of file qgsgraph.cpp.
const QgsGraphVertex & QgsGraph::vertex | ( | int | idx | ) | const |
Returns the vertex at the given index.
Definition at line 47 of file qgsgraph.cpp.
int QgsGraph::vertexCount | ( | ) | const |
Returns number of graph vertices.
Definition at line 115 of file qgsgraph.cpp.
|
protected |
Graph edges.
Definition at line 369 of file qgsgraph.h.
|
protected |
Graph vertices.
Definition at line 366 of file qgsgraph.h.