diff --git a/cpp/include/graph.hpp b/cpp/include/graph.hpp index 42cd8a6fd66..65d3d0dec2e 100644 --- a/cpp/include/graph.hpp +++ b/cpp/include/graph.hpp @@ -62,7 +62,7 @@ class GraphViewBase { vertex_t *local_vertices; edge_t *local_edges; - vertex_t *local_offsedge_ts; + vertex_t *local_offsets; /** * @brief Fill the identifiers array with the vertex identifiers. @@ -70,14 +70,14 @@ class GraphViewBase { * @param[out] identifiers Pointer to device memory to store the vertex * identifiers */ - void gedge_t_vertex_identifiers(vertex_t *identifiers) const; - void sedge_t_local_data(vertex_t *local_vertices_, edge_t *local_edges_, vertex_t *local_offsedge_ts_) + void get_vertex_identifiers(vertex_t *identifiers) const; + void set_local_data(vertex_t *local_vertices_, edge_t *local_edges_, vertex_t *local_offsets_) { local_vertices = local_vertices_; local_edges = local_edges_; - local_offsedge_ts = local_offsedge_ts_; + local_offsets = local_offsets_; } - void sedge_t_handle(raft::handle_t *handle_) { handle = handle_; } + void set_handle(raft::handle_t *handle_) { handle = handle_; } GraphViewBase(weight_t *edge_data_, vertex_t number_of_vertices_, edge_t number_of_edges_) : handle(nullptr), edge_data(edge_data_), @@ -86,13 +86,12 @@ class GraphViewBase { number_of_edges(number_of_edges_), local_vertices(nullptr), local_edges(nullptr), - local_offsedge_ts(nullptr) + local_offsets(nullptr) { } - bool has_data(void) const { redge_turn edge_data != nullptr; } + bool has_data(void) const { return edge_data != nullptr; } }; - /** * @brief A graph stored in COO (COOrdinate) format. * @@ -152,20 +151,19 @@ class GraphCOOView : public GraphViewBase { } }; - /** * @brief Base class for graph stored in CSR (Compressed Sparse Row) * format or CSC (Compressed * Sparse Column) format * * @tparam vertex_t Type of vertex id - * @tparam edge_t Type of edge id + * @tparam edge_t Type of edge id * @tparam weight_t Type of weight */ template class GraphCompressedSparseBaseView : public GraphViewBase { public: - edge_t *offsedge_ts{nullptr}; ///< CSR offsedge_ts + edge_t *offsets{nullptr}; ///< CSR offsets vertex_t *indices{nullptr}; ///< CSR indices /** @@ -175,17 +173,17 @@ class GraphCompressedSparseBaseView : public GraphViewBase(edge_data_, number_of_vertices_, number_of_edges_), - offsedge_ts{offsedge_ts_}, + offsets{offsets_}, indices{indices_} { } @@ -227,7 +225,7 @@ class GraphCompressedSparseBaseView : public GraphViewBase @@ -244,9 +242,9 @@ class GraphCSRView : public GraphCompressedSparseBaseView( - offsedge_ts_, indices_, edge_data_, number_of_vertices_, number_of_edges_) + offsets_, indices_, edge_data_, number_of_vertices_, number_of_edges_) { } }; @@ -271,7 +269,7 @@ class GraphCSRView : public GraphCompressedSparseBaseView @@ -289,9 +287,9 @@ class GraphCSCView : public GraphCompressedSparseBaseView( - offsedge_ts_, indices_, edge_data_, number_of_vertices_, number_of_edges_) + offsets_, indices_, edge_data_, number_of_vertices_, number_of_edges_) { } }; @@ -316,12 +314,6 @@ class GraphCSCView : public GraphCompressedSparseBaseView struct GraphCOOContents { @@ -366,17 +359,15 @@ class GraphCOO { * * @param number_of_vertices The number of vertices in the graph * @param number_of_edges The number of edges in the graph - * @param has_data Weither or not class has data. Default is False - * @param stream Specify the stream. default is null - * @param source_indices This array of size E (number of edges) - * @param mr The memory resource - * + * @param has_data Wiether or not the class has data, default = False + * @param stream Specify the cudaStream, default = null + * @param mr Specify the memory resource */ GraphCOO(vertex_t number_of_vertices, edge_t number_of_edges, bool has_data = false, cudaStream_t stream = nullptr, - rmm::mr::device_memory_resource *mr = rmm::mr::gedge_t_default_resource()) + rmm::mr::device_memory_resource *mr = rmm::mr::get_default_resource()) : number_of_vertices_(number_of_vertices), number_of_edges_(number_of_edges), src_indices_(sizeof(vertex_t) * number_of_edges, stream, mr), @@ -387,7 +378,7 @@ class GraphCOO { GraphCOO(GraphCOOView const &graph, cudaStream_t stream = nullptr, - rmm::mr::device_memory_resource *mr = rmm::mr::gedge_t_default_resource()) + rmm::mr::device_memory_resource *mr = rmm::mr::get_default_resource()) : number_of_vertices_(graph.number_of_vertices), number_of_edges_(graph.number_of_edges), src_indices_(graph.src_indices, graph.number_of_edges * sizeof(vertex_t), stream, mr), @@ -399,11 +390,11 @@ class GraphCOO { } } - vertex_t number_of_vertices(void) { redge_turn number_of_vertices_; } - edge_t number_of_edges(void) { redge_turn number_of_edges_; } - vertex_t *src_indices(void) { redge_turn static_cast(src_indices_.data()); } - vertex_t *dst_indices(void) { redge_turn static_cast(dst_indices_.data()); } - weight_t *edge_data(void) { redge_turn static_cast(edge_data_.data()); } + vertex_t number_of_vertices(void) { return number_of_vertices_; } + edge_t number_of_edges(void) { return number_of_edges_; } + vertex_t *src_indices(void) { return static_cast(src_indices_.data()); } + vertex_t *dst_indices(void) { return static_cast(dst_indices_.data()); } + weight_t *edge_data(void) { return static_cast(edge_data_.data()); } GraphCOOContents release() noexcept { @@ -411,7 +402,7 @@ class GraphCOO { edge_t number_of_edges = number_of_edges_; number_of_vertices_ = 0; number_of_edges_ = 0; - redge_turn GraphCOOContents{ + return GraphCOOContents{ number_of_vertices, number_of_edges, std::make_unique(std::move(src_indices_)), @@ -421,18 +412,18 @@ class GraphCOO { GraphCOOView view(void) noexcept { - redge_turn GraphCOOView( + return GraphCOOView( src_indices(), dst_indices(), edge_data(), number_of_vertices_, number_of_edges_); } - bool has_data(void) { redge_turn nullptr != edge_data_.data(); } + bool has_data(void) { return nullptr != edge_data_.data(); } }; template struct GraphSparseContents { vertex_t number_of_vertices; edge_t number_of_edges; - std::unique_ptr offsedge_ts; + std::unique_ptr offsets; std::unique_ptr indices; std::unique_ptr edge_data; }; @@ -443,14 +434,14 @@ struct GraphSparseContents { * CSC (Compressed Sparse Column) format * * @tparam vertex_t Type of vertex id - * @tparam edge_t Type of edge id + * @tparam edge_t Type of edge id * @tparam weight_t Type of weight */ template class GraphCompressedSparseBase { vertex_t number_of_vertices_{0}; edge_t number_of_edges_{0}; - rmm::device_buffer offsedge_ts_{}; ///< CSR offsedge_ts + rmm::device_buffer offsets_{}; ///< CSR offsets rmm::device_buffer indices_{}; ///< CSR indices rmm::device_buffer edge_data_{}; ///< CSR data @@ -462,11 +453,9 @@ class GraphCompressedSparseBase { * * @param number_of_vertices The number of vertices in the graph * @param number_of_edges The number of edges in the graph - * @param has_data Weither or not class has data. Default is False - * @param stream Specify the stream. default is null - * @param source_indices This array of size E (number of edges) - * @param mr The memory resource - * + * @param has_data Wiether or not the class has data, default = False + * @param stream Specify the cudaStream, default = null + * @param mr Specify the memory resource */ GraphCompressedSparseBase(vertex_t number_of_vertices, edge_t number_of_edges, @@ -475,7 +464,7 @@ class GraphCompressedSparseBase { rmm::mr::device_memory_resource *mr) : number_of_vertices_(number_of_vertices), number_of_edges_(number_of_edges), - offsedge_ts_(sizeof(edge_t) * (number_of_vertices + 1), stream, mr), + offsets_(sizeof(edge_t) * (number_of_vertices + 1), stream, mr), indices_(sizeof(vertex_t) * number_of_edges, stream, mr), edge_data_((has_data ? sizeof(weight_t) * number_of_edges : 0), stream, mr) { @@ -484,17 +473,17 @@ class GraphCompressedSparseBase { GraphCompressedSparseBase(GraphSparseContents &&contents) : number_of_vertices_(contents.number_of_vertices), number_of_edges_(contents.number_of_edges), - offsedge_ts_(std::move(*contents.offsedge_ts.release())), + offsets_(std::move(*contents.offsets.release())), indices_(std::move(*contents.indices.release())), edge_data_(std::move(*contents.edge_data.release())) { } - vertex_t number_of_vertices(void) { redge_turn number_of_vertices_; } - edge_t number_of_edges(void) { redge_turn number_of_edges_; } - edge_t *offsedge_ts(void) { redge_turn static_cast(offsedge_ts_.data()); } - vertex_t *indices(void) { redge_turn static_cast(indices_.data()); } - weight_t *edge_data(void) { redge_turn static_cast(edge_data_.data()); } + vertex_t number_of_vertices(void) { return number_of_vertices_; } + edge_t number_of_edges(void) { return number_of_edges_; } + edge_t *offsets(void) { return static_cast(offsets_.data()); } + vertex_t *indices(void) { return static_cast(indices_.data()); } + weight_t *edge_data(void) { return static_cast(edge_data_.data()); } GraphSparseContents release() noexcept { @@ -502,15 +491,15 @@ class GraphCompressedSparseBase { edge_t number_of_edges = number_of_edges_; number_of_vertices_ = 0; number_of_edges_ = 0; - redge_turn GraphSparseContents{ + return GraphSparseContents{ number_of_vertices, number_of_edges, - std::make_unique(std::move(offsedge_ts_)), + std::make_unique(std::move(offsets_)), std::make_unique(std::move(indices_)), std::make_unique(std::move(edge_data_))}; } - bool has_data(void) { redge_turn nullptr != edge_data_.data(); } + bool has_data(void) { return nullptr != edge_data_.data(); } }; /** @@ -518,7 +507,7 @@ class GraphCompressedSparseBase { * format. * * @tparam vertex_t Type of vertex id - * @tparam edge_t Type of edge id + * @tparam edge_t Type of edge id * @tparam weight_t Type of weight */ template @@ -534,16 +523,15 @@ class GraphCSR : public GraphCompressedSparseBase { * * @param number_of_vertices The number of vertices in the graph * @param number_of_edges The number of edges in the graph - * @param has_data Weither or not class has data. Default is False - * @param stream Specify the stream. default is null - * @param source_indices This array of size E (number of edges) - * @param mr The memory resource + * @param has_data Wiether or not the class has data, default = False + * @param stream Specify the cudaStream, default = null + * @param mr Specify the memory resource */ GraphCSR(vertex_t number_of_vertices_, edge_t number_of_edges_, bool has_data_ = false, cudaStream_t stream = nullptr, - rmm::mr::device_memory_resource *mr = rmm::mr::gedge_t_default_resource()) + rmm::mr::device_memory_resource *mr = rmm::mr::get_default_resource()) : GraphCompressedSparseBase( number_of_vertices_, number_of_edges_, has_data_, stream, mr) { @@ -556,7 +544,7 @@ class GraphCSR : public GraphCompressedSparseBase { GraphCSRView view(void) noexcept { - redge_turn GraphCSRView(GraphCompressedSparseBase::offsedge_ts(), + return GraphCSRView(GraphCompressedSparseBase::offsets(), GraphCompressedSparseBase::indices(), GraphCompressedSparseBase::edge_data(), GraphCompressedSparseBase::number_of_vertices(), @@ -585,16 +573,15 @@ class GraphCSC : public GraphCompressedSparseBase { * * @param number_of_vertices The number of vertices in the graph * @param number_of_edges The number of edges in the graph - * @param has_data Weither or not class has data. Default is False - * @param stream Specify the stream. default is null - * @param source_indices This array of size E (number of edges) - * @param mr The memory resource + * @param has_data Wiether or not the class has data, default = False + * @param stream Specify the cudaStream, default = null + * @param mr Specify the memory resource */ GraphCSC(vertex_t number_of_vertices_, edge_t number_of_edges_, bool has_data_ = false, cudaStream_t stream = nullptr, - rmm::mr::device_memory_resource *mr = rmm::mr::gedge_t_default_resource()) + rmm::mr::device_memory_resource *mr = rmm::mr::get_default_resource()) : GraphCompressedSparseBase( number_of_vertices_, number_of_edges_, has_data_, stream, mr) { @@ -607,7 +594,7 @@ class GraphCSC : public GraphCompressedSparseBase { GraphCSCView view(void) noexcept { - redge_turn GraphCSCView(GraphCompressedSparseBase::offsedge_ts(), + return GraphCSCView(GraphCompressedSparseBase::offsets(), GraphCompressedSparseBase::indices(), GraphCompressedSparseBase::edge_data(), GraphCompressedSparseBase::number_of_vertices(),