Fix aggregated edges
Update R script