Skip to content

Commit

Permalink
fix duplicate in mstList
Browse files Browse the repository at this point in the history
  • Loading branch information
see24 committed May 29, 2024
1 parent e8f607f commit 68d8d90
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
2 changes: 1 addition & 1 deletion R/mstList.R
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ mstList<- function(sim, roadsConnected){

mst.adj <- cbind(rbind(lnd_to_lnd,t(lnd_to_rd)), rbind(lnd_to_rd, 0))
} else {
both.v <- c(lnd.v, rd.v)
both.v <- unique(c(lnd.v, rd.v))
mst.adj <- igraph::distances(sim$g, both.v, both.v)
dimnames(mst.adj) <- list(both.v, both.v)
}
Expand Down
15 changes: 15 additions & 0 deletions tests/testthat/test-projectRoads.R
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,21 @@ test_that("duplicate roads are not created", {

})

test_that("landings on road or multiple landings in same cell work", {
CLUSexample <- prepExData(CLUSexample)

CLUSexample$landings <- bind_rows(CLUSexample$landings,
list(sf::st_point(c(1.5, 4.2)), sf::st_point(c(1.5, 0.6))) %>%
sf::st_as_sfc() %>%
sf::st_as_sf(crs = sf::st_crs(CLUSexample$landings)) %>%
rename(geometry = x))
expect_type(
projectRoads(CLUSexample$landings, CLUSexample$cost, CLUSexample$roads,
roadMethod = "mst"),
"list")


})

if(FALSE){
# checking memory allocations
Expand Down

0 comments on commit 68d8d90

Please sign in to comment.