Class: QgsGraphAnalyzer

Performs graph analysis, e.g. calculates shortest path between two points using different strategies with Dijkstra’s algorithm.

List of all members, including inherited members

Static Methods

dijkstra

Solve shortest path problem using Dijkstra algorithm

shortestTree

Returns shortest path tree with root-node in startVertexIdx

class qgis.analysis.QgsGraphAnalyzer[source]

Bases: object

static dijkstra(source: QgsGraph | None, startVertexIdx: int, criterionNum: int, resultTree: Iterable[int] | None = [], resultCost: Iterable[float] | None = []) tuple[list[int], list[float]][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]] = [])

  • resultCost (Optional[Iterable[float]] = [])

Return type:

tuple[list[int], list[float]]

Returns:

a tuple of (resultTree, resultCost) where resultTree is a list of vertex indices representing the shortest path tree and resultCost is a list of path costs

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]