Question

Can anyone point me to a good pseudocode of a simple parallel shortest path algorithm? Or any language, it doesn't matter. I'm having trouble finding good examples =[

Was it helpful?

Solution

I eventually implemented it myself for a bitcoin bot using OpenMP:

/*defines the chunk size as 1 contiguous iteration*/
#define CHUNKSIZE 1 
/*forks off the threads*/
#pragma omp parallel private(i) {
/*Starts the work sharing construct*/
#pragma omp for schedule(dynamic, CHUNKSIZE)
        list<list_node>::iterator i;
        for (int u = 0; u < V - 1; u++) {
            if (dist[u] != INT_MAX) {
                for (i = adj[u].begin(); i != adj[u].end(); ++i) {
                    if (dist[i->get_vertex()] > dist[u] + i->get_weight()) {
                        dist[i->get_vertex()] = dist[u] + i->get_weight();
                        pre[i->get_vertex()] = u;
                    }
                }
            }
        }
    }

If you want to look at my full implementation, you can view it as a Gist on my GitHub

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top