Resolve the directed graph problem