                                         graph_slices[0]->edges * sizeof(VertexId),
                                         cudaMemcpyHostToDevice),
                                     "ProblemBase cudaMemcpy d_row_indices failed", __FILE__, __LINE__)) break;
+                        
+                        if (retval = util::GRError(cudaMalloc(
+                        (void**)&graph_slices[0]->d_in_degrees,
+                        (graph_slices[0]->nodes) * sizeof(SizeT)),
+                        "ProblemBase cudaMalloc d_in_degrees failed", __FILE__, __LINE__)) break;
+
+                        // count number of in-going degrees for each node
+                        util::MemsetMadVectorKernel<<<128, 128>>>(
+                                data_slices[0]->d_in_degrees,
+                                graph_slices[0]->d_column_offsets,
+                                &graph_slices[0]->d_column_offsets[1], -1, nodes);
                     }
 
                 } //end if(stream_from_host)

            if (d_column_indices)   util::GRError(cudaFree(d_column_indices), "GpuSlice cudaFree d_column_indices failed", __FILE__, __LINE__);
            if (d_column_offsets)   util::GRError(cudaFree(d_column_offsets), "GpuSlice cudaFree d_column_offsets failed", __FILE__, __LINE__);
            if (d_row_indices)      util::GRError(cudaFree(d_row_indices), "GpuSlice cudaFree d_row_indices failed", __FILE__, __LINE__);
            for (int i = 0; i < 2; ++i) {
                if (frontier_queues.d_keys[i])      util::GRError(cudaFree(frontier_queues.d_keys[i]), "GpuSlice cudaFree frontier_queues.d_keys failed", __FILE__, __LINE__);
                if (frontier_queues.d_values[i])    util::GRError(cudaFree(frontier_queues.d_values[i]), "GpuSlice cudaFree frontier_queues.d_values failed", __FILE__, __LINE__);

        VertexId        *d_column_indices;          // CSR format column indices on device memory
        SizeT           *d_column_offsets;          // CSR format column offset on device memory
        VertexId        *d_row_indices;             // CSR format row indices on device memory
        SizeT           *d_in_degrees;              // array that stores the In-degree value for directed graph
        SizeT           *d_out_degrees;             // array that stores the Out-degree value for directed graph and degree value for undirected graph

        //Frontier queues. Used to track working frontier.
        util::DoubleBuffer<VertexId, VertexId>      frontier_queues;
