-
Notifications
You must be signed in to change notification settings - Fork 293
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Fixed links and added c++ docs per issue 4431 (#4435)
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
Showing
4 changed files
with
179 additions
and
5 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
81 changes: 81 additions & 0 deletions
81
docs/cugraph/source/graph_support/algorithms/cpp_algorithms/centrality_cpp.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` |
37 changes: 37 additions & 0 deletions
37
docs/cugraph/source/graph_support/algorithms/cpp_algorithms/linear_cpp.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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). |
56 changes: 56 additions & 0 deletions
56
docs/cugraph/source/graph_support/algorithms/cpp_algorithms/traversal_cpp.md
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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); | ||
``` |