fix in graph infinite loop check