                            e * sizeof(Value));
             }
             fout.close();
+        }
+    }
+
+    void WriteCSR(char *file_name,
+                  SizeT v, SizeT e,
+                  SizeT    *row_offsets,
+                  VertexId *col_indices,
+                  Value    *edge_values = NULL) {
+        std::cout << file_name << std::endl;
+        char rows[256], cols[256], vals[256];
+
+        sprintf(rows, "%s.rows", file_name);
+        sprintf(cols, "%s.cols", file_name);
+        sprintf(vals, "%s.vals", file_name);
+
+        std::ofstream rows_output(rows);
+        if (rows_output.is_open()) {
+            std::copy(row_offsets, row_offsets + v + 1,
+                std::ostream_iterator<SizeT>(rows_output, "\n"));
+            rows_output.close();
+        }
+
+        std::ofstream cols_output(cols);
+        if (cols_output.is_open()) {
+            std::copy(col_indices, col_indices + e,
+                std::ostream_iterator<VertexId>(cols_output, "\n"));
+            cols_output.close();
+        }
+
+        if (edge_values != NULL) {
+            std::ofstream vals_output(vals);
+            if (vals_output.is_open()) {
+                std::copy(edge_values, edge_values + e,
+                    std::ostream_iterator<Value>(vals_output, "\n"));
+                vals_output.close();
+            }
         }
     }
 

                    printf(",");
                    util::PrintValue(edge_values[j]);
                }
            }   
            printf(")\n");
        }   
    
        /*if (edge_values != NULL)
        {   
            printf("\n edge_values = ");
            for (SizeT i=0;i<displayed_node_num;i++)
            {   
                printf("(");
                for (SizeT j=row_offsets[i];j<row_offsets[i+1];j++)
                {   
                    if (j!=row_offsets[i]) printf(", ");
                    util::PrintValue(edge_values[j]);
                }   
                printf(") ");
            }   
        }*/   

        printf("\n");
    }   

    bool CheckValue()
    {

        }
    }

    void DisplayGraph(const char name[], SizeT limit = 40)
    {
        SizeT displayed_node_num = (nodes > limit) ? limit: nodes;
        printf("%s : #nodes = ",name); util::PrintValue(nodes);
        printf(", #edges = "); util::PrintValue(edges);
        //printf("\n  row_offsets = ");
        printf("\n");
        /*for (SizeT i=0;i<=displayed_node_num;i++)
        {
            if (i!=0) printf(", ");
            util::PrintValue(row_offsets[i]);
        }

        if (node_values != NULL)
        {
            printf("\n  node_values = ");
            for (SizeT i=0;i<displayed_node_num;i++)
            {
                if (i!=0) printf(", ");
                util::PrintValue(node_values[i]);
            }
        }*/

        //printf("\n  edges = ");
        for (SizeT i=0;i<displayed_node_num;i++)
        {
            util::PrintValue(i);
            printf(",");
            util::PrintValue(row_offsets[i]);
