protected function search()
    {
        $this->state = array(
            'last_visit_order' => array(),
            'components' => array(),
        );

        foreach ($this->graph as $start => $data) {
            $this->searchComponent($start);
        }

        $component_weights = array();

        foreach ($this->state['last_visit_order'] as $vertex) {

            $component = $this->graph[$vertex]['component'];

            if (!isset($component_weights[$component])) {
                $component_weights[$component] = 0;
            }

            $this->graph[$vertex]['weight'] = $component_weights[$component]--;
        }
    }