# Single Source Shortest Path

In the lecture we are taught that we can solve All Pairs
Shortest Path(APSP)
with matrix
multiplication
.

In APSP we are creating a distance table for all the distances
between each nodes in the graph. And now the question is "Is it
possible to solve Single Source Shortest Path(SSSP)
problem with matrix multiplication? If it is, then
how?"

If you give me an explanation how to accomplish this I would
appreciate.

 Giraph Shortest Path Examples I have problem running the given example SimpleShortestPathsComputation with the tiny_graph.txt. I always get stuck at the process of Reduce Part after the Map part. It always shows me 100% maps and 0% reduced and hangs there all the time. Having a hard time looking for solutions in the Web. Does anyone has come across this problem? By the way, my hadoop version is 1.2.1 while giraph is 1.1.0. Thank you! Web Development Why is the second CUDA kernel needed for computing the single source shortest path? I have implemented single source shortest path algorithm on CUDA by referring to a research paper. There are two kernels as follows ``````__global__ void SSSP_kernel_1(Node* d_node, int* d_edges, int *d_weights, bool* d_mask, int* d_cost, int *d_costU, unsigned long long no_of_nodes) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if(tid < no_of_nodes && d_mask[tid]) { d_mask[tid] = false; for(int i = d_node[tid].start; i < (d_node[tid].start + d_node[tid].num); i++) { int id = d_edges[i]; if(d_costU[id] > (d_cost[tid] + d_weights[i])) d_costU[id] = d_cost[tid] + d_weights[i]; } } `````` } ``````__global__ void SSSP_kernel_2(Node* d_node, int* d_edges, int *d_weights, bool* d_mask, int* d_cost, int *d_costU, unsigned long long no_of_nodes, bool *d_stop) { int tid = blockIdx.x * blockDim.x + threadIdx.x; if(tid < no_of_nodes) { if(d_cost[tid] > d_costU[tid]) { d_cost[tid] = d_costU[tid]; d_mask[tid] = true; *d_stop = false; } d_costU[tid] = d_cost[tid]; } `````` } The cost is computed using an intermediate array and a second kernel is launched to update the cost values. The authors say " Updating the cost at the time of modification itself can result in read after write inconsistencies." But I fail to see why. Even if there is read after write, I would be updating (line 8, kernel 1) only the least value which is what is anyway needed. What am I missing here? Thank you for your time Web Development Shortest path calculation from source to destination I am trying to implement BFS in graph, found the following code and wondering how to include distance to each vertex using this below implementation. My idea is to calculate the shortest distance for unweighted graph.... Here is the code I am following: ``````#include #include #include #include using namespace std; class Graph { int V; // No. of vertices list *adj; // Pointl;er to an array containing adjacency lists std::queue queue1; public: Graph(int V); // Constructor ~Graph() { delete[] adj; } //Destructor void addEdge(int v, int w); // function to add an edge to graph bool isReachable(int s, int d); // returns true if there is a path from s to d }; Graph::Graph(int V) { this->V = V; adj = new list[V]; } void Graph::addEdge(int v, int w) { adj[v].push_back(w); // Add w to v’s list. } bool Graph::isReachable(int s, int d) { // Base case if (s == d) return true; // Mark all the vertices as not visited bool *visited = new bool[V]; for (int i = 0; i < V; i++) visited[i] = false; // Create a queue for BFS list queue; // Mark the current node as visited and enqueue it visited[s] = true; queue.push_back(s); queue1.push(s); // it will be used to get all adjacent vertices of a vertex list::iterator i; while (!queue.empty()) { // Dequeue a vertex from queue and print it s = queue.front(); queue.pop_front(); // Get all adjacent vertices of the dequeued vertex s // If a adjacent has not been visited, then mark it visited // and enqueue it for (i = adj[s].begin(); i != adj[s].end(); ++i) { // If this adjacent node is the destination node, then return true if (*i == d) { queue1.push(*i); return true; } // Else, continue to do BFS if (!visited[*i]) { visited[*i] = true; queue.push_back(*i); queue1.push(*i); } } } return false; } int main() { // Create a graph given in the above diagram inputtouser(); Graph g(24); g.addEdge(1, 2); g.addEdge(2, 3); g.addEdge(3, 4); g.addEdge(4, 5); g.addEdge(5, 6); g.addEdge(6, 7); g.addEdge(7, 8); g.addEdge(8, 9); g.addEdge(9, 10); g.addEdge(10, 11); g.addEdge(11, 12); g.addEdge(12, 13); g.addEdge(13, 14); g.addEdge(14, 15); g.addEdge(15, 16); g.addEdge(8, 17); g.addEdge(17, 18); g.addEdge(18, 19); g.addEdge(19, 20); g.addEdge(20, 21); g.addEdge(21, 22); g.addEdge(22, 23); g.addEdge(23, 16); int u = 0; int v = 0; cout << "Please enter the source area code: "; cin >> u; cout << "Please enter the destination area code: "; cin >> v; if (g.isReachable(u, v)) cout << " There is a path from " << u << " to " << v < 180) angle = 360 - angle; return angle; }; trace(getShortAngle(360, 720)); `````` Or in Smallbasic: ``````Sub GetShortestpath angle = Math.Remainder((Math.abs(a1 - a2)),360) if angle > 180 Then angle = 360 - angle EndIf Return = angle EndSub `````` Thanks for any help! Web Development Text object to Path: how to remove a single path from a double path produced when you use print method in Raphael js using cambam fonts? When I use the print method on Raphael js to convert text to path it produces a double path(an outline) of each character. I have searched on line and noticed that there are some fonts like: href="http://www.mrrace.com/CamBam_Fonts/" rel="nofollow">camBam fonts that seem to be true type fonts but they actually are tricking the font creators to see them as outline of a characters while they are putting 2 same lines on top of each other. I was wondering If there is any way to programmatically (using js) split those lines(paths) on top of each other and remove one of them? Here is the svg code to an svg file that contains paths that are on top of each other and are the same for letter s (for example) : `````` `````` And if you manipulated it manually in inkscape or illustrator you can see that the letter s has 2 lines on top of each other that makes up that letter: How can I remove one of the 2 lines(paths) using js? And if I have a whole text that has been converted to paths similar to the s character, how can I apply that removal function to all the text to make it single paths texts? Any ideas would be greatly appreciated Web Development Single Source Shortest Path In the lecture we are taught that we can solve All Pairs Shortest Path(APSP) with matrix multiplication. In APSP we are creating a distance table for all the distances between each nodes in the graph. And now the question is "Is it possible to solve Single Source Shortest Path(SSSP) problem with matrix multiplication? If it is, then how?" If you give me an explanation how to accomplish this I would appreciate. Programming Languages

 - Technology - Languages + Webmasters + Development + Development Tools + Internet + Mobile Programming + Linux + Unix + Apple + Ubuntu + Mobile & Tablets + Databases + Android + Network & Servers + Operating Systems + Coding + Design Software + Web Development + Game Development + Access + Excel + Web Design + Web Hosting + Web Site Reviews + Domain Name + Information Security + Software + Computers + Electronics + Hardware + Windows + PHP + ASP/ASP.Net + C/C++/C# + VB/VB.Net + JAVA + Javascript + Programming