Skip to content

[REVIEW] Add support for shortest_path_length and fix graph vertex checks#1278

Merged
rapids-bot[bot] merged 6 commits intorapidsai:branch-0.17from
jpurviance:shortest-path-length
Dec 3, 2020
Merged

[REVIEW] Add support for shortest_path_length and fix graph vertex checks#1278
rapids-bot[bot] merged 6 commits intorapidsai:branch-0.17from
jpurviance:shortest-path-length

Conversation

@jpurviance
Copy link
Copy Markdown
Contributor

@jpurviance jpurviance commented Nov 23, 2020

Adds the ability to get the length/cost of path from source to destination(s). Closely follows networkx.shortest_path_length.

Similarities:

  1. Takes an optional target vertex
  2. If only source is provided, a cudf dataframe is returned with columns: [vertex, distance] (similar to networkx dictionary return)
  3. If source and target are specified the exact length is returned or sys.float_info.max if the vertex is not reachable.

Differences:

  1. Requires that source be provided, as apposed to networkx
  2. Nethod of graph traversal is not an option.

Fixes:

  1. Fixes [FEA] target to source shortest path #806
  2. sssp and cugraph.Graph.has_node vertex checks. Added support for checking for vertexes that are not apart of the graph. in the past, TypeError was raised when doing a comparison check (as apposed to ValueError)

@jpurviance jpurviance requested a review from a team as a code owner November 23, 2020 05:47
@GPUtester
Copy link
Copy Markdown
Contributor

Can one of the admins verify this patch?

2 similar comments
@GPUtester
Copy link
Copy Markdown
Contributor

Can one of the admins verify this patch?

@GPUtester
Copy link
Copy Markdown
Contributor

Can one of the admins verify this patch?

@BradReesWork BradReesWork added this to the 0.17 milestone Nov 24, 2020
@BradReesWork
Copy link
Copy Markdown
Member

ok to test

@BradReesWork BradReesWork added the improvement Improvement / enhancement to an existing function label Nov 24, 2020
@GPUtester
Copy link
Copy Markdown
Contributor

Please update the changelog in order to start CI tests.

View the gpuCI docs here.


# Step 5: Check if source index is valid
if not 0 <= source < num_verts:
if source is cudf.NA or 0 > source or num_verts <= source:
Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

It might be cleaner to raise an exception for source is cudf.NA in sssp.py after doing the renumbering conversion (if necessary). I usually think of the algorithm.py file as dealing with things related to getting into the context for the calling C++ and the algorithm_wrapper.pyx file as dealing with the mechanical aspects of calling C++.

Copy link
Copy Markdown
Member

@afender afender left a comment

Choose a reason for hiding this comment

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

Looks good. Thank you!
I just added a minor suggestion.

Comment thread python/cugraph/traversal/__init__.py Outdated


# TODO: need to add docs, test with cupy matrix and networkx graphs
def shortest_path_length(G, source, target=None):
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

In addition to docs, please consider transferring this function to sssp.py for consistency

@jpurviance jpurviance changed the title [WIP] add support for shortest_path_length and fix graph vertex checks add support for shortest_path_length and fix graph vertex checks Nov 25, 2020
@jpurviance
Copy link
Copy Markdown
Contributor Author

Ready for review

@jpurviance
Copy link
Copy Markdown
Contributor Author

I've been looking over the contributing.md docs.

I noticed that there is a changelog step. is this completed for every pr? Should I take the effort to complete that now or after the PR if so.

Also, I noticed there is collection of [WIP], [REVIEW] and [GPUCI] on PR's. Is there information on which ones I should be using? Should I be adding these myself or waiting for the project maintainers?

@seunghwak
Copy link
Copy Markdown
Contributor

I've been looking over the contributing.md docs.

I noticed that there is a changelog step. is this completed for every pr? Should I take the effort to complete that now or after the PR if so.

Also, I noticed there is collection of [WIP], [REVIEW] and [GPUCI] on PR's. Is there information on which ones I should be using? Should I be adding these myself or waiting for the project maintainers?

We're switching to auto-generate change-log using PR title and message (this should happen very soon), but before then, CHANGELOG should be manually updated.

Yes, the authors are expected to add [WIP] (work-in-progress) or [REVIEW] (ready-to-be-reviewed)in the PR title to indicate the current state of the PR.

@BradReesWork BradReesWork changed the title add support for shortest_path_length and fix graph vertex checks [REVIEW] add support for shortest_path_length and fix graph vertex checks Nov 30, 2020
@BradReesWork
Copy link
Copy Markdown
Member

@jpurviance code looks good, just need the CHANGELOG updated.. As Seunghwa mentioned above, that step is going to be dropped as we move to automatically updating teh change log based on PR title, but that is st ill a few weeks away

@jpurviance jpurviance changed the title [REVIEW] add support for shortest_path_length and fix graph vertex checks [REVIEW] Add support for shortest_path_length and fix graph vertex checks Dec 1, 2020
Copy link
Copy Markdown
Member

@afender afender left a comment

Choose a reason for hiding this comment

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

Thank you, John!
I noticed there's a small merge conflict in sssp.py as well as the changelog check that is still complaining.. We should be able to press the merge button once this is addressed.

@jpurviance jpurviance force-pushed the shortest-path-length branch from 574b8a3 to a206b5d Compare December 2, 2020 01:44
@jpurviance jpurviance force-pushed the shortest-path-length branch from a206b5d to 2dd0172 Compare December 2, 2020 01:49
@jpurviance
Copy link
Copy Markdown
Contributor Author

Change log updated and merge conflicts resolved.

@codecov-io
Copy link
Copy Markdown

codecov-io commented Dec 3, 2020

Codecov Report

Merging #1278 (e984ffb) into branch-0.17 (09854cc) will increase coverage by 0.30%.
The diff coverage is 100.00%.

Impacted file tree graph

@@               Coverage Diff               @@
##           branch-0.17    #1278      +/-   ##
===============================================
+ Coverage        60.07%   60.38%   +0.30%     
===============================================
  Files               67       67              
  Lines             3006     3029      +23     
===============================================
+ Hits              1806     1829      +23     
  Misses            1200     1200              
Impacted Files Coverage Δ
python/cugraph/__init__.py 100.00% <ø> (ø)
python/cugraph/structure/graph.py 66.79% <100.00%> (ø)
python/cugraph/traversal/__init__.py 100.00% <100.00%> (ø)
python/cugraph/traversal/sssp.py 93.63% <100.00%> (+1.87%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 09854cc...e984ffb. Read the comment docs.

@rapids-bot rapids-bot Bot merged commit 6b92349 into rapidsai:branch-0.17 Dec 3, 2020
@BradReesWork
Copy link
Copy Markdown
Member

@jpurviance thanks for diving in and helping make cuGraph better

@jpurviance jpurviance deleted the shortest-path-length branch December 4, 2020 03:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

improvement Improvement / enhancement to an existing function non-breaking Non-breaking change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[FEA] target to source shortest path

7 participants