Skip to content

Commit

Permalink
speed up by removing unnecessary %in%
Browse files Browse the repository at this point in the history
  • Loading branch information
see24 committed Mar 13, 2024
1 parent ecd0e46 commit 38277cb
Showing 1 changed file with 4 additions and 2 deletions.
6 changes: 4 additions & 2 deletions R/shortestPaths.R
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ shortestPaths<- function(sim){

# updates the cost(weight) associated with the edge that became a road
igraph::edge_attr(sim$g,
index = igraph::E(sim$g)[igraph::E(sim$g) %in% paths.e],
index = igraph::E(sim$g)[paths.e],
name = "weight") <- 0.00001

rm(paths.e)
Expand All @@ -71,8 +71,10 @@ iterativeShortestPaths<- function(sim){
path <- unlist(path)

# update the cost(weight) associated with the edge that became a road
path_edge_ind <- igraph::E(sim$g)[path[grepl("epath", names(path))]]

igraph::edge_attr(sim$g,
index = igraph::E(sim$g)[igraph::E(sim$g) %in% path[grepl("epath", names(path))]],
index = path_edge_ind,
name = "weight") <- 0.00001

# get vertices
Expand Down

0 comments on commit 38277cb

Please sign in to comment.