-
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
Refactor the python function symmetrizing the edgelist #4649
Conversation
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.
Reviewed the C part, LGTM (besides one question)
const cugraph_type_erased_device_array_view_t* weights, | ||
bool_t reciprocal, | ||
cugraph_induced_subgraph_result_t** result, | ||
cugraph_error_t** 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.
Aren't we planning to remove this function from the python API? Should we expose this in the C-API?
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.
Agreed, I thought we decided this was not going to be exposed via the C API.
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.
A few things to address.
const cugraph_type_erased_device_array_view_t* weights, | ||
bool_t reciprocal, | ||
cugraph_induced_subgraph_result_t** result, | ||
cugraph_error_t** 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.
Agreed, I thought we decided this was not going to be exposed via the C API.
cpp/include/cugraph_c/graph.h
Outdated
@@ -150,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 |
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.
This comment doesn't read correctly, looks like we didn't get the entire comment from wherever it was copied.
We should add in the assumption that only weights can be symmetrized currently... if you have edge_ids
or edge_types
you can't specify symmetrize as true
.
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.
I removed the unrelated comments. I also update the doc strings to reflect that the symmetrization of edges with edge and type ids is currently not supported. In the CAPI, I return an unsupported
error if either or is specified
cpp/include/cugraph_c/graph.h
Outdated
@@ -190,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. |
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.
Same as above.
@@ -207,6 +210,22 @@ struct create_graph_functor : public cugraph::c_api::abstract_functor { | |||
: false); | |||
} | |||
|
|||
if (symmetrize_) { |
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 set is_symmetric
to true.
@@ -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 comment
The reason will be displayed to describe this comment to others. Learn more.
Same comment as above regarding is_symmetric
@@ -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_) { | |||
if (edgelist_edge_ids || edgelist_edge_types) { |
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.
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 comment
The reason will be displayed to describe this comment to others. Learn more.
I tracked this in an issue
Right we are not exposing it to the python API. I forgot to remove it from the CAPI as well |
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.
Thanks! Just a few requests below.
print("G = ", G) | ||
|
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.
Oops
behavior symmetrizes the edges if the graph is undirected. If the edges | ||
are already symmetric, set this flag to False. |
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.
Should you also mention the restriction on edgelists with edge IDs and edge types? Also, the way this is worded makes it seem like the user must figure out if the edgrs are symmetric or not and set the flag accordingly. Maybe it would be better if it was worded like this:
behavior symmetrizes the edges if the graph is undirected. If the edges | |
are already symmetric, set this flag to False. | |
behavior symmetrizes the edges if the graph is undirected. This flag cannot be set to True if the edgelist contains edge IDs or edge Types. If the incoming edgelist is intended for an undirected graph and it is known to be symmetric, this flag can be set to False to skip the symmetrization step for better performance. |
Same suggestion for from_cudf_adjlist
below.
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.
Got it. I reworded it as you suggested
print("creating a directed graph") | ||
G = cugraph.Graph(directed=True) | ||
elif isinstance(nxG, nx.classes.graph.Graph): | ||
print("creating an undirected graph") |
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.
more leftover debug prints.
…0_refactor_symmetrize
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.
Thanks, almost done, still see a debug print and I had one minor request.
python/cugraph/cugraph/structure/graph_implementation/simpleGraph.py
Outdated
Show resolved
Hide resolved
/merge |
This PR updates the python API to symmetrize the edge list through the CAPI for PLC algorithms. This PR also deprecates the legacy python function symmetrizing the edge list
closes #4588