V8031l71122252 takenextthingonlist7movetovand

Info iconThis preview shows page 1. Sign up to view the full content.

View Full Document Right Arrow Icon
This is the end of the preview. Sign up to access the rest of the document.

Unformatted text preview: ’s view” V = {8, 3, 7, 1, 2, 5} L = {4, 6} Take next thing on list (4), move to V, and put it’s neighbors on list if not in V or L yet V = {8, 3, 7, 1, 2, 5, 4} L = {6} Take next thing on list (6), move to V, and put it’s neighbors on list if not in V or L yet V = {8, 3, 7, 1, 2, 5, 4, 6} L = { } DONE Possible to keep track of “level” Li information as you go: Let’s see how. 1: 2,3 2: 1,3,4,5 3: 1,2,5,7,8 4: 2,5 5: 2,3,4,6 6: 5 7: 3,8 8: 3,7 9: 10 10: 9 11: 12 12: 11,13 13: 12 “Computer’s view” Mark 8 as “visited”; put 3 and 7 on the list V={80} L = {31,71} Take next thing on list (3), move to V, and put it’s neighbors on list if not in V or L yet. V = {80, 31} L = {71, 12, 22, 52} Take next thing on list (7), move to V, and put it’s neighbors on list if not in V or L yet V = {80, 31, 71} L = {12, 22, 52} 1: 2,3 2: 1,3,4,5 3: 1,2,5,7,8 4: 2,5 5: 2,3,4,6 6: 5 7: 3,8 8: 3,7 9: 10 10: 9 11: 12 12: 11,13 13: 12 “Computer’s view” V = {80, 31, 71} L = {12, 22, 52} Mark 1 as “visited”; no new neighbors V={80, 31, 71, 12} L = {22, 52} Take next thing on list (2), move to V, and put it’s neighbors on list if not in V or L yet. V = {80, 31, 71, 12, 22} L = {52, 43} Take next thing on list (5), move to V, and put it’s neighbors on list if not in V or L yet V = {80, 31, 71, 12, 22, 52} L = {43, 63} 1: 2,3 2: 1,3,4,5 3: 1,2,5,7,8 4: 2,5 5: 2,3,4,6 6: 5 7: 3,8 8: 3,7 9: 10 10: 9 11: 12 12: 11,13 13: 12 “Computer’s view” V = {80, 31, 71, 12, 22, 52} L = {43, 63} Take next thing on list (4), move to V, and put it’s neighbors on list if not in V or L yet V = {80, 31, 71, 12, 22, 52, 43} L = {63} Take next thing on list (6), move to V, and put it’s neighbors on list if not in V or L yet V = {80, 31, 71, 12, 22, 52, 43, 63} L = { } DONE Shortest paths to each vertex are shown 1: 2,3 2: 1,3,4,5 3: 1,2,5,7,8 4: 2,5 5: 2,3,4,6 6: 5 7: 3,8 8: 3,7 9: 10 10: 9 11: 12 12: 11,13 13: 12 Shortest Path Problem Shortest Path Problem Shortest path ne...
View Full Document

This document was uploaded on 04/02/2014.

Ask a homework question - tutors are online