Skip to content

Instantly share code, notes, and snippets.

@spaghetti-source
Last active November 25, 2020 15:49
Show Gist options
  • Save spaghetti-source/6445960 to your computer and use it in GitHub Desktop.
Save spaghetti-source/6445960 to your computer and use it in GitHub Desktop.
Floyd Warshall (matlab)
function D = FloydWarshall(D)
n = size(D, 1);
for k = 1 : n
i2k = repmat(D(:,k), 1, n);
k2j = repmat(D(k,:), n, 1);
D = min(D, i2k + k2j);
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment