diff options
Diffstat (limited to 'R Scripts')
| -rwxr-xr-x | R Scripts/generate-dag-dat.R | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/R Scripts/generate-dag-dat.R b/R Scripts/generate-dag-dat.R index adef5f6..3e8b495 100755 --- a/R Scripts/generate-dag-dat.R +++ b/R Scripts/generate-dag-dat.R @@ -9,7 +9,7 @@ registerDoMC(cores=4) edgeWeights = function(eis){return(c(lcc_edges$weight[eis],Inf,Inf)[1:3])} lcc2 = remove.edge.attribute(lcc,'weight') -vics = split(vic_ids, ceiling(seq_along(vic_ids)/98)) +vics = split(vic_ids, ceiling(seq_along(vic_ids)/40)) dag_dat_lcc = c() for(i in 1:length(vics)){ ptm = proc.time() @@ -19,10 +19,11 @@ for(i in 1:length(vics)){ ddl = foreach (u = vic_ids, .combine=rbind) %dopar% { if ((which(vic_ids==u) %% 100)==0) print(which(vic_ids==u)) - nbhd = unlist(neighborhood(lcc,nodes=u,order=1)) # get nodes within neighborhood + nbhd = unlist(neighborhood(lcc,nodes=u,order=2)) # get nodes within neighborhood nbhd = nbhd[-1] # don't want to include u in the neighborhood dists = as.numeric(shortest.paths(lcc2,u,nbhd)) + nbhd = nbhd[dists==2]; dists = dists[dists==2] ##### es = get.shortest.paths(lcc2,u,nbhd,output='epath')$epath weights = matrix(unlist(lapply(es,edgeWeights),use.names = F),ncol=3,byrow=T) @@ -58,3 +59,8 @@ write.csv(dag_dat_lcc, file='Results/dag_dat_lcc.csv') #### # create lcc_vic_times +vic_times_lcc = lcc_verts[,c('name','nonfatal_day_1','nonfatal_day_2', + 'nonfatal_day_3','nonfatal_day_4', + 'nonfatal_day_5','fatal_day')] +save(vic_times_lcc, file='Results/vic_times_lcc.RData') +write.csv(vic_times_lcc, file='Results/vic_times_lcc.csv') |
