original_string: public function build(array $items)
      {
          $this->graph = array(); // Reset all previous data
  
          foreach ($items as $id => $item) {
  
              $this->graph[$id]['edges'] = array();
  
              if (empty($item['dependencies'])) {
                  continue;
              }
  
              foreach ($item['dependencies'] as $did => $ddata) {
                  $this->graph[$id]['edges'][$did] = $ddata;
              }
          }
  
          $this->search();
  
          foreach ($this->graph as $id => $data) {
              $items[$id]['required_by'] = isset($data['reverse_paths']) ? $data['reverse_paths'] : array();
              $items[$id]['requires'] = isset($data['paths']) ? $data['paths'] : array();
              $items[$id]['sort'] = $data['weight'];
          }
  
          return $items;
      }
code: public function build(array $items)
      {
          $this->graph = array(); // Reset all previous data
  
          foreach ($items as $id => $item) {
  
              $this->graph[$id]['edges'] = array();
  
              if (empty($item['dependencies'])) {
                  continue;
              }
  
              foreach ($item['dependencies'] as $did => $ddata) {
                  $this->graph[$id]['edges'][$did] = $ddata;
              }
          }
  
          $this->search();
  
          foreach ($this->graph as $id => $data) {
              $items[$id]['required_by'] = isset($data['reverse_paths']) ? $data['reverse_paths'] : array();
              $items[$id]['requires'] = isset($data['paths']) ? $data['paths'] : array();
              $items[$id]['sort'] = $data['weight'];
          }
  
          return $items;
      }
code_tokens: public function build ( array $ items ) { $ this -> graph = array ( ) ; // Reset all previous data foreach ( $ items as $ id => $ item ) { $ this -> graph [ $ id ] [ 'edges' ] = array ( ) ; if ( empty ( $ item [ 'dependencies' ] ) ) { continue ; } foreach ( $ item [ 'dependencies' ] as $ did => $ ddata ) { $ this -> graph [ $ id ] [ 'edges' ] [ $ did ] = $ ddata ; } } $ this -> search ( ) ; foreach ( $ this -> graph as $ id => $ data ) { $ items [ $ id ] [ 'required_by' ] = isset ( $ data [ 'reverse_paths' ] ) ? $ data [ 'reverse_paths' ] : array ( ) ; $ items [ $ id ] [ 'requires' ] = isset ( $ data [ 'paths' ] ) ? $ data [ 'paths' ] : array ( ) ; $ items [ $ id ] [ 'sort' ] = $ data [ 'weight' ] ; } return $ items ; }
docstring: Determines which components require and are required by each component
  @param array $items
  @return array
docstring_tokens: Determines which components require and are required by each component