From c8d45c39f4dc0b5bab73ce7fafaa94e4fcc1e7f0 Mon Sep 17 00:00:00 2001 From: Laaksonen Antti H S Date: Tue, 3 Jul 2018 14:48:22 +0300 Subject: [PATCH] Fix Bellman-Ford example [closes #60] --- chapter13.tex | 50 +++++++++++++++++++++++++------------------------- 1 file changed, 25 insertions(+), 25 deletions(-) diff --git a/chapter13.tex b/chapter13.tex index e87828b..f318a98 100644 --- a/chapter13.tex +++ b/chapter13.tex @@ -53,17 +53,17 @@ works in the following graph: \node[draw, circle] (2) at (4,3) {2}; \node[draw, circle] (3) at (1,1) {3}; \node[draw, circle] (4) at (4,1) {4}; -\node[draw, circle] (5) at (6,2) {5}; +\node[draw, circle] (5) at (6,2) {6}; \node[color=red] at (1,3+0.55) {$0$}; \node[color=red] at (4,3+0.55) {$\infty$}; \node[color=red] at (1,1-0.55) {$\infty$}; \node[color=red] at (4,1-0.55) {$\infty$}; \node[color=red] at (6,2-0.55) {$\infty$}; -\path[draw,thick,-] (1) -- node[font=\small,label=above:2] {} (2); +\path[draw,thick,-] (1) -- node[font=\small,label=above:5] {} (2); \path[draw,thick,-] (1) -- node[font=\small,label=left:3] {} (3); -\path[draw,thick,-] (3) -- node[font=\small,label=below:$-2$] {} (4); +\path[draw,thick,-] (3) -- node[font=\small,label=below:1] {} (4); \path[draw,thick,-] (2) -- node[font=\small,label=left:3] {} (4); -\path[draw,thick,-] (2) -- node[font=\small,label=above:5] {} (5); +\path[draw,thick,-] (2) -- node[font=\small,label=above:2] {} (5); \path[draw,thick,-] (4) -- node[font=\small,label=below:2] {} (5); \path[draw,thick,-] (1) -- node[font=\small,label=above:7] {} (4); \end{tikzpicture} @@ -82,15 +82,15 @@ First, all edges from node 1 reduce distances: \node[draw, circle] (4) at (4,1) {4}; \node[draw, circle] (5) at (6,2) {5}; \node[color=red] at (1,3+0.55) {$0$}; -\node[color=red] at (4,3+0.55) {$2$}; +\node[color=red] at (4,3+0.55) {$5$}; \node[color=red] at (1,1-0.55) {$3$}; \node[color=red] at (4,1-0.55) {$7$}; \node[color=red] at (6,2-0.55) {$\infty$}; -\path[draw,thick,-] (1) -- node[font=\small,label=above:2] {} (2); +\path[draw,thick,-] (1) -- node[font=\small,label=above:5] {} (2); \path[draw,thick,-] (1) -- node[font=\small,label=left:3] {} (3); -\path[draw,thick,-] (3) -- node[font=\small,label=below:$-2$] {} (4); +\path[draw,thick,-] (3) -- node[font=\small,label=below:1] {} (4); \path[draw,thick,-] (2) -- node[font=\small,label=left:3] {} (4); -\path[draw,thick,-] (2) -- node[font=\small,label=above:5] {} (5); +\path[draw,thick,-] (2) -- node[font=\small,label=above:2] {} (5); \path[draw,thick,-] (4) -- node[font=\small,label=below:2] {} (5); \path[draw,thick,-] (1) -- node[font=\small,label=above:7] {} (4); @@ -110,15 +110,15 @@ reduce distances: \node[draw, circle] (4) at (4,1) {4}; \node[draw, circle] (5) at (6,2) {5}; \node[color=red] at (1,3+0.55) {$0$}; -\node[color=red] at (4,3+0.55) {$2$}; +\node[color=red] at (4,3+0.55) {$5$}; \node[color=red] at (1,1-0.55) {$3$}; -\node[color=red] at (4,1-0.55) {$1$}; +\node[color=red] at (4,1-0.55) {$4$}; \node[color=red] at (6,2-0.55) {$7$}; -\path[draw,thick,-] (1) -- node[font=\small,label=above:2] {} (2); +\path[draw,thick,-] (1) -- node[font=\small,label=above:5] {} (2); \path[draw,thick,-] (1) -- node[font=\small,label=left:3] {} (3); -\path[draw,thick,-] (3) -- node[font=\small,label=below:$-2$] {} (4); +\path[draw,thick,-] (3) -- node[font=\small,label=below:1] {} (4); \path[draw,thick,-] (2) -- node[font=\small,label=left:3] {} (4); -\path[draw,thick,-] (2) -- node[font=\small,label=above:5] {} (5); +\path[draw,thick,-] (2) -- node[font=\small,label=above:2] {} (5); \path[draw,thick,-] (4) -- node[font=\small,label=below:2] {} (5); \path[draw,thick,-] (1) -- node[font=\small,label=above:7] {} (4); @@ -135,15 +135,15 @@ Finally, there is one more change: \node[draw, circle] (4) at (4,1) {4}; \node[draw, circle] (5) at (6,2) {5}; \node[color=red] at (1,3+0.55) {$0$}; -\node[color=red] at (4,3+0.55) {$2$}; +\node[color=red] at (4,3+0.55) {$5$}; \node[color=red] at (1,1-0.55) {$3$}; -\node[color=red] at (4,1-0.55) {$1$}; -\node[color=red] at (6,2-0.55) {$3$}; -\path[draw,thick,-] (1) -- node[font=\small,label=above:2] {} (2); +\node[color=red] at (4,1-0.55) {$4$}; +\node[color=red] at (6,2-0.55) {$6$}; +\path[draw,thick,-] (1) -- node[font=\small,label=above:5] {} (2); \path[draw,thick,-] (1) -- node[font=\small,label=left:3] {} (3); -\path[draw,thick,-] (3) -- node[font=\small,label=below:$-2$] {} (4); +\path[draw,thick,-] (3) -- node[font=\small,label=below:1] {} (4); \path[draw,thick,-] (2) -- node[font=\small,label=left:3] {} (4); -\path[draw,thick,-] (2) -- node[font=\small,label=above:5] {} (5); +\path[draw,thick,-] (2) -- node[font=\small,label=above:2] {} (5); \path[draw,thick,-] (4) -- node[font=\small,label=below:2] {} (5); \path[draw,thick,-] (1) -- node[font=\small,label=above:7] {} (4); @@ -169,15 +169,15 @@ the following path: \node[draw, circle] (4) at (4,1) {4}; \node[draw, circle] (5) at (6,2) {5}; \node[color=red] at (1,3+0.55) {$0$}; -\node[color=red] at (4,3+0.55) {$2$}; +\node[color=red] at (4,3+0.55) {$5$}; \node[color=red] at (1,1-0.55) {$3$}; -\node[color=red] at (4,1-0.55) {$1$}; -\node[color=red] at (6,2-0.55) {$3$}; -\path[draw,thick,-] (1) -- node[font=\small,label=above:2] {} (2); +\node[color=red] at (4,1-0.55) {$4$}; +\node[color=red] at (6,2-0.55) {$6$}; +\path[draw,thick,-] (1) -- node[font=\small,label=above:5] {} (2); \path[draw,thick,-] (1) -- node[font=\small,label=left:3] {} (3); -\path[draw,thick,-] (3) -- node[font=\small,label=below:$-2$] {} (4); +\path[draw,thick,-] (3) -- node[font=\small,label=below:1] {} (4); \path[draw,thick,-] (2) -- node[font=\small,label=left:3] {} (4); -\path[draw,thick,-] (2) -- node[font=\small,label=above:5] {} (5); +\path[draw,thick,-] (2) -- node[font=\small,label=above:2] {} (5); \path[draw,thick,-] (4) -- node[font=\small,label=below:2] {} (5); \path[draw,thick,-] (1) -- node[font=\small,label=above:7] {} (4);