fourth version, graph diameter heuristic