@@ -148,9 +148,78 @@ class Pgr_base_graph {
148
148
// ! @name Graph Modification
149
149
// @{
150
150
// ! Used for storing the removed_edges
151
- std::deque<pgr_edge_t > removed_edges;
151
+ std::deque<boost_edge_t > removed_edges;
152
+
153
+ // ! Used for storing modified edges because of adding points
154
+ // TODO
155
+ #if 0
156
+ std::deque<boost_edge_t> modified_edges;
157
+ std::deque< Point_on_edge > points;
158
+ // map to get wich boost edge was modified
159
+ std::map < int64_t, int64_t >;
160
+ #endif
152
161
// @}
153
162
163
+ #if 0
164
+ void add_point(Point_on_edge &point, int driving) {
165
+ // we have:
166
+ // point.point_id
167
+ // point.edge_id
168
+ // point.fraction
169
+ // Look for the edge in modified edges
170
+ //
171
+ // Driving: 0: doesnt matter (both), 1) right, 2) left
172
+ bool found = false;
173
+ int64_t edge_to_modify = 0;
174
+ for (const auto &edge : modified_edges) {
175
+ if (point.edge_id == edge.id) {
176
+ found = true;
177
+ break;
178
+ }
179
+ ++edge_to_modify;
180
+ }
181
+
182
+ //was not there so look for it in the graph
183
+ if (!found) {
184
+ E_i edge_ptr, edges_end;
185
+ for (boost::tie(edge_ptr, edges_end) = edges(graph);
186
+ edge_ptr != edges_end; ++edge_ptr) {
187
+ if (point.edge_id == edge_ptr->id) {
188
+ modified_edges.push_back(*edge_ptr);
189
+ boost::remove_edge(edge_ptr, graph);
190
+ //delete the edge from the graph
191
+ found = true;
192
+ break;
193
+ }
194
+ }
195
+ }
196
+
197
+ // add the point
198
+ int64_t vertex_id = -(points.size() + 1);
199
+ point.vertex_id = vertex_id;
200
+ points.push_back(point);
201
+
202
+ // add the vertex
203
+ LI vm_s;
204
+ vm_s = vertices_map.find(vertex_id);
205
+ if (vm_s == vertices_map.end()) {
206
+ vertices_map[vertex_id]= m_num_vertices;
207
+ gVertices_map[m_num_vertices++] = vertex_id;
208
+ vm_s = vertices_map.find(vertex_id);
209
+ }
210
+
211
+ if (!found) {
212
+ // the vertex remains disconnected
213
+ // because the edge was not found
214
+ return;
215
+ }
216
+
217
+ }
218
+ #endif
219
+
220
+
221
+
222
+
154
223
155
224
// ! @name The Graph
156
225
// @{
@@ -190,7 +259,7 @@ class Pgr_base_graph {
190
259
void disconnect_edge (int64_t p_from, int64_t p_to) {
191
260
V g_from;
192
261
V g_to;
193
- pgr_edge_t d_edge;
262
+ boost_edge_t d_edge;
194
263
// nothing to do, the vertex doesnt exist
195
264
if (!get_gVertex (p_from, g_from)) return ;
196
265
if (!get_gVertex (p_to, g_to)) return ;
@@ -203,7 +272,7 @@ class Pgr_base_graph {
203
272
d_edge.source = graph[source (*out, graph)].id ;
204
273
d_edge.target = graph[target (*out, graph)].id ;
205
274
d_edge.cost = graph[*out].cost ;
206
- d_edge.reverse_cost = -1 ;
275
+ // d_edge.reverse_cost = -1;
207
276
removed_edges.push_back (d_edge);
208
277
}
209
278
}
@@ -219,8 +288,8 @@ class Pgr_base_graph {
219
288
\returns 0: The out degree of a vertex that its not in the graph
220
289
221
290
@param [IN] *vertex_id* original vertex id
222
- */
223
-
291
+ */
292
+
224
293
225
294
degree_size_type out_degree (int64_t vertex_id) const {
226
295
V v_from;
@@ -234,7 +303,7 @@ class Pgr_base_graph {
234
303
return boost::out_degree (v, graph);
235
304
}
236
305
// @}
237
-
306
+
238
307
239
308
// ! \brief Disconnects the outgoing edges with a particular original id from a vertex
240
309
/* !
@@ -247,7 +316,7 @@ class Pgr_base_graph {
247
316
*/
248
317
void disconnect_out_going_edge (int64_t vertex_id, int64_t edge_id) {
249
318
V v_from;
250
- pgr_edge_t d_edge;
319
+ boost_edge_t d_edge;
251
320
252
321
// nothing to do, the vertex doesnt exist
253
322
if (!get_gVertex (vertex_id, v_from)) {
@@ -266,7 +335,7 @@ class Pgr_base_graph {
266
335
d_edge.source = graph[source (*out, graph)].id ;
267
336
d_edge.target = graph[target (*out, graph)].id ;
268
337
d_edge.cost = graph[*out].cost ;
269
- d_edge.reverse_cost = -1 ;
338
+ // d_edge.reverse_cost = -1;
270
339
removed_edges.push_back (d_edge);
271
340
boost::remove_edge ((*out), graph);
272
341
change = true ;
@@ -294,7 +363,7 @@ class Pgr_base_graph {
294
363
*/
295
364
void disconnect_vertex (int64_t p_vertex) {
296
365
V g_vertex;
297
- pgr_edge_t d_edge;
366
+ boost_edge_t d_edge;
298
367
// nothing to do, the vertex doesnt exist
299
368
if (!get_gVertex (p_vertex, g_vertex)) return ;
300
369
EO_i out, out_end;
@@ -305,7 +374,7 @@ class Pgr_base_graph {
305
374
d_edge.source = graph[source (*out, graph)].id ;
306
375
d_edge.target = graph[target (*out, graph)].id ;
307
376
d_edge.cost = graph[*out].cost ;
308
- d_edge.reverse_cost = -1 ;
377
+ // d_edge.reverse_cost = -1;
309
378
removed_edges.push_back (d_edge);
310
379
}
311
380
@@ -318,7 +387,7 @@ class Pgr_base_graph {
318
387
d_edge.source = graph[source (*in, graph)].id ;
319
388
d_edge.target = graph[target (*in, graph)].id ;
320
389
d_edge.cost = graph[*in].cost ;
321
- d_edge.reverse_cost = -1 ;
390
+ // d_edge.reverse_cost = -1;
322
391
removed_edges.push_back (d_edge);
323
392
}
324
393
}
@@ -411,6 +480,38 @@ class Pgr_base_graph {
411
480
}
412
481
413
482
private:
483
+
484
+
485
+ void
486
+ graph_add_edge (const boost_edge_t &edge ) {
487
+ bool inserted;
488
+ LI vm_s, vm_t ;
489
+ E e;
490
+
491
+ vm_s = vertices_map.find (edge.source );
492
+ if (vm_s == vertices_map.end ()) {
493
+ vertices_map[edge.source ]= m_num_vertices;
494
+ gVertices_map [m_num_vertices++] = edge.source ;
495
+ vm_s = vertices_map.find (edge.source );
496
+ }
497
+
498
+ vm_t = vertices_map.find (edge.target );
499
+ if (vm_t == vertices_map.end ()) {
500
+ vertices_map[edge.target ]= m_num_vertices;
501
+ gVertices_map [m_num_vertices++] = edge.target ;
502
+ vm_t = vertices_map.find (edge.target );
503
+ }
504
+
505
+ if (edge.cost >= 0 ) {
506
+ boost::tie (e, inserted) =
507
+ boost::add_edge (vm_s->second , vm_t ->second , graph);
508
+ graph[e].cost = edge.cost ;
509
+ graph[e].id = edge.id ;
510
+ graph[e].first = edge.first ;
511
+ }
512
+
513
+ }
514
+
414
515
void
415
516
graph_add_edge (const pgr_edge_t &edge ) {
416
517
bool inserted;
@@ -436,13 +537,15 @@ class Pgr_base_graph {
436
537
boost::add_edge (vm_s->second , vm_t ->second , graph);
437
538
graph[e].cost = edge.cost ;
438
539
graph[e].id = edge.id ;
540
+ graph[e].first = true ;
439
541
}
440
542
441
543
if (edge.reverse_cost >= 0 ) {
442
544
boost::tie (e, inserted) =
443
545
boost::add_edge (vm_t ->second , vm_s->second , graph);
444
546
graph[e].cost = edge.reverse_cost ;
445
547
graph[e].id = edge.id ;
548
+ graph[e].first = false ;
446
549
}
447
550
}
448
551
};
0 commit comments