zjpjack/CUDA_BFS_ORIGIN — pull request #1 by myeu (2014-11-29 08:26:03+00:00)
Title: Fixing a bug

In the original code, a node could have its cost set at two levels, with the higher cost level setting the final cost. I saw this happening in my test data. Below is an excerpt from my debugging.

The visited array is supposed to make sure the cost is set only once. It doesn't control whether it's own edges are processed. Therefore, the visited boolean should be set at the same time as cost. Level will be true and on the next iteration that node will be processed to get its edges.

The change in the bfs.cu code is necessary because the starting node doesn't need to get its cost set in the kernel. So visited should be set to true at the same time as the cost, outside the kernel.

In my test data, Node 15152 is connected to the starting node, it should have cost = 2
Iteration Num: node id, visited, cost
1: 15152, 0, -1
2: 15152, 0, 2
3: 15152, 1, 4

Cost is set at Iteration 2, but visited is still false until the next iteration. Since it was false for a time, another node got to it and set its cost again, to 4.

I found your code to be extremely helpful. I wanted to be helpful in return by letting you know about the bug I found.