Reference
Shortest paths
unweaver.shortest_paths.shortest_path.shortest_path(G, origin_node, destination_node, cost_function)
Find the shortest path from one on-graph node to another.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G |
DiGraphGPKGView
|
The graph to use for this shortest path search. |
required |
origin_node |
str
|
The start node ID. |
required |
destination_node |
str
|
The end node ID. |
required |
cost_function |
CostFunction
|
A dynamic cost function. |
required |
precalculated_cost_function |
A cost function that finds a precalculated weight. |
required |
Source code in unweaver/shortest_paths/shortest_path.py
138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 |
|
unweaver.shortest_paths.shortest_path.shortest_path_multi(G, nodes, cost_function)
Find the on-graph shortest path between multiple waypoints (nodes).
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G |
DiGraphGPKGView
|
The routing graph. |
required |
nodes |
List[Union[str, ProjectedNode]]
|
A list of nodes to visit, finding the shortest path between each. |
required |
cost_function |
CostFunction
|
A networkx-compatible cost function. Takes u, v, ddict as parameters and returns a single number. |
required |
Source code in unweaver/shortest_paths/shortest_path.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 |
|
unweaver.shortest_paths.shortest_path_tree.shortest_path_tree(G, start_node, cost_function, max_cost=None, precalculated_cost_function=None)
Find the shortest paths to on-graph nodes starting at a given edge/node, subject to a maximum total "distance"/cost constraint.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G |
Union[AugmentedDiGraphGPKGView, DiGraphGPKGView]
|
Network graph. |
required |
start_node |
str
|
Start node (on graph) at which to begin search. |
required |
cost_function |
CostFunction
|
NetworkX-compatible weight function. |
required |
max_cost |
Optional[float]
|
Maximum weight to reach in the tree. |
None
|
precalculated_cost_function |
Optional[CostFunction]
|
NetworkX-compatible weight function that represents precalculated weights. |
None
|
Source code in unweaver/shortest_paths/shortest_path_tree.py
31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 |
|
unweaver.shortest_paths.reachable_tree.reachable_tree(G, candidate, cost_function, max_cost, precalculated_cost_function=None)
Generate all reachable places on graph, allowing extensions beyond existing nodes (e.g., assuming cost function is distance in meters and max_cost is 400, will extend to 400 meters from origin, creating new fake nodes at the ends.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
G |
Union[AugmentedDiGraphGPKGView, DiGraphGPKGView]
|
Network graph. |
required |
candidate |
ProjectedNode
|
On-graph candidate metadata as created by waypoint_candidates. |
required |
cost_function |
CostFunction
|
NetworkX-compatible weight function. |
required |
max_cost |
float
|
Maximum weight to reach in the tree. |
required |
precalculated_cost_function |
Optional[CostFunction]
|
NetworkX-compatible weight function that represents precalculated weights. |
None
|
Source code in unweaver/shortest_paths/reachable_tree.py
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|