@@ -171,25 +171,27 @@ remove_turn_restrictions <- function (graph, res) {
171171 graph_in <- graph_in [which (graph_in $ .vx1 %in% graph_out_compound $ .vx0 ), ]
172172
173173 index <- match (graph_out_compound $ .vx0 , graph_in $ .vx1 )
174- graph_out_compound $ .vx0 <- graph_in $ .vx0 [index ]
175- graph_out_compound $ object_ <-
176- paste0 (graph_in $ object_ [index ], " _" , graph_out_compound $ object_ )
177- graph_out_compound $ d <- graph_in $ d [index ] + graph_out_compound $ d
178- graph_out_compound $ d_weighted <-
179- graph_in $ d_weighted [index ] + graph_out_compound $ d_weighted
180- graph_out_compound $ time <- graph_in $ time [index ] + graph_out_compound $ time
181- graph_out_compound $ time_weighted <-
182- graph_in $ time_weighted [index ] + graph_out_compound $ time_weighted
183-
184- # Extend edge map:
185- res $ edge_map <- rbind (
186- res $ edge_map ,
187- data.frame (
188- edge = paste0 (" j_" , rcpp_gen_hash (length (index ), 10 )),
189- e_in = graph_in $ edge_ [index ],
190- e_out = graph_out_compound $ edge_
174+ if (length (index ) > 0L ) {
175+ graph_out_compound $ .vx0 <- graph_in $ .vx0 [index ]
176+ graph_out_compound $ object_ <-
177+ paste0 (graph_in $ object_ [index ], " _" , graph_out_compound $ object_ )
178+ graph_out_compound $ d <- graph_in $ d [index ] + graph_out_compound $ d
179+ graph_out_compound $ d_weighted <-
180+ graph_in $ d_weighted [index ] + graph_out_compound $ d_weighted
181+ graph_out_compound $ time <- graph_in $ time [index ] + graph_out_compound $ time
182+ graph_out_compound $ time_weighted <-
183+ graph_in $ time_weighted [index ] + graph_out_compound $ time_weighted
184+
185+ # Extend edge map:
186+ res $ edge_map <- rbind (
187+ res $ edge_map ,
188+ data.frame (
189+ edge = paste0 (" j_" , rcpp_gen_hash (length (index ), 10 )),
190+ e_in = graph_in $ edge_ [index ],
191+ e_out = graph_out_compound $ edge_
192+ )
191193 )
192- )
194+ }
193195
194196 # Remove original edges from graph, and add new compound ones:
195197 res $ graph <- rbind (
0 commit comments