Finish todo in asp notebook

This commit is contained in:
Gelieza K 2023-08-18 11:51:59 +02:00
parent 9372448ef5
commit aa26119f34

View File

@ -31,7 +31,7 @@
"id": "ade31d26", "id": "ade31d26",
"metadata": {}, "metadata": {},
"source": [ "source": [
"## The all pairs of shortest paths (ASP) problem\n", "## The All Pairs of Shortest Paths (ASP) problem\n",
"\n", "\n",
"Let us start by presenting the all pairs of shortest paths (ASP) problem and its solution with the [FloydWarshall algorithm](https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm).\n", "Let us start by presenting the all pairs of shortest paths (ASP) problem and its solution with the [FloydWarshall algorithm](https://en.wikipedia.org/wiki/Floyd%E2%80%93Warshall_algorithm).\n",
"\n", "\n",
@ -70,10 +70,21 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 1,
"id": "4fe447c5", "id": "4fe447c5",
"metadata": {}, "metadata": {},
"outputs": [], "outputs": [
{
"data": {
"text/plain": [
"floyd! (generic function with 1 method)"
]
},
"execution_count": 1,
"metadata": {},
"output_type": "execute_result"
}
],
"source": [ "source": [
"function floyd!(C)\n", "function floyd!(C)\n",
" n = size(C,1)\n", " n = size(C,1)\n",
@ -99,10 +110,25 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": null, "execution_count": 2,
"id": "860e537c", "id": "860e537c",
"metadata": {}, "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": [ "source": [
"inf = 1000\n", "inf = 1000\n",
"C = [\n", "C = [\n",
@ -296,7 +322,7 @@
"id": "db9a3294", "id": "db9a3294",
"metadata": {}, "metadata": {},
"source": [ "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 @@
"</div>" "</div>"
] ]
}, },
{
"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": { "attachments": {
"g12957.png": { "g12957.png": {
@ -634,7 +668,7 @@
], ],
"metadata": { "metadata": {
"kernelspec": { "kernelspec": {
"display_name": "Julia 1.9.0", "display_name": "Julia 1.9.1",
"language": "julia", "language": "julia",
"name": "julia-1.9" "name": "julia-1.9"
}, },
@ -642,7 +676,7 @@
"file_extension": ".jl", "file_extension": ".jl",
"mimetype": "application/julia", "mimetype": "application/julia",
"name": "julia", "name": "julia",
"version": "1.9.0" "version": "1.9.1"
} }
}, },
"nbformat": 4, "nbformat": 4,