/**
  * Converts a DirectedGraph into a DirectedAcyclicGraph.
  *
  * A DirectedGraph can be converted into a DirectedAcyclicGraph when
  * is does not contain any cycle.
  *
  * @param \GraphAPI\Component\Graph\DirectedGraph $g
  * @param type $ignore_exception
  * @throws \GraphAPI\Component\Graph\Exception
  */
 static function fromDirectedGraph(DirectedGraph $g, $ignore_exception = FALSE)
 {
     $d = new DirectedAcyclicGraph();
     foreach ($g->getNodeIds() as $id) {
         $links = $g->getLinks($id);
         foreach ($links as $link) {
             try {
                 $d->addLink($id, $link);
             } catch (\Exception $exc) {
                 if (!$ignore_exception) {
                     throw $exc;
                 }
             }
         }
     }
     return $d;
 }
function dumpTSL(DirectedAcyclicGraph $g)
{
    echo "\nTSL: " . join(',', $g->getTSL()) . "\n";
}