scgraph 3.2.0__tar.gz → 3.2.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {scgraph-3.2.0 → scgraph-3.2.1}/PKG-INFO +1 -1
- {scgraph-3.2.0 → scgraph-3.2.1}/pyproject.toml +1 -1
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/cpp/src/graph.cpp +1 -1
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/cpp/src/transit_node_routing.cpp +20 -7
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/transit_node_routing.py +15 -11
- {scgraph-3.2.0 → scgraph-3.2.1}/CMakeLists.txt +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/LICENSE +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/README.md +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/build/cp314-cp314-linux_x86_64/CMakeFiles/CheckCXX/CMakeLists.txt +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/__init__.py +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/contraction_hierarchies.py +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/cpp/bindings/graph_bindings.cpp +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/cpp/src/bmssp.hpp +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/cpp/src/contraction_hierarchies.cpp +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/cpp/src/contraction_hierarchies.hpp +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/cpp/src/graph.hpp +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/cpp/src/graph_utils.cpp +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/cpp/src/graph_utils.hpp +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/cpp/src/transit_node_routing.hpp +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/geograph.py +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/graph.py +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/graph_utils.py +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/grid.py +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/helpers/__init__.py +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/helpers/geojson.py +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/helpers/visvalingam.py +0 -0
- {scgraph-3.2.0 → scgraph-3.2.1}/scgraph/utils.py +0 -0
|
@@ -464,7 +464,7 @@ void Graph::set_tnr_graph(std::shared_ptr<TNRGraph> tnr_graph) {
|
|
|
464
464
|
|
|
465
465
|
GraphResult Graph::tnr(int origin_id, int destination_id, bool length_only) {
|
|
466
466
|
if (__tnr_graph__ == nullptr) {
|
|
467
|
-
|
|
467
|
+
create_tnr_hierarchy();
|
|
468
468
|
}
|
|
469
469
|
return __tnr_graph__->search(origin_id, destination_id, length_only);
|
|
470
470
|
}
|
|
@@ -66,16 +66,29 @@ TNRGraph::TNRGraph(const std::vector<std::unordered_map<int, double>>& graph,
|
|
|
66
66
|
backward_access_nodes[i] = compute_access_nodes(i, false);
|
|
67
67
|
}
|
|
68
68
|
|
|
69
|
-
// 3. Compute Distance Table
|
|
69
|
+
// 3. Compute Distance Table using full Dijkstra on original_graph (one tree per transit origin)
|
|
70
|
+
size_t n = original_graph.size();
|
|
70
71
|
for (int origin : transit_nodes) {
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
72
|
+
std::vector<double> dist(n, std::numeric_limits<double>::infinity());
|
|
73
|
+
dist[origin] = 0.0;
|
|
74
|
+
using PQItem = std::pair<double, int>;
|
|
75
|
+
std::priority_queue<PQItem, std::vector<PQItem>, std::greater<PQItem>> pq;
|
|
76
|
+
pq.push({0.0, origin});
|
|
77
|
+
while (!pq.empty()) {
|
|
78
|
+
auto [d, u] = pq.top();
|
|
79
|
+
pq.pop();
|
|
80
|
+
if (d > dist[u]) continue;
|
|
81
|
+
for (const auto& [v, w] : original_graph[u]) {
|
|
82
|
+
double nd = d + w;
|
|
83
|
+
if (nd < dist[v]) {
|
|
84
|
+
dist[v] = nd;
|
|
85
|
+
pq.push({nd, v});
|
|
86
|
+
}
|
|
77
87
|
}
|
|
78
88
|
}
|
|
89
|
+
for (int target : transit_nodes) {
|
|
90
|
+
distance_table[{origin, target}] = dist[target];
|
|
91
|
+
}
|
|
79
92
|
}
|
|
80
93
|
}
|
|
81
94
|
|
|
@@ -139,22 +139,26 @@ class TNRGraphPreprocessing:
|
|
|
139
139
|
for i in range(self.nodes_count)
|
|
140
140
|
]
|
|
141
141
|
|
|
142
|
-
# 3. Compute Distance Table
|
|
142
|
+
# 3. Compute Distance Table using full Dijkstra on original_graph (one tree per transit origin)
|
|
143
143
|
self.distance_table = {}
|
|
144
144
|
t_nodes_list = list(self.transit_nodes)
|
|
145
|
+
n = len(self.original_graph)
|
|
145
146
|
|
|
146
|
-
# Note: This is O(T^2) which is slow for Python.
|
|
147
|
-
# For a production implementation, we'd use many-to-one Dijkstra.
|
|
148
147
|
for origin in t_nodes_list:
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
148
|
+
dist = [float("inf")] * n
|
|
149
|
+
dist[origin] = 0
|
|
150
|
+
open_leaves = [(0, origin)]
|
|
151
|
+
while open_leaves:
|
|
152
|
+
d, u = heappop(open_leaves)
|
|
153
|
+
if d > dist[u]:
|
|
154
154
|
continue
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
155
|
+
for v, w in self.original_graph[u].items():
|
|
156
|
+
nd = d + w
|
|
157
|
+
if nd < dist[v]:
|
|
158
|
+
dist[v] = nd
|
|
159
|
+
heappush(open_leaves, (nd, v))
|
|
160
|
+
for target in t_nodes_list:
|
|
161
|
+
self.distance_table[(origin, target)] = dist[target]
|
|
158
162
|
|
|
159
163
|
|
|
160
164
|
class TNRGraphAlgorithms:
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
{scgraph-3.2.0 → scgraph-3.2.1}/build/cp314-cp314-linux_x86_64/CMakeFiles/CheckCXX/CMakeLists.txt
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|