update: fixed index bug in graph.R