public function buildTree(): OutTree
    {
        if ($this->tree === null) {
            $root = $this->graph->createVertex(0);

            // Create edges directed from the root node
            foreach ($this->processes as $className => $processWrapper) {
                $vertex = $this->graph->getVertex($className);

                if ($processWrapper->getDelayMinutes() === null) { // doesn't depend on anything => link it to the root
                    $root->createEdgeTo($vertex)->setWeight(0);
                } else { // is dependant => link it to its dependency
                    // Throw error if dependency is to not existing vertex
                    if (!$this->graph->hasVertex($processWrapper->getDelayAfter())) {
                        throw new \InvalidArgumentException(
                            sprintf(
                                'Testcase "%s" has @delayAfter dependency on "%s", but this testcase was not defined.',
                                $className,
                                $processWrapper->getDelayAfter()
                            )
                        );
                    }

                    $this->graph->getVertex($processWrapper->getDelayAfter())
                        ->createEdgeTo($vertex)
                        ->setWeight($processWrapper->getDelayMinutes());
                }
            }
        }

        $this->tree = new OutTree($this->graph);

        if (!$this->tree->isTree()) {
            throw new \InvalidArgumentException(
                sprintf('Cannot build tree graph from tests dependencies. Probably some cyclic dependency is present.')
            );
        }

        return $this->tree;
    }
public function buildTree(): OutTree
    {
        if ($this->tree === null) {
            $root = $this->graph->createVertex(0);

            // Create edges directed from the root node
            foreach ($this->processes as $className => $processWrapper) {
                $vertex = $this->graph->getVertex($className);

                if ($processWrapper->getDelayMinutes() === null) { // doesn't depend on anything => link it to the root
                    $root->createEdgeTo($vertex)->setWeight(0);
                } else { // is dependant => link it to its dependency
                    // Throw error if dependency is to not existing vertex
                    if (!$this->graph->hasVertex($processWrapper->getDelayAfter())) {
                        throw new \InvalidArgumentException(
                            sprintf(
                                'Testcase "%s" has @delayAfter dependency on "%s", but this testcase was not defined.',
                                $className,
                                $processWrapper->getDelayAfter()
                            )
                        );
                    }

                    $this->graph->getVertex($processWrapper->getDelayAfter())
                        ->createEdgeTo($vertex)
                        ->setWeight($processWrapper->getDelayMinutes());
                }
            }
        }

        $this->tree = new OutTree($this->graph);

        if (!$this->tree->isTree()) {
            throw new \InvalidArgumentException(
                sprintf('Cannot build tree graph from tests dependencies. Probably some cyclic dependency is present.')
            );
        }

        return $this->tree;
    }
public function buildTree ( ) : OutTree { if ( $ this -> tree === null ) { $ root = $ this -> graph -> createVertex ( 0 ) ; // Create edges directed from the root node foreach ( $ this -> processes as $ className => $ processWrapper ) { $ vertex = $ this -> graph -> getVertex ( $ className ) ; if ( $ processWrapper -> getDelayMinutes ( ) === null ) { // doesn't depend on anything => link it to the root $ root -> createEdgeTo ( $ vertex ) -> setWeight ( 0 ) ; } else { // is dependant => link it to its dependency // Throw error if dependency is to not existing vertex if ( ! $ this -> graph -> hasVertex ( $ processWrapper -> getDelayAfter ( ) ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Testcase "%s" has @delayAfter dependency on "%s", but this testcase was not defined.' , $ className , $ processWrapper -> getDelayAfter ( ) ) ) ; } $ this -> graph -> getVertex ( $ processWrapper -> getDelayAfter ( ) ) -> createEdgeTo ( $ vertex ) -> setWeight ( $ processWrapper -> getDelayMinutes ( ) ) ; } } } $ this -> tree = new OutTree ( $ this -> graph ) ; if ( ! $ this -> tree -> isTree ( ) ) { throw new \ InvalidArgumentException ( sprintf ( 'Cannot build tree graph from tests dependencies. Probably some cyclic dependency is present.' ) ) ; } return $ this -> tree ; }
Build out-tree graph from defined Processes and their relations.

@internal Should be called directly only in unit-testing
Build out - tree graph from defined Processes and their relations .