Skip to content

Commit 429dd14

Browse files
authored
Merge pull request #313 from UrbanAnalyst/compound
fix compound junction construction when there are none #305
2 parents 54f976b + 7e9df7f commit 429dd14

File tree

3 files changed

+22
-20
lines changed

3 files changed

+22
-20
lines changed

DESCRIPTION

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Package: dodgr
22
Title: Distances on Directed Graphs
3-
Version: 0.4.3.008
3+
Version: 0.4.3.009
44
Authors@R: c(
55
person("Mark", "Padgham", , "mark.padgham@email.com", role = c("aut", "cre")),
66
person("Andreas", "Petutschnig", role = "aut"),

R/compound-junctions.R

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -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 (

codemeta.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
"codeRepository": "https://github.com/UrbanAnalyst/dodgr",
1212
"issueTracker": "https://github.com/UrbanAnalyst/dodgr/issues",
1313
"license": "https://spdx.org/licenses/GPL-3.0",
14-
"version": "0.4.3.008",
14+
"version": "0.4.3.009",
1515
"programmingLanguage": {
1616
"@type": "ComputerLanguage",
1717
"name": "R",

0 commit comments

Comments
 (0)