original_string: 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]--;
          }
      }
code: 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]--;
          }
      }
code_tokens: 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 ] -- ; } }
docstring: Performs a depth-first search and sort on a directed acyclic graph
docstring_tokens: Performs a depth - first search and sort on a directed acyclic graph