the error is Error: expression must have pointer to object type, this applies to every time I try to access dist or prev.
void GraphType::Dijkstra(string vertex, int& dist, int& prev)
{
for(int i = 0; i< numVertices; i++)//set dist and prev to infinite and undefined respectivly
{
dist[i] = INT_MAX;
prev[i] = -1;
}
int start = IndexIs(vertices, vertex); //get the index of the starting vertex
dist[start] = 0;
MarkVertex(vertex);//mark said starting vertex
priority_queue<int> Q;//set up priority queue
for(int i = 0; i<numVertices; i++)//for loop to add the vertices not vistited yet
{
if(marks[i] == false)
Q.push(i);
}
int u, newdist;
queue<int> while_queue;
while(Q.size() != 0)
{
u = Q.top();
MarkVertex( u);
GetToVertices(u, while_queue);
for(int v = 0; v<while_queue.size(); v++)
{
newdist = dist[u]+WeightIs(u,v);
if(newdist < dist[v])
{
dist[v] = newdist;
prev[v] = u;
Q.push(dist[v];
}
}
}
//ClearMarks();
}
This post has been edited by killermunk1: 17 June 2012 - 11:43 AM

New Topic/Question
Reply


MultiQuote




|