-
Notifications
You must be signed in to change notification settings - Fork 309
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Refactor the python function symmetrizing the edgelist #4649
Changes from 36 commits
f2f3a04
0c8b927
c01456a
fb115da
47b0677
f09fd41
b737b02
ea19b62
bd7eede
6e433ab
e5c94f7
0470299
2df98f5
fabcb37
3b1c1d0
0462529
e8beb72
e3e413b
5336a91
3b40fc5
cbbfb88
8891b1f
4e9e85d
d135ac1
a9c7064
1c70046
2cfb0fb
fec091f
efbdb38
35c25db
f91bb81
0389f27
97472cd
ec7da8d
0e5a9ba
2a78356
43ba0cd
cfecd90
96d2e20
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,6 +43,7 @@ struct create_graph_functor : public cugraph::c_api::abstract_functor { | |
bool_t renumber_; | ||
bool_t drop_self_loops_; | ||
bool_t drop_multi_edges_; | ||
bool_t symmetrize_; | ||
bool_t do_expensive_check_; | ||
cugraph_data_type_id_t edge_type_; | ||
cugraph::c_api::cugraph_graph_t* result_{}; | ||
|
@@ -58,6 +59,7 @@ struct create_graph_functor : public cugraph::c_api::abstract_functor { | |
bool_t renumber, | ||
bool_t drop_self_loops, | ||
bool_t drop_multi_edges, | ||
bool_t symmetrize, | ||
bool_t do_expensive_check, | ||
cugraph_data_type_id_t edge_type) | ||
: abstract_functor(), | ||
|
@@ -72,6 +74,7 @@ struct create_graph_functor : public cugraph::c_api::abstract_functor { | |
renumber_(renumber), | ||
drop_self_loops_(drop_self_loops), | ||
drop_multi_edges_(drop_multi_edges), | ||
symmetrize_(symmetrize), | ||
do_expensive_check_(do_expensive_check), | ||
edge_type_(edge_type) | ||
{ | ||
|
@@ -207,6 +210,22 @@ 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 | ||
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, | ||
edge_t, | ||
|
@@ -268,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_{}; | ||
|
||
|
@@ -280,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), | ||
|
@@ -290,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) | ||
{ | ||
} | ||
|
@@ -398,6 +420,22 @@ struct create_graph_csr_functor : public cugraph::c_api::abstract_functor { | |
cugraph::graph_view_t<vertex_t, edge_t, store_transposed, multi_gpu>, | ||
edge_type_id_t>(handle_); | ||
|
||
if (symmetrize_) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment as above regarding |
||
if (edgelist_edge_ids || edgelist_edge_types) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should add an issue to discuss what symmetrization means with respect to edge properties. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I tracked this in an issue |
||
// 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, | ||
edge_t, | ||
|
@@ -518,6 +556,7 @@ extern "C" cugraph_error_code_t cugraph_graph_create_sg( | |
bool_t renumber, | ||
bool_t drop_self_loops, | ||
bool_t drop_multi_edges, | ||
bool_t symmetrize, | ||
bool_t do_expensive_check, | ||
cugraph_graph_t** graph, | ||
cugraph_error_t** error) | ||
|
@@ -542,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.", | ||
|
@@ -606,6 +653,7 @@ extern "C" cugraph_error_code_t cugraph_graph_create_sg( | |
renumber, | ||
drop_self_loops, | ||
drop_multi_edges, | ||
symmetrize, | ||
do_expensive_check, | ||
edge_type); | ||
|
||
|
@@ -658,6 +706,7 @@ extern "C" cugraph_error_code_t cugraph_sg_graph_create( | |
renumber, | ||
FALSE, | ||
FALSE, | ||
FALSE, | ||
do_expensive_check, | ||
graph, | ||
error); | ||
|
@@ -673,6 +722,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) | ||
|
@@ -707,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), | ||
|
@@ -735,6 +793,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 { | ||
|
@@ -770,6 +829,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) | ||
|
@@ -783,6 +843,7 @@ cugraph_error_code_t cugraph_sg_graph_create_from_csr( | |
edge_type_ids, | ||
store_transposed, | ||
renumber, | ||
symmetrize, | ||
do_expensive_check, | ||
graph, | ||
error); | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In addition to this logic, if
symmetrize_
is true then we should override the graph properties to setis_symmetric
to true.