function imprimir_afd() { $this->layout = 'empty'; $this->thompson->generarAFND(); $this->thompson->AFNDaAFD(); $AFD = $this->thompson->getAFD(); $estados = $AFD->getEstados(); $graph = new Image_GraphViz(true, array(), 'AFD', false); $graph->setAttributes(array('size' => '8,5', 'rankdir' => 'LR')); $transiciones = array(); foreach ($estados as $estado) { if (!$estado->esFinal()) { $graph->addNode('q' . $estado->getID(), array('shape' => 'circle')); } else { $graph->addNode('q' . $estado->getID(), array('shape' => 'doublecircle')); } if ($estado->esInicial()) { $graph->addNode('null', array('shape' => 'plaintext', 'label' => '')); $graph->addEdge(array('null' => 'q' . $estado->getID()), array('label' => '')); } $transiciones = $estado->getArregloTransiciones(); if (!empty($transiciones)) { foreach ($transiciones as $simbolo => $destinos) { foreach ($destinos as $destino) { $graph->addEdge(array('q' . $estado->getID() => 'q' . $destino), array('label' => $simbolo)); } } } } $graph->image(); }