public function findUnreachableStates(): array
	{
		$g = new Graph();
		$g->indexNodeAttr('unreachable');

		$g->createNode('', ['unreachable' => false]);
		foreach ($this->states as $s => $state) {
			if ($s !== '') {
				$g->createNode($s, ['unreachable' => true]);
			}
		}

		foreach ($this->actions as $a => $action) {
			foreach ($action['transitions'] ?? [] as $source => $transition) {
				foreach ($transition['targets'] ?? [] as $target) {
					$g->createEdge(null, $g->getNode($source), $g->getNode($target), []);
				}
			}
		}

		GraphSearch::DFS($g)
			->onNode(function (Node $node) use ($g) {
				$node->setAttr('unreachable', false);
				return true;
			})
			->start([$g->getNode('')]);

		return array_map(function(Node $n) { return $n->getId(); }, $g->getNodesByAttr('unreachable', true));
	}
public function findUnreachableStates(): array
	{
		$g = new Graph();
		$g->indexNodeAttr('unreachable');

		$g->createNode('', ['unreachable' => false]);
		foreach ($this->states as $s => $state) {
			if ($s !== '') {
				$g->createNode($s, ['unreachable' => true]);
			}
		}

		foreach ($this->actions as $a => $action) {
			foreach ($action['transitions'] ?? [] as $source => $transition) {
				foreach ($transition['targets'] ?? [] as $target) {
					$g->createEdge(null, $g->getNode($source), $g->getNode($target), []);
				}
			}
		}

		GraphSearch::DFS($g)
			->onNode(function (Node $node) use ($g) {
				$node->setAttr('unreachable', false);
				return true;
			})
			->start([$g->getNode('')]);

		return array_map(function(Node $n) { return $n->getId(); }, $g->getNodesByAttr('unreachable', true));
	}
public function findUnreachableStates ( ) : array { $ g = new Graph ( ) ; $ g -> indexNodeAttr ( 'unreachable' ) ; $ g -> createNode ( '' , [ 'unreachable' => false ] ) ; foreach ( $ this -> states as $ s => $ state ) { if ( $ s !== '' ) { $ g -> createNode ( $ s , [ 'unreachable' => true ] ) ; } } foreach ( $ this -> actions as $ a => $ action ) { foreach ( $ action [ 'transitions' ] ?? [ ] as $ source => $ transition ) { foreach ( $ transition [ 'targets' ] ?? [ ] as $ target ) { $ g -> createEdge ( null , $ g -> getNode ( $ source ) , $ g -> getNode ( $ target ) , [ ] ) ; } } } GraphSearch :: DFS ( $ g ) -> onNode ( function ( Node $ node ) use ( $ g ) { $ node -> setAttr ( 'unreachable' , false ) ; return true ; } ) -> start ( [ $ g -> getNode ( '' ) ] ) ; return array_map ( function ( Node $ n ) { return $ n -> getId ( ) ; } , $ g -> getNodesByAttr ( 'unreachable' , true ) ) ; }
Run DFS from not-exists state and return list of unreachable states.
Run DFS from not - exists state and return list of unreachable states .