Skip to content

Commit

Permalink
update API to symmetrize the edgelist and update docstring
Browse files Browse the repository at this point in the history
  • Loading branch information
jnke2016 committed Sep 23, 2024
1 parent 47b0677 commit f09fd41
Show file tree
Hide file tree
Showing 11 changed files with 145 additions and 301 deletions.
1 change: 0 additions & 1 deletion cpp/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -666,7 +666,6 @@ add_library(cugraph_c
src/c_api/weakly_connected_components.cpp
src/c_api/strongly_connected_components.cpp
src/c_api/allgather.cpp
src/c_api/symmetrize_edgelist.cpp
)
add_library(cugraph::cugraph_c ALIAS cugraph_c)

Expand Down
8 changes: 8 additions & 0 deletions cpp/include/cugraph_c/graph.h
Original file line number Diff line number Diff line change
Expand Up @@ -152,6 +152,9 @@ cugraph_error_code_t cugraph_graph_create_sg(
* If false, do not renumber. Renumbering enables some significant optimizations within
* the graph primitives library, so it is strongly encouraged. Renumbering is required if
* the vertices are not sequential integer values from 0 to num_vertices.
* @param [in] symmetrize If true, symmetrize the edgelist.
* or take the maximum weight), the caller should remove specific edges themselves and not rely
* on this flag.
* @param [in] do_expensive_check If true, do expensive checks to validate the input data
* is consistent with software assumptions. If false bypass these checks.
* @param [out] graph A pointer to the graph object
Expand All @@ -170,6 +173,7 @@ cugraph_error_code_t cugraph_sg_graph_create_from_csr(
const cugraph_type_erased_device_array_view_t* edge_type_ids,
bool_t store_transposed,
bool_t renumber,
bool_t symmetrize,
bool_t do_expensive_check,
cugraph_graph_t** graph,
cugraph_error_t** error);
Expand All @@ -192,6 +196,9 @@ cugraph_error_code_t cugraph_sg_graph_create_from_csr(
* If false, do not renumber. Renumbering enables some significant optimizations within
* the graph primitives library, so it is strongly encouraged. Renumbering is required if
* the vertices are not sequential integer values from 0 to num_vertices.
* @param [in] symmetrize If true, symmetrize the edgelist.
* or take the maximum weight), the caller should remove specific edges themselves and not rely
* on this flag.
* @param [in] do_expensive_check If true, do expensive checks to validate the input data
* is consistent with software assumptions. If false bypass these checks.
* @param [out] graph A pointer to the graph object
Expand All @@ -210,6 +217,7 @@ cugraph_error_code_t cugraph_graph_create_sg_from_csr(
const cugraph_type_erased_device_array_view_t* edge_type_ids,
bool_t store_transposed,
bool_t renumber,
bool_t symmetrize,
bool_t do_expensive_check,
cugraph_graph_t** graph,
cugraph_error_t** error);
Expand Down
2 changes: 1 addition & 1 deletion cpp/src/c_api/graph_mg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -230,7 +230,7 @@ struct create_graph_functor : public cugraph::c_api::abstract_functor {

if (symmetrize_) {
if (edgelist_edge_ids || edgelist_edge_types) {
// Currently doesn't support the symmetrization with edge_ids and edge_types
// Currently doesn't support the symmetrization of edgelist with edge_ids and edge_types
unsupported();
}

Expand Down
41 changes: 23 additions & 18 deletions cpp/src/c_api/graph_sg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -167,23 +167,6 @@ struct create_graph_functor : public cugraph::c_api::abstract_functor {
edge_type_ids_->size_,
handle_.get_stream());
}

if (symmetrize_) {
if (edgelist_edge_ids || edgelist_edge_types) {
// Currently doesn't support the symmetrization with edge_ids and edge_types
unsupported();
}

// Symmetrize the edgelist
std::tie(
edgelist_srcs, edgelist_dsts, edgelist_weights) =
cugraph::symmetrize_edgelist<vertex_t, weight_t, store_transposed, multi_gpu>(handle_,
std::move(edgelist_srcs),
std::move(edgelist_dsts),
std::move(edgelist_weights),
false);
}


auto graph = new cugraph::graph_t<vertex_t, edge_t, store_transposed, multi_gpu>(handle_);

Expand Down Expand Up @@ -227,7 +210,6 @@ struct create_graph_functor : public cugraph::c_api::abstract_functor {
: false);
}


if (symmetrize_) {
if (edgelist_edge_ids || edgelist_edge_types) {
// Currently doesn't support the symmetrization with edge_ids and edge_types
Expand Down Expand Up @@ -305,6 +287,7 @@ struct create_graph_csr_functor : public cugraph::c_api::abstract_functor {
cugraph::c_api::cugraph_type_erased_device_array_view_t const* edge_ids_;
cugraph::c_api::cugraph_type_erased_device_array_view_t const* edge_type_ids_;
bool_t renumber_;
bool_t symmetrize_;
bool_t do_expensive_check_;
cugraph::c_api::cugraph_graph_t* result_{};

Expand All @@ -317,6 +300,7 @@ struct create_graph_csr_functor : public cugraph::c_api::abstract_functor {
cugraph::c_api::cugraph_type_erased_device_array_view_t const* edge_ids,
cugraph::c_api::cugraph_type_erased_device_array_view_t const* edge_type_ids,
bool_t renumber,
bool_t symmetrize,
bool_t do_expensive_check)
: abstract_functor(),
properties_(properties),
Expand All @@ -327,6 +311,7 @@ struct create_graph_csr_functor : public cugraph::c_api::abstract_functor {
edge_ids_(edge_ids),
edge_type_ids_(edge_type_ids),
renumber_(renumber),
symmetrize_(symmetrize),
do_expensive_check_(do_expensive_check)
{
}
Expand Down Expand Up @@ -434,6 +419,22 @@ struct create_graph_csr_functor : public cugraph::c_api::abstract_functor {
auto edge_types = new cugraph::edge_property_t<
cugraph::graph_view_t<vertex_t, edge_t, store_transposed, multi_gpu>,
edge_type_id_t>(handle_);

if (symmetrize_) {
if (edgelist_edge_ids || edgelist_edge_types) {
// Currently doesn't support the symmetrization with edge_ids and edge_types
unsupported();
}

// Symmetrize the edgelist
std::tie(
edgelist_srcs, edgelist_dsts, edgelist_weights) =
cugraph::symmetrize_edgelist<vertex_t, weight_t, store_transposed, multi_gpu>(handle_,
std::move(edgelist_srcs),
std::move(edgelist_dsts),
std::move(edgelist_weights),
false);
}

std::tie(*graph, new_edge_weights, new_edge_ids, new_edge_types, new_number_map) =
cugraph::create_graph_from_edgelist<vertex_t,
Expand Down Expand Up @@ -713,6 +714,7 @@ cugraph_error_code_t cugraph_graph_create_sg_from_csr(
const cugraph_type_erased_device_array_view_t* edge_type_ids,
bool_t store_transposed,
bool_t renumber,
bool_t symmetrize,
bool_t do_expensive_check,
cugraph_graph_t** graph,
cugraph_error_t** error)
Expand Down Expand Up @@ -775,6 +777,7 @@ cugraph_error_code_t cugraph_graph_create_sg_from_csr(
p_edge_ids,
p_edge_type_ids,
renumber,
FALSE, // symmetrize
do_expensive_check);

try {
Expand Down Expand Up @@ -810,6 +813,7 @@ cugraph_error_code_t cugraph_sg_graph_create_from_csr(
const cugraph_type_erased_device_array_view_t* edge_type_ids,
bool_t store_transposed,
bool_t renumber,
bool_t symmetrize,
bool_t do_expensive_check,
cugraph_graph_t** graph,
cugraph_error_t** error)
Expand All @@ -823,6 +827,7 @@ cugraph_error_code_t cugraph_sg_graph_create_from_csr(
edge_type_ids,
store_transposed,
renumber,
symmetrize,
do_expensive_check,
graph,
error);
Expand Down
182 changes: 0 additions & 182 deletions cpp/src/c_api/symmetrize_edgelist.cpp

This file was deleted.

Loading

0 comments on commit f09fd41

Please sign in to comment.