Hi Team, I have been trying to get the shortest path for a lot of pairs of start and end points for a given road layer. Although I'm able to achieve this by creating the *QgsVectorLayerDirector *and Graph object for every pair of start and end points.
However, I could not reuse the graph object or director object for all the pairs of start and end points, eventually the code is as slow as executing the* 'native:shortestpathpointtopoint'* processing tool programmatically for each pair of start and end points. Essentially, I'm trying to improve the performance by reusing the graph objects. Can someone help me whether there is a possibility to reuse the graph object for large sets of pairs? Here is the code snippet I have used. vectorLayer = QgsVectorLayer('testdata/network.gpkg|layername=network_lines', 'lines')director = QgsVectorLayerDirector(vectorLayer, -1, '', '', '', QgsVectorLayerDirector.DirectionBoth)strategy = QgsNetworkDistanceStrategy()director.addStrategy(strategy)builder = QgsGraphBuilder(vectorLayer.sourceCrs())startPoint = QgsPointXY(1179661.925139,5419188.074362)endPoint = QgsPointXY(1180942.970617,5420040.097560)tiedPoints = director.makeGraph(builder, [startPoint, endPoint])tStart, tStop = tiedPointsgraph = builder.graph()idxStart = graph.findVertex(tStart)idxEnd = graph.findVertex(tStop)(tree, costs) = QgsGraphAnalyzer.dijkstra(graph, idxStart, 0) -Prem
_______________________________________________ QGIS-Developer mailing list QGIS-Developer@lists.osgeo.org List info: https://lists.osgeo.org/mailman/listinfo/qgis-developer Unsubscribe: https://lists.osgeo.org/mailman/listinfo/qgis-developer