Skip to content
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

Merged

Conversation

jnke2016
Copy link
Contributor

@jnke2016 jnke2016 commented Sep 10, 2024

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

@jnke2016 jnke2016 requested a review from a team as a code owner September 10, 2024 13:26
@jnke2016 jnke2016 requested a review from a team as a code owner September 10, 2024 14:52
@github-actions github-actions bot added the CMake label Sep 10, 2024
@jnke2016 jnke2016 changed the title Refactor the python function symmetrizing the edgeless Refactor the python function symmetrizing the edgelist Sep 11, 2024
@jnke2016 jnke2016 marked this pull request as draft September 11, 2024 15:16
@github-actions github-actions bot removed the CMake label Sep 23, 2024
@jnke2016 jnke2016 marked this pull request as ready for review September 23, 2024 13:46
@jnke2016 jnke2016 requested a review from a team as a code owner September 23, 2024 13:46
@jnke2016 jnke2016 self-assigned this Sep 23, 2024
Copy link
Contributor

@seunghwak seunghwak left a 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);
Copy link
Contributor

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?

Copy link
Collaborator

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.

Copy link
Collaborator

@ChuckHastings ChuckHastings left a 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);
Copy link
Collaborator

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.

@@ -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
Copy link
Collaborator

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.

Copy link
Contributor Author

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

@@ -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.
Copy link
Collaborator

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_) {
Copy link
Collaborator

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_) {
Copy link
Collaborator

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) {
Copy link
Collaborator

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.

Copy link
Contributor Author

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

@jnke2016
Copy link
Contributor Author

Agreed, I thought we decided this was not going to be exposed via the C API.

Right we are not exposing it to the python API. I forgot to remove it from the CAPI as well

Copy link
Contributor

@rlratzel rlratzel left a 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.

Comment on lines 290 to 291
print("G = ", G)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Oops

Comment on lines 181 to 182
behavior symmetrizes the edges if the graph is undirected. If the edges
are already symmetric, set this flag to False.
Copy link
Contributor

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:

Suggested change
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.

Copy link
Contributor Author

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

Comment on lines 122 to 125
print("creating a directed graph")
G = cugraph.Graph(directed=True)
elif isinstance(nxG, nx.classes.graph.Graph):
print("creating an undirected graph")
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

more leftover debug prints.

Copy link
Contributor

@rlratzel rlratzel left a 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.

@rlratzel rlratzel added improvement Improvement / enhancement to an existing function non-breaking Non-breaking change labels Oct 2, 2024
@rlratzel
Copy link
Contributor

rlratzel commented Oct 2, 2024

/merge

@raydouglass raydouglass merged commit 5fad435 into rapidsai:branch-24.10 Oct 3, 2024
130 of 131 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cuGraph improvement Improvement / enhancement to an existing function non-breaking Non-breaking change python
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Remove deprecation warning for multigraph edges / refactor symmetrization
5 participants