The BFS code

1
2
3
4
5
6
7
8
__global__ void
initialize_vertices( Vertex * vertices,
                    int starting_vertex,
                    int num_vertices )
{
    int v = blockDim.x * blockIdx.x + threadIdx.x;
    if (v == starting_vertex) vertices[v] = 0 else vertices[v] = -1;
}