title: How to convert Directed Acyclic Graph (DAG) to Tree
body: <p>I have been looking for C# examples to transform a DAG into a Tree.</p>
  
  <p>Does anyone have an examples or pointers in the right direction?</p>
  
  <p><b>Clarification Update</b></p>
  
  <p>
  I have a graph that contains a list of modules that my application is required to load.  Each module has a list of modules it depends on. For example here are my modules, A, B C, D and E
  </p>
  
  <ul>
  <li>A has no dependencies</li>
  <li>B depends on A, C and E</li>
  <li>C depends on A</li>
  <li>D depends on A</li>
  <li>E depends on C and A</li>
  </ul>
  
  <p>
  I want resolve dependencies and generate a tree that looks like this...
  </p>
  
  <p>--A</p>
  
  <p>--+--B</p>
  
  <p>-----+--C</p>
  
  <p>---------+--D</p>
  
  <p>--+--E</p>
  
  <p><b>Topological Sort</b></p>
  
  <p>
  Thanks for the information, if I perform a Topological sort and reverse the output i will have the following order</p>
  
  <ul>
  <li>A</li>
  <li>B</li>
  <li>C</li>
  <li>D</li>
  <li>E</li>
  </ul>
  
  <p>
  I want to maintain the hierarchical structure so that my modules are loaded into the correct context, for example... module E should be in the same container as B
  </p>
  
  <p>Thanks</p>
  
  <p>Rohan</p>