QGIS API Documentation 3.40.0-Bratislava (b56115d8743)
|
Mathematical graph representation. More...
#include <qgsgraph.h>
Public Member Functions | |
QgsGraph ()=default | |
int | addEdge (int fromVertexIdx, int toVertexIdx, const QVector< QVariant > &strategies) |
Add an edge to the graph, going from the fromVertexIdx to toVertexIdx. | |
int | addVertex (const QgsPointXY &pt) |
Add a vertex to the graph. | |
const QgsGraphEdge & | edge (int idx) const |
Returns the edge at the given index. | |
int | edgeCount () const |
Returns number of graph edges. | |
int | findOppositeEdge (int index) const |
Finds the first edge which is the opposite of the edge with the specified index. | |
int | findVertex (const QgsPointXY &pt) const |
Find vertex by associated point. | |
bool | hasEdge (int index) const |
Returns whether the edge of the given index exists. | |
bool | hasVertex (int index) const |
Returns whether the vertex of the given index exists. | |
void | removeEdge (int index) |
Removes the edge at specified index. | |
void | removeVertex (int index) |
Removes the vertex at specified index. | |
const QgsGraphVertex & | vertex (int idx) const |
Returns the vertex at the given index. | |
int | vertexCount () const |
Returns number of graph vertices. | |
Protected Attributes | |
QHash< int, QgsGraphEdge > | mGraphEdges |
Graph edges. | |
QHash< int, QgsGraphVertex > | mGraphVertices |
Graph vertices. | |
Mathematical graph representation.
Definition at line 133 of file qgsgraph.h.
|
default |
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 357 of file qgsgraph.h.
|
protected |
Graph vertices.
Definition at line 354 of file qgsgraph.h.