Refine getDrawData algorithm to support cycles in the graph.