protected function searchComponent($start)
    {
        if (!isset($this->component)) {
            $this->component = $start;
        }

        if (isset($this->graph[$start]['paths'])) {
            return null;
        }

        $this->graph[$start]['paths'] = array();
        $this->graph[$start]['component'] = $this->component;
        $this->state['components'][$this->component][] = $start;

        if (isset($this->graph[$start]['edges'])) {
            foreach ($this->graph[$start]['edges'] as $end => $v) {
                $this->graph[$start]['paths'][$end] = $v;
                if (isset($this->graph[$end]['component']) && $this->component != $this->graph[$end]['component']) {
                    $new_component = $this->graph[$end]['component'];
                    foreach ($this->state['components'][$this->component] as $vertex) {
                        $this->graph[$vertex]['component'] = $new_component;
                        $this->state['components'][$new_component][] = $vertex;
                    }
                    unset($this->state['components'][$this->component]);
                    $this->component = $new_component;
                }

                if (isset($this->graph[$end])) {
                    $this->searchComponent($end);
                    $this->graph[$start]['paths'] += $this->graph[$end]['paths'];
                }
            }
        }

        foreach ($this->graph[$start]['paths'] as $end => $v) {
            if (isset($this->graph[$end])) {
                $this->graph[$end]['reverse_paths'][$start] = $v;
            }
        }

        $this->state['last_visit_order'][] = $start;
        return null;
    }
protected function searchComponent($start)
    {
        if (!isset($this->component)) {
            $this->component = $start;
        }

        if (isset($this->graph[$start]['paths'])) {
            return null;
        }

        $this->graph[$start]['paths'] = array();
        $this->graph[$start]['component'] = $this->component;
        $this->state['components'][$this->component][] = $start;

        if (isset($this->graph[$start]['edges'])) {
            foreach ($this->graph[$start]['edges'] as $end => $v) {
                $this->graph[$start]['paths'][$end] = $v;
                if (isset($this->graph[$end]['component']) && $this->component != $this->graph[$end]['component']) {
                    $new_component = $this->graph[$end]['component'];
                    foreach ($this->state['components'][$this->component] as $vertex) {
                        $this->graph[$vertex]['component'] = $new_component;
                        $this->state['components'][$new_component][] = $vertex;
                    }
                    unset($this->state['components'][$this->component]);
                    $this->component = $new_component;
                }

                if (isset($this->graph[$end])) {
                    $this->searchComponent($end);
                    $this->graph[$start]['paths'] += $this->graph[$end]['paths'];
                }
            }
        }

        foreach ($this->graph[$start]['paths'] as $end => $v) {
            if (isset($this->graph[$end])) {
                $this->graph[$end]['reverse_paths'][$start] = $v;
            }
        }

        $this->state['last_visit_order'][] = $start;
        return null;
    }
protected function searchComponent ( $ start ) { if ( ! isset ( $ this -> component ) ) { $ this -> component = $ start ; } if ( isset ( $ this -> graph [ $ start ] [ 'paths' ] ) ) { return null ; } $ this -> graph [ $ start ] [ 'paths' ] = array ( ) ; $ this -> graph [ $ start ] [ 'component' ] = $ this -> component ; $ this -> state [ 'components' ] [ $ this -> component ] [ ] = $ start ; if ( isset ( $ this -> graph [ $ start ] [ 'edges' ] ) ) { foreach ( $ this -> graph [ $ start ] [ 'edges' ] as $ end => $ v ) { $ this -> graph [ $ start ] [ 'paths' ] [ $ end ] = $ v ; if ( isset ( $ this -> graph [ $ end ] [ 'component' ] ) && $ this -> component != $ this -> graph [ $ end ] [ 'component' ] ) { $ new_component = $ this -> graph [ $ end ] [ 'component' ] ; foreach ( $ this -> state [ 'components' ] [ $ this -> component ] as $ vertex ) { $ this -> graph [ $ vertex ] [ 'component' ] = $ new_component ; $ this -> state [ 'components' ] [ $ new_component ] [ ] = $ vertex ; } unset ( $ this -> state [ 'components' ] [ $ this -> component ] ) ; $ this -> component = $ new_component ; } if ( isset ( $ this -> graph [ $ end ] ) ) { $ this -> searchComponent ( $ end ) ; $ this -> graph [ $ start ] [ 'paths' ] += $ this -> graph [ $ end ] [ 'paths' ] ; } } } foreach ( $ this -> graph [ $ start ] [ 'paths' ] as $ end => $ v ) { if ( isset ( $ this -> graph [ $ end ] ) ) { $ this -> graph [ $ end ] [ 'reverse_paths' ] [ $ start ] = $ v ; } } $ this -> state [ 'last_visit_order' ] [ ] = $ start ; return null ; }
Performs a depth-first search on a graph
@param string $start
@return null
Performs a depth - first search on a graph