Skip to content

Commit

Permalink
Fixed links and added c++ docs per issue 4431 (#4435)
Browse files Browse the repository at this point in the history
added content to document c++ algorithms and fixed links that were pointing to the previously removed content
resolves #4431  
Resolves #4116

Authors:
  - Don Acosta (https://github.com/acostadon)

Approvers:
  - Rick Ratzel (https://github.com/rlratzel)
  - Brad Rees (https://github.com/BradReesWork)
  - Chuck Hastings (https://github.com/ChuckHastings)

URL: #4435
  • Loading branch information
acostadon committed May 29, 2024
1 parent 4c797bf commit 04e8000
Show file tree
Hide file tree
Showing 4 changed files with 179 additions and 5 deletions.
10 changes: 5 additions & 5 deletions docs/cugraph/source/graph_support/algorithms.md
Original file line number Diff line number Diff line change
Expand Up @@ -50,10 +50,10 @@ Note: Multi-GPU, or MG, includes support for Multi-Node Multi-GPU (also called M
| Layout | | | |
| | [Force Atlas 2](https://github.com/rapidsai/cugraph/blob/main/notebooks/algorithms/layout/Force-Atlas2.ipynb) | Single-GPU | |
| Linear Assignment | | | |
| | [Hungarian]() | Single-GPU | [README](cpp/src/linear_assignment/README-hungarian.md) |
| | [Hungarian](https://docs.rapids.ai/api/cugraph/nightly/api_docs/cugraph/linear_assignment/#hungarian) | Single-GPU | [README](./algorithms/cpp_algorithms/linear_cpp.html) |
| Link Analysis | | | |
| | [Pagerank](https://github.com/rapidsai/cugraph/blob/main/notebooks/algorithms/link_analysis/Pagerank.ipynb) | __Multi-GPU__ | [C++ README](cpp/src/centrality/README.md#Pagerank) |
| | [Personal Pagerank]() | __Multi-GPU__ | [C++ README](cpp/src/centrality/README.md#Personalized-Pagerank) |
| | [Pagerank](https://github.com/rapidsai/cugraph/blob/main/notebooks/algorithms/link_analysis/Pagerank.ipynb) | __Multi-GPU__ | [C++ README](./algorithms/cpp_algorithms/centrality_cpp.html#Pagerank) |
| | [Personal Pagerank](https://github.com/rapidsai/cugraph/blob/main/notebooks/algorithms/link_analysis/Pagerank.ipynb) | __Multi-GPU__ | [C++ README](./algorithms/cpp_algorithms/centrality_cpp.html#Personalized-Pagerank) |
| | [HITS](https://github.com/rapidsai/cugraph/blob/main/notebooks/algorithms/link_analysis/HITS.ipynb) | __Multi-GPU__ | |
| [Link Prediction](algorithms/Similarity.html) | | | |
| | [Jaccard Similarity](https://github.com/rapidsai/cugraph/blob/main/notebooks/algorithms/link_prediction/Jaccard-Similarity.ipynb) | __Multi-GPU__ | Directed graph only |
Expand All @@ -68,8 +68,8 @@ Note: Multi-GPU, or MG, includes support for Multi-Node Multi-GPU (also called M
| | Node2Vec | __Multi-GPU__ | |
| | Neighborhood sampling | __Multi-GPU__ | |
| Traversal | | | |
| | Breadth First Search (BFS) | __Multi-GPU__ | with cutoff support [C++ README](cpp/src/traversal/README.md#BFS) |
| | Single Source Shortest Path (SSSP) | __Multi-GPU__ | [C++ README](cpp/src/traversal/README.md#SSSP) |
| | Breadth First Search (BFS) | __Multi-GPU__ | [C++ README](algorithms/cpp_algorithms/traversal_cpp.html#BFS) |
| | Single Source Shortest Path (SSSP) | __Multi-GPU__ | [C++ README](algorithms/cpp_algorithms/traversal_cpp.html#SSSP) |
| | _ASSP / APSP_ | --- | |
| Tree | | | |
| | Minimum Spanning Tree | Single-GPU | |
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,81 @@
# Centrality algorithms
cuGraph Pagerank is implemented using our graph primitive library

## Pagerank

The unit test code is the best place to search for examples on calling pagerank.

* [SG Implementation](https://github.com/rapidsai/cugraph/blob/main/cpp/tests/link_analysis/pagerank_test.cpp)
* [MG Implementation](https://github.com/rapidsai/cugraph/blob/main/cpp/tests/link_analysis/mg_pagerank_test.cpp)

## Simple pagerank

The example assumes that you create an SG or MG graph somehow. The caller must create the pageranks vector in device memory and pass in the raw pointer to that vector into the pagerank function.

```cpp
#include <cugraph/algorithms.hpp>
...
using vertex_t = int32_t; // or int64_t, whichever is appropriate
using weight_t = float; // or double, whichever is appropriate
using result_t = weight_t; // could specify float or double also
raft::handle_t handle; // Must be configured if MG
auto graph_view = graph.view(); // assumes you have created a graph somehow

result_t constexpr alpha{0.85};
result_t constexpr epsilon{1e-6};

rmm::device_uvector<result_t> pageranks_v(graph_view.number_of_vertices(), handle.get_stream());

// pagerank optionally supports three additional parameters:
// max_iterations - maximum number of iterations, if pagerank doesn't coverge by
// then we abort
// has_initial_guess - if true, values in the pagerank array when the call is initiated
// will be used as the initial pagerank values. These values will
// be normalized before use. If false (the default), the values
// in the pagerank array will be set to 1/num_vertices before
// starting the computation.
// do_expensive_check - perform extensive validation of the input data before
// executing algorithm. Off by default. Note: turning this on
// is expensive
cugraph::pagerank(handle, graph_view, nullptr, nullptr, nullptr, vertex_t{0},
pageranks_v.data(), alpha, epsilon);
```
## Personalized Pagerank
The example assumes that you create an SG or MG graph somehow. The caller must create the pageranks vector in device memory and pass in the raw pointer to that vector into the pagerank function. Additionally, the caller must create personalization_vertices and personalized_values vectors in device memory, populate them and pass in the raw pointers to those vectors.
```cpp
#include <cugraph/algorithms.hpp>
...
using vertex_t = int32_t; // or int64_t, whichever is appropriate
using weight_t = float; // or double, whichever is appropriate
using result_t = weight_t; // could specify float or double also
raft::handle_t handle; // Must be configured if MG
auto graph_view = graph.view(); // assumes you have created a graph somehow
vertex_t number_of_personalization_vertices; // Provided by caller
result_t constexpr alpha{0.85};
result_t constexpr epsilon{1e-6};
rmm::device_uvector<result_t> pageranks_v(graph_view.number_of_vertices(), handle.get_stream());
rmm::device_uvector<vertex_t> personalization_vertices(number_of_personalization_vertices, handle.get_stream());
rmm::device_uvector<result_t> personalization_values(number_of_personalization_vertices, handle.get_stream());
// Populate personalization_vertices, personalization_values with user provided data
// pagerank optionally supports three additional parameters:
// max_iterations - maximum number of iterations, if pagerank doesn't coverge by
// then we abort
// has_initial_guess - if true, values in the pagerank array when the call is initiated
// will be used as the initial pagerank values. These values will
// be normalized before use. If false (the default), the values
// in the pagerank array will be set to 1/num_vertices before
// starting the computation.
// do_expensive_check - perform extensive validation of the input data before
// executing algorithm. Off by default. Note: turning this on
// is expensive
cugraph::pagerank(handle, graph_view, nullptr, personalization_vertices.data(),
personalization_values.data(), number_of_personalization_vertices,
pageranks_v.data(), alpha, epsilon);
```
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
# LAP

Implementation of ***O(n^3) Alternating Tree Variant*** of Hungarian Algorithm on NVIDIA CUDA-enabled GPU.

This implementation solves a batch of ***k*** **Linear Assignment Problems (LAP)**, each with ***nxn*** matrix of single floating point cost values. At optimality, the algorithm produces an assignment with ***minimum*** cost.

The API can be used to query optimal primal and dual costs, optimal assignment vector, and optimal row/column dual vectors for each subproblem in the batch.

cuGraph exposes the Hungarian algorithm, the actual implementation is contained in the RAFT library which contains some common tools and kernels shared between cuGraph and cuML.

Following parameters can be used to tune the performance of algorithm:

1. epsilon: (in raft/lap/lap_kernels.cuh) This parameter controls the tolerance on the floating point precision. Setting this too small will result in increased solution time because the algorithm will search for precise solutions. Setting it too high may cause some inaccuracies.

2. BLOCKDIMX, BLOCKDIMY: (in raft/lap/lap_functions.cuh) These parameters control threads_per_block to be used along the given dimension. Set these according to the device specifications and occupancy calculation.

***This library is licensed under Apache License 2.0. Please cite our paper, if this library helps you in your research.***

- Harvard citation style

Date, K. and Nagi, R., 2016. GPU-accelerated Hungarian algorithms for the Linear Assignment Problem. Parallel Computing, 57, pp.52-72.

- BibTeX Citation block to be used in LaTeX bibliography file:

```
@article{date2016gpu,
title={GPU-accelerated Hungarian algorithms for the Linear Assignment Problem},
author={Date, Ketan and Nagi, Rakesh},
journal={Parallel Computing},
volume={57},
pages={52--72},
year={2016},
publisher={Elsevier}
}
```

The paper is available online on [ScienceDirect](https://www.sciencedirect.com/science/article/abs/pii/S016781911630045X).
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
# Traversal
cuGraph traversal algorithms are contained in this directory

## SSSP

The unit test code is the best place to search for examples on calling SSSP.

* [SG Implementation](https://github.com/rapidsai/cugraph/blob/main/cpp/tests/traversal/sssp_test.cpp)
* [MG Implementation](https://github.com/rapidsai/cugraph/blob/main/cpp/tests/traversal/mg_sssp_test.cpp)

## Simple SSSP

The example assumes that you create an SG or MG graph somehow. The caller must create the distances and predecessors vectors in device memory and pass in the raw pointers to those vectors into the SSSP function.

```cpp
#include <cugraph/algorithms.hpp>
...
using vertex_t = int32_t; // or int64_t, whichever is appropriate
using weight_t = float; // or double, whichever is appropriate
using result_t = weight_t; // could specify float or double also
raft::handle_t handle; // Must be configured if MG
auto graph_view = graph.view(); // assumes you have created a graph somehow
vertex_t source; // Initialized by user

rmm::device_uvector<weight_t> distances_v(graph_view.number_of_vertices(), handle.get_stream());
rmm::device_uvector<vertex_t> predecessors_v(graph_view.number_of_vertices(), handle.get_stream());

cugraph::sssp(handle, graph_view, distances_v.begin(), predecessors_v.begin(), source, std::numeric_limits<weight_t>::max(), false);
```
## BFS
The unit test code is the best place to search for examples on calling BFS.
* [SG Implementation](https://github.com/rapidsai/cugraph/blob/main/cpp/tests/traversal/bfs_test.cpp)
* [MG Implementation](https://github.com/rapidsai/cugraph/blob/main/cpp/tests/traversal/mg_bfs_test.cpp)
## Simple BFS
The example assumes that you create an SG or MG graph somehow. The caller must create the distances and predecessors vectors in device memory and pass in the raw pointers to those vectors into the BFS function.
```cpp
#include <cugraph/algorithms.hpp>
...
using vertex_t = int32_t; // or int64_t, whichever is appropriate
using weight_t = float; // or double, whichever is appropriate
using result_t = weight_t; // could specify float or double also
raft::handle_t handle; // Must be configured if MG
auto graph_view = graph.view(); // assumes you have created a graph somehow
vertex_t source; // Initialized by user
rmm::device_uvector<weight_t> distances_v(graph_view.number_of_vertices(), handle.get_stream());
rmm::device_uvector<vertex_t> predecessors_v(graph_view.number_of_vertices(), handle.get_stream());
cugraph::bfs(handle, graph_view, d_distances.begin(), d_predecessors.begin(), source, false, std::numeric_limits<vertex_t>::max(), false);
```

0 comments on commit 04e8000

Please sign in to comment.