Impelementasi Implementasi Algoritma Dijkstra

b return 0; return a b ? -1 : 1; } } v0 = new vertex0; v1 = new vertex1; v2 = new vertex2; v3 = new vertex3; v4 = new vertex4; v5 = new vertex5; v6 = new vertex6; v7 = new vertex7; v8 = new vertex8; list0 = new SplDoublyLinkedList; list0-pusharrayvertex = v1, distance = 3; list0-pusharrayvertex = v3, distance = 1; list0-rewind; list1 = new SplDoublyLinkedList; list1-pusharrayvertex = v0, distance = 3; list1-pusharrayvertex = v2, distance = 7; list1-rewind; list2 = new SplDoublyLinkedList; list2-pusharrayvertex = v1, distance = 7; list2-pusharrayvertex = v3, distance = 8; list2-pusharrayvertex = v4, distance = 12; list2-rewind; list3 = new SplDoublyLinkedList; list3-pusharrayvertex = v0, distance = 1; list3-pusharrayvertex = v2, distance = 8; list3-rewind; list4 = new SplDoublyLinkedList; list4-pusharrayvertex = v2, distance = 12; list4-pusharrayvertex = v5, distance = 3; list4-rewind; list5 = new SplDoublyLinkedList; list5-pusharrayvertex = v4, distance = 3; list5-rewind; list6 = new SplDoublyLinkedList; list6-pusharrayvertex = v6, distance = 10; list6-rewind; list7 = new SplDoublyLinkedList; list7-pusharrayvertex = v7, distance = 15; list7-rewind; adjacencyList = array list0, list1, list2, list3, list4, list5, list6, list7 ; function calcShortestPathsvertex start, adjLists{ define an empty queue q = new PriorityQueue; push the starting vertex into the queue q-insertstart, 0; q-rewind; mark the distance to it 0 start-distance = 0; the path to the starting vertex start-path = arraystart-key; while q-valid{ t = q-extract; t-visited = 1; l = adjLists[t-key]; while l-valid{ item = l-current; if item[vertex]-visited{ if item[vertex]-distance t-distance + item[distance]{ item[vertex]-distance = t-distance + item[distance]; item[vertex]-parent = t; } item[vertex]-path = array_merget-path, arrayitem[vertex]-key; q-insertitem[vertex], item[vertex]-distance; } l-next; } q-recoverFromCorruption; q-rewind; } } calcShortestPathsv0, adjacencyList; The path from node 0 to node 5 [0, 1, 2, 4, 5] Array [0] = -2 [1] = -2 [2] = INFINITY [3] = -2 [4] = -2 echo [.implode, , v5-path.]; ?

4.3 Tampilan Sistem Informasi Geografis