Presentation is loading. Please wait.

Presentation is loading. Please wait.

Math 170 Project Part 3 By: Guadalupe Esquivel and Marlene Reyna.

Similar presentations


Presentation on theme: "Math 170 Project Part 3 By: Guadalupe Esquivel and Marlene Reyna."— Presentation transcript:

1 Math 170 Project Part 3 By: Guadalupe Esquivel and Marlene Reyna

2 10.7 #12 Use Dijkstra’s algorithm for the airline route system of Figure 10.7.3 to find the shortest distance from Nashville to Minneapolis. Make a table similar to Table 10.7.1 to show the action of the algorithm. N= Nashville S= St. Lous Lv.= Louisville Cn.= Cincinnati Ch.= Chicago D= Detroit Mw.= Milwaukee Mn.= Minneapolis

3 Step 1: Step 2: Initialize T to be the graph with vertex N= Nashville and no edges. Set L(N)= 0 since the shortest path from N to N has length 0. For the remaining vertices set them equal to ∞. Find the vertices adjacent to vertex N and choose the one with the smallest value. Vertices: Lv, Mn L(Lv)= 151 L(Mn)= 695 Since L(Lv) < L(Mn), Lv is added to V(T). Length of N _______ Starting point Ending Point

4 Step 3: Step:4 Find the vertices adjacent to vertices N and Lv and choose the one with the smallest value. Vertices: Mn, S, Cn, Ch, Mw, D L(Mn)= 695 L(S)=151+242=393 L(Cn)=151+83=234 L(Ch)=151+269=420 L(Mw)=151+348=499 L(D)=151+306=457 Since L(Cn) is less than the rest, Cn is added to V(T). Find the vertices adjacent to vertices N, Lv, and Cn and choose the one with the smallest value. Vertices: Mn, S, Ch, D, Mw L(Mn)=695 L(S)=151+242=393 L(Ch)=151+269=420 L(Mw)=151+348=499 L(D)=151+306=457 Since L(S) is less than the rest, S is added to V(T).

5 Step 5: Step 6: Find the vertices adjacent to vertices N, Lv, Cn, and S and choose the one with the smallest value. Vertices: Mn, Ch, D, Mw L(Mn)=695 L(Ch)=151+269=420 L(D)=151+306=457 L(Mw)=151+348=499 Since L(Ch) is less than the rest, Ch is added to V(T). Find the vertices adjacent to vertices N,Lv, Cn, S, and Ch and choose the one with the smallest value. Vertices: Mn, D, Mw L(Mw)=151+269+74=494 L(Mn)=695 L(D)=151+306=457 Since L(D) is less than the rest, D is added to V(T).

6 Step 7: Step 8: Find the vertices adjacent to vertices N, Lv, Cn, S, Ch, and D and choose the one with the smallest value. Vertices: Mn, Mw L(Mw)=151+269+74=494 L(Mn)=695 Since L(Mw) is less than the rest, Mw is added to V(T). Find the vertices adjacent to vertices N, Lv, Cn, S, Ch, D, and Mw and choose the one with the smallest value. L(Mn)=695 Mn is added to V(T). Starting point Ending Point

7 StepV(T) The set of vertices of T. E(T) The set of edges of T. F The vertices that are adjacent to at least 1 vertex. 1{N}empty set{N} 2 empty set{Lv,Mn} 3{N,Lv}{{N,Lv}}{Mn,S,Cn,Ch,D,M w} 4{N,Lv, Cn}{{N,Lv}, {Lv,Cn}}{Mn, S,Ch,D,Mw} 5{N,Lv, Cn,S}{{N,Lv}, {Lv,Cn}, {Lv,S}}{Mn,Ch,D,Mw} 6{N,Lv, Cn,S, Ch}{{N,Lv}, {Lv,Cn}, {Lv,S}, {Lv,Ch}}{Mn,D,Mw} 7{N,Lv, Cn,S, Ch, D}{{N,Lv}, {Lv,Cn}, {Lv,S}, {Lv,Ch}, {Lv,D}}{Mn,Mw} 8{N,Lv, Cn,S, Ch, D, Mw}{{N,Lv}, {Lv,Cn}, {Lv,S}, {Lv,Ch}, {Lv,D}, {Ch,Mw}}{Mn} 9{N,Lv, Cn,S, Ch, D, Mw, Mn}

8 Thus, the shortest path from Nashville to Minneapolis has length L(Mn)= 695 miles. StepL(N) Nashville L(S) St. Louis L(Lv) Louisville L(Cn) Cincinnati L(Ch) Chicago L(D) Detroit L(Mw) Milwaukee L(Mn) Minneapolis 10 ∞∞∞∞∞∞∞ 20 ∞ 151 ∞∞∞∞ 695 30393151234420457499695 40393151234420457499695 50393151234420457499695 603931512342457494695 70393151234420457494695 80393151234420457494695

9 10.7 #14 Use Dijkstra’s algorithm to find the shortest path from a to z for the graph. Make a table similar to Table 10.7.1 to show the action of the algorithm a b f c e z g d 1 1 8 7 1 1 1 20 4 1

10 0 a f ∞ c ∞ e ∞ z ∞ g ∞ d ∞ 1 1 8 7 1 1 1 20 4 1 Start with vertex a and set its distance to equal to 0 and the rest as ∞ b ∞ 0 a f ∞ c ∞ e ∞ z ∞ g ∞ d ∞ 1 1 8 7 1 1 1 20 4 1b ∞ Next, choose the vertex with the smallest distance value and remove it from the graph, and calculate the value from that vertex to the adjacent vertices and leave the smaller value 1 4

11 0 a f ∞ c ∞ e z ∞ g ∞ d ∞ 1 1 8 7 1 1 1 20 4 1b 1 4 Now choose the vertex with the next smallest value, remove it and calculate the new values for the adjacent vertices 2 8 0 a f c e z ∞ g 10 d 3 1 1 8 7 1 1 1 20 4 1b 1 4 2 8 Repeat until you have chosen vertex z ∞ ∞

12 0 a f c e z ∞ g 10 d 3d 3 1 1 8 7 1 1 1 20 4 1b 1 4 2 8 0a0a f 8 5 c e z g 10 d 3d 3 1 1 8 7 1 1 1 20 4 1b 1 4 2 23 0a0a f 5f 5 c e z g 10 d 3d 3 1 1 8 7 1 1 1 20 4 1b 1 4 2 6 23 0a0a f 5f 5 c e z g d 3d 3 1 1 87 1 1 1 20 4 1b 1 4 2 6 23 7

13 0a0a f 5f 5 c e z g d 3d 3 1 1 8 7 1 1 1 20 4 1b 1 4 2 6 7 The last vertex left is vertex z, the end point. The 7 represents the smallest weighted path there is from vertex a vertex z.

14 StepV(T)E(T)FL(a)L(b)L(c)L(d)L(e)L(f)L(g)L(z) 0 {a} ∅ 0 ∞∞∞∞∞∞∞ 1 ∅ {b,e}01 ∞∞ 4 ∞∞∞ 2 {a,b}{{a,b}}{c,e,f}012 ∞ 48 ∞∞ 3 {a,b,c}{{a,b},{b,c}}{d,e,f,g}01234810 ∞ 4 {a,b,c,d}{{a,b},{b,c},{c,d}}{e,f,g,z}0123481023 5 {a,b,c,d,e}{{a,b},{b,c},{c,d},{a,e}}{f,g,z}0123451023 6 {a,b,c,d,e,f}{{a,b},{b,c},{c,d},{a,e}, {e,f}} {g,z}012345623 7 {a,b,c,d,e,f,g}{{a,b},{b,c},{c,d},{a,e}, {e,f},{f,g}} {z}01234567 8 {a,b,c,d,e,f,g,z}{{a,b},{b,c},{c,d},{a,e}, {e,f},{f,g},{g,z}}


Download ppt "Math 170 Project Part 3 By: Guadalupe Esquivel and Marlene Reyna."

Similar presentations


Ads by Google