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.

Related to : Single Source Shortest Path

Giraph Shortest Path Examples 
Programming Languages 

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!

Why is the second CUDA kernel needed for computing the single source shortest path? 
Programming Languages 

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

Shortest path calculation from source to destination 
Programming Languages 

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<iostream>
#include <list>
#include <queue>
#include <iomanip>
using namespace std;
class Graph
{
int V; // No. of vertices
list<int> *adj; // Pointl;er to an array containing adjacency
lists
std::queue<int> 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<int>[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<int> 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<int>::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
<<endl;
else
cout << "
There is no path from " << u << " to " << v
<<endl;
cout << "This is the suggestion given to you" << endl;
return 0;
}

Getting the shortest angle path 
Programming Languages 

I need to get the shortest direction between two angles. Like if
Ang1 is 5 and Ang2 is 355 then I want it to return that I need to
subtract from Ang1 to get to Ang2 .
I have some code that will tell me the shortest distance, but not
the shortest direction.
function getShortAngle(a1, a2)
{
var angle = (Math.abs(a1  a2))%360;
if(angle > 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!

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? 
Programming Languages 

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: 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) :
<svg height="100%" version="1.1" width="100%"
xmlns="http://www.w3.org/2000/svg" viewBox="0, 0,
600,600"><desc>Created with
Snap</desc><defs></defs><path
d="M24.06033444444444,57.3853C27.382556666666662,57.00196666666667,31.727001111111107,58.53530000000001,31.727001111111107,54.57418888888889C31.727001111111107,50.22974444444445,25.08255666666666,52.52974444444445,24.315889999999996,49.079744444444444C24.571445555555552,46.524188888888894,31.727001111111107,46.396411111111114,31.727001111111107,49.59085555555556C31.727001111111107,49.59085555555556,31.727001111111107,46.90752222222223,31.727001111111107,46.90752222222223C29.043667777777774,47.67418888888889,24.06033444444444,45.374188888888895,24.06033444444444,49.079744444444444C24.06033444444444,53.16863333333334,31.215889999999995,50.868633333333335,31.215889999999995,54.57418888888889C31.215889999999995,57.51307777777778,24.315889999999996,57.896411111111114,24.06033444444444,54.57418888888889C24.06033444444444,54.57418888888889,24.06033444444444,57.3853,24.06033444444444,57.3853C24.06033444444444,57.3853,24.06033444444444,57.3853,24.06033444444444,57.3853"
fill="none" stroke="#0000ff"></path></svg>
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

Single Source Shortest Path 
Programming Languages 

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.



