fork download
  1. <?php
  2. $times_arrival =
  3. 3 =>
  4. 0 =>
  5. 0 => '1',
  6. 1 => '08:12'),
  7. 1 =>
  8. 0 => '2',
  9. 1 => '08:40')),
  10. 41 =>
  11. 0 =>
  12. 0 => '21',
  13. 1 => '12:40')));
  14.  
  15.  
  16. foreach($times_arrival as $city_id => $time_points) {
  17. if (isset($times_departure[$city_id]) && isset($cities[$city_id]))
  18. {
  19. foreach($times_arrival[$city_id] as $t1_info)
  20. {
  21. foreach($times_departure[$city_id] as $t2_info)
  22. {
  23. if ($t1_info[0] != $t2_info[0])
  24. {
  25. $t1 = $t1_info[1];
  26. $t2 = $t2_info[1];
  27.  
  28. $vertex_key = new Vertex($city_id, $t1, 1);
  29. $vertex_key = $vertex_key->toString();
  30.  
  31. if (date('H:i', strtotime($t2)) > date('H:i', strtotime('+ 10 minutes', strtotime($t1))))
  32. {
  33. $this->graph[$vertex_key][] = new Edge(
  34. NULL,
  35. $vertex_key,
  36. new Vertex($city_id, $t2, 0),
  37. (float) 0,
  38. $f((strtotime($t2) - strtotime($t1)) / 60, 0, 1) //edge weight
  39. );
  40. }
  41. else if (date('H:i', strtotime('+ 24 hours', strtotime($t2))) > date('H:i', strtotime('+ 10 minutes', strtotime($t1))))
  42. {
  43. $this->graph[$vertex_key][] = new Edge(
  44. NULL,
  45. $vertex_key,
  46. new Vertex($city_id, $t2, 0),
  47. (float) 0,
  48. $f(strtotime('+ 24 hours', strtotime($t2)) - strtotime($t1) / 60, 0, 1)
  49. );
  50. }
  51. }
  52. }
  53. }
  54. }
  55. }
  56. ?>
Success #stdin #stdout 0.02s 13112KB
stdin
Standard input is empty
stdout
Standard output is empty