Question: can you help me fix this syntax error, dont use vectors only dynamically allocated arrays. Also the function needs to be in the edge class
can you help me fix this syntax error, dont use vectors only dynamically allocated arrays. Also the function needs to be in the edge class provided according to instructions. Can you help me figure this out
dijkstra.h:
:
: error:
const class graph
has no member named
getNeighbor
for
const auto &edge : g
getNeighbor
u
vertexNum
void DijkstraShortestPath
const graph &g
int start
int numVertices
g
getNumVer
;
minHeap minHeap
numVertices
;
assuming minHeap can be constructed with the number of vertices
int
locator
new int
numVertices
;
Dynamic array for locator
Initialize all vertices
for
int i
; i
numVertices;
i
vertex ver;
ver.vertexNum
i;
ver.curDist
;
ver.predecessor
;
minHeap.insert
ver
;
locator
i
i;
Locator initialization
Update the start vertex in the heap
vertex startVertex
minHeapgetElem
locator
start
;
startVertex.curDist
;
minHeap.updateElem
locator
start
startVertex
;
Dijkstras algorithm main loop
while
minHeap.isEmpty
vertex u
minHeapgetMin
;
int uIndex
locator
u
vertexNum
;
for
const auto &edge : g
getNeighbor
u
vertexNum
int v
edgefirst;
int weight
edgesecond;
int vIndex
locator
v
;
if
u
curDist
weight
minHeapgetElem
vIndex
curDist
vertex vVertex
minHeapgetElem
vIndex
;
vVertex.curDist
u
curDist
weight;
vVertex.predecessor
u
vertexNum;
minHeap.updateElem
vIndex
vVertex
;
Clean up the dynamic array
delete
locator;
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
