From aa26119f34dcdccf32f21bf7d46ab562d6a167c6 Mon Sep 17 00:00:00 2001 From: Gelieza K Date: Fri, 18 Aug 2023 11:51:59 +0200 Subject: [PATCH] Finish todo in asp notebook --- notebooks/asp.ipynb | 50 +++++++++++++++++++++++++++++++++++++-------- 1 file changed, 42 insertions(+), 8 deletions(-) diff --git a/notebooks/asp.ipynb b/notebooks/asp.ipynb index cedc122..843c863 100644 --- a/notebooks/asp.ipynb +++ b/notebooks/asp.ipynb @@ -31,7 +31,7 @@ "id": "ade31d26", "metadata": {}, "source": [ - "## The all pairs of shortest paths (ASP) problem\n", + "## The All Pairs of Shortest Paths (ASP) problem\n", "\n", "Let us start by presenting the all pairs of shortest paths (ASP) problem and its solution with the [Floyd–Warshall algorithm](https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm).\n", "\n", @@ -70,10 +70,21 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 1, "id": "4fe447c5", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "floyd! (generic function with 1 method)" + ] + }, + "execution_count": 1, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "function floyd!(C)\n", " n = size(C,1)\n", @@ -99,10 +110,25 @@ }, { "cell_type": "code", - "execution_count": null, + "execution_count": 2, "id": "860e537c", "metadata": {}, - "outputs": [], + "outputs": [ + { + "data": { + "text/plain": [ + "4×4 Matrix{Int64}:\n", + " 0 9 6 1\n", + " 2 0 8 3\n", + " 5 3 0 6\n", + " 10 8 5 0" + ] + }, + "execution_count": 2, + "metadata": {}, + "output_type": "execute_result" + } + ], "source": [ "inf = 1000\n", "C = [\n", @@ -296,7 +322,7 @@ "id": "db9a3294", "metadata": {}, "source": [ - "TODO explain this part" + "At each iteration, the processor needs the input values `C[i,j]`, `C[i,k]` and `C[k,j]`. Since we split the data row-wise, the process already has values `C[i,j]` and `C[i,k]`. However, `C[k,j]` may be stored in a different process. " ] }, { @@ -314,6 +340,14 @@ "" ] }, + { + "cell_type": "markdown", + "id": "a01872ef", + "metadata": {}, + "source": [ + "As we iterate over columns $j$, the process needs input from all values of row $k$. Therefore, at the start of iteration $k$, the whole row $k$ needs to be communicated." + ] + }, { "attachments": { "g12957.png": { @@ -634,7 +668,7 @@ ], "metadata": { "kernelspec": { - "display_name": "Julia 1.9.0", + "display_name": "Julia 1.9.1", "language": "julia", "name": "julia-1.9" }, @@ -642,7 +676,7 @@ "file_extension": ".jl", "mimetype": "application/julia", "name": "julia", - "version": "1.9.0" + "version": "1.9.1" } }, "nbformat": 4,