Skip to content

Commit adfa054

Browse files
authored
Merge pull request #314 from leoniedu/dodgt-times-pairwise
add pairwise option to dodgr_times.
2 parents 429dd14 + 9b502be commit adfa054

File tree

3 files changed

+30
-4
lines changed

3 files changed

+30
-4
lines changed

R/times.R

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ dodgr_times <- function (graph,
99
from = NULL,
1010
to = NULL,
1111
shortest = FALSE,
12+
pairwise = FALSE,
1213
heap = "BHeap") {
1314

1415
graph <- tbl_to_df (graph)
@@ -29,6 +30,6 @@ dodgr_times <- function (graph,
2930
}
3031
graph [[gr_cols$d_weighted]] <- graph [[gr_cols$time_weighted]]
3132
}
32-
33-
dodgr_dists (graph, from, to, heap = heap)
34-
}
33+
34+
dodgr_dists (graph = graph, from = from, to = to, heap = heap, pairwise= pairwise)
35+
}

man/dodgr_times.Rd

Lines changed: 11 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

tests/testthat/test-dists.R

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -178,6 +178,21 @@ test_that ("times", {
178178
expect_identical (t2, t0)
179179
})
180180

181+
test_that ("times-pairwise", {
182+
graph <- weight_streetnet (hampi)
183+
n <- 50
184+
set.seed (1)
185+
from <- sample (graph$from_id, size = n)
186+
to <- sample (graph$to_id, size = n)
187+
expect_silent (d <- dodgr_times (graph, from = from, to = to))
188+
expect_equal (dim (d), c (n, n))
189+
expect_silent (d <- dodgr_times (graph,
190+
from = from, to = to,
191+
pairwise = TRUE
192+
))
193+
expect_equal (dim (d), c (50, 1))
194+
})
195+
181196
test_that ("all dists", {
182197
graph <- weight_streetnet (hampi)
183198
graph <- graph [graph$component == 2, ]

0 commit comments

Comments
 (0)