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

isolated vertices are not being captured properly when initializing a Graph with an adjacency matrix #1478

Open
Tracked by #3256
rlratzel opened this issue Mar 23, 2021 · 4 comments
Assignees
Labels
bug Something isn't working

Comments

@rlratzel
Copy link
Contributor

Isolated vertices are lost when we initialize a Graph using an adj list:

>>> nxG = nx.from_numpy_array     (np.array([[1,1,0], [1,0,0], [0,0,0]]), create_using=nx.DiGraph)
>>> G   = cugraph.from_numpy_array(np.array([[1,1,0], [1,0,0], [0,0,0]]), create_using=cugraph.DiGraph)
>>>
>>> nxG.number_of_nodes()
3
>>> G.number_of_vertices()
2
>>> G = cugraph.from_numpy_array(np.array([[0]]), create_using=cugraph.DiGraph)
/opt/conda/envs/rapids/lib/python3.8/site-packages/cudf/core/join/casting_logic.py:132: UserWarning: can't safely cast column from right with type float64 to int64, upcasting to float64
  warnings.warn(
>>> G.number_of_vertices()
nan
>>> nxG = nx.from_numpy_array(np.array([[0]]), create_using=nx.DiGraph)
>>> nxG.number_of_nodes()
1

This is likely due to internally converting the numpy array to an edgelist, which is then used to initialize the Graph. We may be able to at least capture the correct number of vertices by looking at the incoming array's shape (which would also allow us to assert it's square).

@rlratzel rlratzel added bug Something isn't working ? - Needs Triage Need team to review and classify labels Mar 23, 2021
@BradReesWork BradReesWork removed the ? - Needs Triage Need team to review and classify label Mar 24, 2021
@BradReesWork BradReesWork added this to the 0.20 milestone Mar 24, 2021
@rlratzel rlratzel changed the title [BUG] isolated vertices are not being captured properly when initializing a Graph with an adjacency list [BUG] isolated vertices are not being captured properly when initializing a Graph with an adjacency matrix Mar 24, 2021
@rapidsai rapidsai deleted a comment from github-actions bot May 5, 2021
@BradReesWork BradReesWork modified the milestones: 21.06, 21.08 Jun 2, 2021
@ChuckHastings
Copy link
Collaborator

The new graph object construction code can handle this properly as long as the python code calls the construction properly.

The legacy graph object construction code in C++ should handle this properly except in the case where there are isolated vertices at the end of the vertex list.

We need to prioritize/schedule this accordingly. If we can wait until we migrate to the new graph objects (C++) then this problem will be corrected at that point. If we need to fix it sooner then we will need to update the legacy implementation to properly handle isolated vertices at the end of the vertex list.

@rlratzel rlratzel modified the milestones: 21.08, 21.10 Jul 19, 2021
@BradReesWork BradReesWork modified the milestones: 21.10, 21.12 Oct 6, 2021
@BradReesWork BradReesWork modified the milestones: 21.12, 22.02 Nov 17, 2021
@rapidsai rapidsai deleted a comment from github-actions bot Jan 26, 2022
@BradReesWork BradReesWork removed this from the 22.02 milestone Jan 26, 2022
@BradReesWork BradReesWork modified the milestones: 22.06, 22.08 Jun 1, 2022
@jarmak-nv jarmak-nv modified the milestones: 22.08, 22.10 Aug 8, 2022
@BradReesWork BradReesWork assigned rlratzel and unassigned oorliu Oct 6, 2022
@BradReesWork BradReesWork modified the milestones: 22.10, 22.12 Oct 6, 2022
@BradReesWork BradReesWork modified the milestones: 22.12, 23.02 Dec 7, 2022
@BradReesWork BradReesWork removed this from the 23.02 milestone Jan 12, 2023
@BradReesWork BradReesWork added Fix and removed bug Something isn't working labels Feb 2, 2023
@kingmesal kingmesal added bug Something isn't working and removed Fix labels Feb 9, 2023
@rlratzel rlratzel changed the title [BUG] isolated vertices are not being captured properly when initializing a Graph with an adjacency matrix isolated vertices are not being captured properly when initializing a Graph with an adjacency matrix Aug 7, 2023
@rapidsai rapidsai deleted a comment from github-actions bot Aug 7, 2023
@ChuckHastings
Copy link
Collaborator

Note that #3982 adds parameters to the C API that can address this. The python layer would need to be updated to pick up these changes in the case of an adjacency matrix.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

8 participants