From 06eaed3546d970b400b1644d3151cf8e792992a4 Mon Sep 17 00:00:00 2001 From: Kuzivanov Sergey <43182277+SergeyKuz1001@users.noreply.github.com> Date: Fri, 1 Nov 2019 17:01:56 +0300 Subject: [PATCH] Create SequentialAlgoFloyd.cs --- Task02/SequentialAlgoFloyd.cs | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100644 Task02/SequentialAlgoFloyd.cs diff --git a/Task02/SequentialAlgoFloyd.cs b/Task02/SequentialAlgoFloyd.cs new file mode 100644 index 0000000..34087ce --- /dev/null +++ b/Task02/SequentialAlgoFloyd.cs @@ -0,0 +1,27 @@ +using System; + +namespace Task02 +{ + public class SequentialAlgoFloyd + { + public static int[,] Execute() + { + int n = GeneralResources.n; + int[,] dist = new int[n, n]; + Array.Copy(GeneralResources.graphMatrix, dist, n * n); + + for (int k = 0; k < n; k++) + { + for (int i = 0; i < n; i++) + { + for (int j = 0; j < n; j++) + { + if (dist[i, j] > dist[i, k] + dist[k, j]) + dist[i, j] = dist[i, k] + dist[k, j]; + } + } + } + return dist; + } + } +}