Class: QgsGraphAnalyzer

This class performs graph analysis, e.g. calculates shortest path between two points using different strategies with Dijkstra algorithm

class qgis.analysis.QgsGraphAnalyzer[source]

Bases: object

static dijkstra(source: QgsGraph | None, startVertexIdx: int, criterionNum: int, resultTree: Iterable[int] | None = [], resultCost: Iterable[float] | None = []) List[source]

Solve shortest path problem using Dijkstra algorithm

Parameters:
  • source (Optional[QgsGraph]) – source graph

  • startVertexIdx (int) – index of the start vertex

  • criterionNum (int) – index of the optimization strategy

  • resultTree (Optional[Iterable[int]] = []) – array that represents shortest path tree. resultTree[ vertexIndex ] == inboundingArcIndex if vertex reachable, otherwise resultTree[ vertexIndex ] == -1. Note that the startVertexIdx will also have a value of -1 and may need special handling by callers.

  • resultCost (Optional[Iterable[float]] = []) – array of the paths costs

Return type:

List

static shortestTree(source: QgsGraph | None, startVertexIdx: int, criterionNum: int) QgsGraph | None[source]

Returns shortest path tree with root-node in startVertexIdx

Parameters:
  • source (Optional[QgsGraph]) – source graph

  • startVertexIdx (int) – index of the start vertex

  • criterionNum (int) – index of the optimization strategy

Return type:

Optional[QgsGraph]