The algorithms to remove cycles completely in a directed graph can be complicated. If you just remove one cycle, you can use brute force. Remove one edge at a time. Use detect cycle method to check whether the cycle is gone. If not, move to the next edge.