fix error in graph construction