Пример #1
0
 /**
  * 
  * @param string $start_object_id The id of the object to start the search from
  * @param string $function the function to get the next level of elements
  * @param string $object_id the object id to searhc for
  * @param array $visited the array of visited element
  * @return boolean true if cycle
  */
 protected static function isCycle($start_object_id, $function, $object_id, &$visited = array())
 {
     if ($start_object_id == $object_id) {
         return true;
     }
     $visited[] = $start_object_id;
     $cycle = false;
     $next_level = HotspotGraph::$function($start_object_id);
     if ($next_level) {
         foreach ($next_level as $next_row) {
             if (!in_array($next_row['next_element_id'], $visited)) {
                 $cycle = $cycle || HotspotGraph::isCycle($next_row['next_element_id'], $function, $object_id, $visited);
             }
             if ($cycle) {
                 break;
             }
         }
     }
     return $cycle;
 }