refactor dagre to be a one shot call