title: Algorithm to find a hierarchy tree in a directed acyclic graph?
body: <p>I have a graph with properties as shown below:</p>
  
  <p>Adjacency Matrix:</p>
  
  <p><img src="https://i.stack.imgur.com/LchSG.png" alt=""></p>
  
  <p>Graph Representation:</p>
  
  <p><img src="https://i.stack.imgur.com/z1yBc.png" alt=""></p>
  
  <p>Which algorithm can be applied to find a hierarchy tree of the above graph? In my words, a hierarchy tree is one in which nodes are connected and directed towards their immediate child only and any edge from current to child of child or any other should be removed.</p>
  
  <p>For the above graph, a hierarchy tree would look like the following:</p>
  
  <p>Hierarchy Tree:</p>
  
  <p><img src="https://i.stack.imgur.com/HKmnc.png" alt=""></p>