<?php
$map = [
0 => [0, 15, 13, 1],
1 => [15, 0, 7, 10],
2 => [13, 7, 0, 14],
3 => [1, 10, 14, 0]
];
$s = [];
$t = [];
$start = 0;
$end = 3;
$s[] = $start;
$t = [];
$Vj = $start;
echo count($map);die;
for ($i = 0; $i < count($map), $i++){
foreach ($map[$start] as $key => $value){
if (in_array($key, $s)){
continue;
}
$tem = $s[$Vj] + $value;
if (isset($t[$key]) && $tem < $t[$key]){
$t[$key] = $tem;
}else{
$t[$key] = $value;
}
}
$Vj = array_search(min($t), $t);
$s[$Vj] = min($t);
unset($t[$Vj]);
var_dump($s);
}