Skip to content

Commit

Permalink
ensure the graph properties match when symmetrizing
Browse files Browse the repository at this point in the history
  • Loading branch information
jnke2016 committed Sep 26, 2024
1 parent 0470299 commit 2df98f5
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 0 deletions.
8 changes: 8 additions & 0 deletions cpp/src/c_api/graph_mg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -378,6 +378,14 @@ extern "C" cugraph_error_code_t cugraph_graph_create_mg(
if (weight_type == cugraph_data_type_id_t::NTYPES) weight_type = p_weights[i]->type_;
}

if (symmetrize == TRUE){
CAPI_EXPECTS(
(properties->is_symmetric == TRUE),
CUGRAPH_INVALID_INPUT,
"Invalid input arguments: The graph property must be symmetric if symmetrize is set to True.",
*error);
}

CAPI_EXPECTS(p_src[i]->type_ == vertex_type,
CUGRAPH_INVALID_INPUT,
"Invalid input arguments: all vertex types must match",
Expand Down
16 changes: 16 additions & 0 deletions cpp/src/c_api/graph_sg.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -581,6 +581,14 @@ extern "C" cugraph_error_code_t cugraph_graph_create_sg(
auto p_edge_type_ids =
reinterpret_cast<cugraph::c_api::cugraph_type_erased_device_array_view_t const*>(edge_type_ids);

if (symmetrize == TRUE){
CAPI_EXPECTS(
(properties->is_symmetric == TRUE),
CUGRAPH_INVALID_INPUT,
"Invalid input arguments: The graph property must be symmetric if symmetrize is set to True.",
*error);
}

CAPI_EXPECTS(p_src->size_ == p_dst->size_,
CUGRAPH_INVALID_INPUT,
"Invalid input arguments: src size != dst size.",
Expand Down Expand Up @@ -749,6 +757,14 @@ cugraph_error_code_t cugraph_graph_create_sg_from_csr(
weight_type = cugraph_data_type_id_t::FLOAT32;
}

if (symmetrize == TRUE){
CAPI_EXPECTS(
(properties->is_symmetric == TRUE),
CUGRAPH_INVALID_INPUT,
"Invalid input arguments: The graph property must be symmetric if symmetrize is set to True.",
*error);
}

CAPI_EXPECTS(
(edge_type_ids == nullptr && edge_ids == nullptr) ||
(edge_type_ids != nullptr && edge_ids != nullptr),
Expand Down

0 comments on commit 2df98f5

Please sign in to comment.