title: What is the algorithm to find circular dependency in the project?
body: <p>I need to find circular dependency between classes and I immediately remember two things from the "Algorithms and Data Structures" course:</p>
  
  <p>1)Finding a Loop in a Singly Linked List (Floyd’s Cycle-Finding Algorithm)</p>
  
  <p>2)Depth-first search</p>
  
  <p>So, I have a method that check circular dependency</p>
  
  <pre><code> private void FindDependency(IDictionary&lt;string, IEnumerable&lt;string&gt;&gt; serviceDependence)
  </code></pre>
  
  <p>In input, we have a dictionary that contains, for example,  <code>&lt;"A", &lt; "B", "C" &gt;&gt;</code> and  <code>&lt;"B", &lt; "A", "D" &gt;&gt;</code>, this means that class <code>A</code> depends on class <code>B</code> and <code>C</code>.  In the output, we have a circular dependency between <code>A-&gt;B</code>(in the more complex situation it will be a chain of dependency).</p>
  
  <p>Which algorithms should I use and why?</p>