title: How to detect a cycle in a directed graph with Python?
body: <p>I have some input like: <code>[('A', 'B'),('C', 'D'),('D', 'C'),('C', 'D')]</code>. I want to look for if the existence of a cycle in a directed graph represented by this edgeList.</p>
  
  <p>I read a discussion: <a href="https://www.geeksforgeeks.org/detect-cycle-in-a-graph/" rel="nofollow noreferrer">https://www.geeksforgeeks.org/detect-cycle-in-a-graph/</a>, however it has some errors when the case is:</p>
  
  <pre><code>g = Graph(3)
  g.addEdge('A', 'B')
  g.addEdge('B', 'C')
  g.addEdge('C', 'A')
  </code></pre>
  
  <p>Its result is 'Graph has no cycle'. This is clearly wrong.
  Can you help me to solve this problem?</p>