graph.R code clean