10/13/2023 0 Comments Directed graph builder![]() ![]() Single available path and it is optimal (shortest) on this graph If vertex B is reachable from vertex A, then the path from A to B is the Only one vertex has no incoming edges - the root of the treeĪll other vertexes have only one incoming edge The shortest path tree is a directed weighted graph (or more precisely a tree) The results can be represented as a shortest path tree. Graph to all the others and the values of the optimization parameters. Network analysis library provides Dijkstra’s algorithm.ĭijkstra’s algorithm finds the shortest route from one of the vertexes of the #Directed graph builder how to#Networks analysis is used to find answers to two questions: which vertexesĪre connected and how to find a shortest path. It is necessary then to create a strategy for calculating edge properties QgsVectorLayerDirector.DirectionBoth - Two-way QgsVectorLayerDirector.DirectionBackward - One-way reverse QgsVectorLayerDirector.DirectionForward - One-way direct Those roads where field directionFieldId is not set or has some valueĭifferent from any of the three values specified above. A string.ĭefaultDirection - default road direction. Roads we can move from first point to last and from last to first). A string.īothDirectionValue - field value for bidirectional roads (for such (moving from last line point to first one). ReverseDirectionValue - field value for roads with reverse direction (moving from first line point to last one). If -1, then don’t use thisĭirectDirectionValue - field value for roads with direct direction Information about roads direction is stored. VectorLayer - vector layer used to build the graphĭirectionFieldId - index of the attribute table field, where #Directed graph builder full#Using edge length and speed value from attributes.įirst of all, to use this library we should import the analysis moduleġ director = QgsVectorLayerDirector ( vectorLayer, 2 directionFieldId, 3 directDirectionValue, 4 reverseDirectionValue, 5 bothDirectionValue, 6 defaultDirection )Īnd here is full list of what these parameters mean: You can implement your own strategy that will use allįor example, RoadGraph plugin uses a strategy that computes travel time QgsNetworkSpeedStrategy (that also considers Strategy (that takes into account the length of the route) and To calculate edge properties the programming pattern strategy You may want to implement your own builders that will build a graph compatible In the case with the director, only one builder exists: QgsGraphBuilder, The director sets the basic settings that will be used to construct a graphįrom a line vector layer, used by the builder to create the graph. There is only one Director for now: QgsVectorLayerDirector. A graph is constructed using a so-called Director. Vector layer attributes and length of an edge can be used as the propertiesĬonverting from a vector layer to the graph is done using the In the latter case the edge will be split and a new vertex added. Point a match will be found - the closest graph vertex or closest graph edge. Input vector layer any number of additional points. So two lines that have a common node become connected to each other.Īdditionally, during graph creation it is possible to “fix” (“tie”) to the If several nodes have the same coordinates then they are the same graph vertex. Nodes of the polylinesīecome graph vertexes, and segments of the polylines are graph edges. All further actions will use this graph,Īs a source we can use any polyline vector layer. The first thing you need to do - is to prepare input data, that is toĬonvert a vector layer into a graph. Use analysis results (for example, visualize them) General information īriefly, a typical use case can be described as:Ĭreate graph from geodata (usually polyline vector layer) RoadGraph core plugin and now you can use it’s methods in plugins orĭirectly from the Python console. The network analysis library was created by exporting basic functions from the Implement basic methods from graph theory (currently only Dijkstra’s The network analysis library can be used to:Ĭreate mathematical graph from geographical data (polyline vector layers) Tasks - doing heavy work in the background Expressions, Filtering and Calculating Values QGIS Desktop User Guide/Manual (QGIS 3.28). ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |