I implemented the Dijkstra's algorithm In C. I'm trying to compare the runtime with and without using OpenMP, but for some reason OpenMP is always slower. I read something about how expensive new threads are but expanding the graph does not solve it.
I would like to use omp here
#pragma omp parallel for
for(index=0; index<nodes[n].size; index++){
int ct = nodes[n].paths[index].connectsTo;
if(notVisited[ct]){
int dist = dis[n]+nodes[n].paths[index].weight;
if(dist<dis[ct]){
prev[ct] = n;
dis[ct] = dist;
}
}
}