Subgroup: Graph

Class: QgsGraphBuilderInterface

class qgis.analysis.QgsGraphBuilderInterface(crs: QgsCoordinateReferenceSystem, ctfEnabled: bool = True, topologyTolerance: float = 0, ellipsoidID: str = '')

Bases: sip.wrapper

Default constructor

  • crs – Coordinate reference system for new graph vertex
  • ctfEnabled – enable coordinate transform from source graph CRS to CRS graph
  • topologyTolerance – sqrt distance between source point as one graph vertex
  • ellipsoidID – ellipsoid for edge measurement


Determine interface for creating a graph. Contains the settings of the graph.

QgsGraphBuilder and QgsGraphDirector both use a “builder” design pattern


addEdge Add edge to the graph
addVertex Add vertex to the graph
coordinateTransformationEnabled Returns coordinate transformation enabled
destinationCrs Returns destinaltion CRS
distanceArea Returns measurement tool
topologyTolerance Returns topology tolerance



addEdge(self, pt1id: int, pt1: QgsPointXY, pt2id: int, pt2: QgsPointXY, strategies: Iterable[Any])

Add edge to the graph

  • pt1id – first vertex identificator
  • pt1 – first vertex coordinates
  • pt2id – second vertex identificator
  • pt2 – second vertex coordinates
  • strategies – optimization strategies


pt1id, pt1 and pt2id, pt2 is a redundant interface. You can use vertex coordinates or their identificators.

addVertex(self, id: int, pt: QgsPointXY)

Add vertex to the graph

  • id – vertex identifier
  • pt – vertex coordinates


id and pt are redundant. You can use pt or id to identify the vertex

coordinateTransformationEnabled(self) → bool

Returns coordinate transformation enabled

destinationCrs(self) → QgsCoordinateReferenceSystem

Returns destinaltion CRS

distanceArea(self) → QgsDistanceArea

Returns measurement tool

topologyTolerance(self) → float

Returns topology tolerance