So lets say I created a graph with vector<vector<Path> >aPath, where path contains
1 2 3 4 5 6 7 8
struct Path{
Path(float num1, float num2): direction(num1), weight(num2), taken(false) { }
bool taken;
float direction; // The vertex that it goes to
float weight; // The number of the edge
};
I'm having trouble figuring out how to implement Dijkstra. I've been looking at pseudocode and this is what I have so far.
1 2 3 4 5 6 7 8 9 10 11 12
void dijkstra(vector<vector<Path> > aGraph, int start){
float min = std::numeric_limits<double>::infinity();
vector<vector<Path> > v = aGraph;
distance.resize(aGraph[start-1].size());
// Sets the weight of the edges to infinity
for(int graphIndex = 0; graphIndex < v.size(); graphIndex++){
for(int innerVector = 0; innerVector < v[graphIndex].size(); innerVector++){
v[graphIndex][innerVector].weight = min;
}
}
I know I have to check weights and change to boolean to true if it has checked the vertex, but I'm lost. Any guidance would help!