-
Notifications
You must be signed in to change notification settings - Fork 304
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
Update Louvain to use new graph primitives and pattern accelerators #1423
Changes from 12 commits
97e7d83
e1581d7
9b6fa0c
11aeffa
e8ab13a
f9fb0cd
9e4421e
7cb4c13
d660d4c
c90f608
0673a52
9bd82c2
b9cdf40
ab2fb70
b64e65b
bf522a4
0810213
9e753ca
d2d1dfe
4a26686
38dc0e5
a8c91c2
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -14,10 +14,14 @@ | |
* limitations under the License. | ||
*/ | ||
#pragma once | ||
|
||
#include <dendrogram.hpp> | ||
#include <experimental/graph.hpp> | ||
#include <experimental/graph_view.hpp> | ||
|
||
#include <graph.hpp> | ||
#include <internals.hpp> | ||
|
||
#include <raft/handle.hpp> | ||
|
||
namespace cugraph { | ||
|
@@ -637,6 +641,66 @@ std::pair<size_t, typename graph_t::weight_type> louvain( | |
size_t max_level = 100, | ||
typename graph_t::weight_type resolution = typename graph_t::weight_type{1}); | ||
|
||
/** | ||
* @brief Louvain implementation, returning dendrogram | ||
* | ||
* Compute a clustering of the graph by maximizing modularity | ||
* | ||
* Computed using the Louvain method described in: | ||
* | ||
* VD Blondel, J-L Guillaume, R Lambiotte and E Lefebvre: Fast unfolding of | ||
* community hierarchies in large networks, J Stat Mech P10008 (2008), | ||
* http://arxiv.org/abs/0803.0476 | ||
* | ||
* @throws cugraph::logic_error when an error occurs. | ||
* | ||
* @tparam graph_t Type of graph | ||
* | ||
* @param[in] handle Library handle (RAFT). If a communicator is set in the handle, | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. "If a communicator is set in the handle, ..." missing the end of the sentence? There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Removed extraneous text from copy/paste. |
||
* @param[in] graph input graph object (CSR) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should start clarifying supported graphs (directed, distributed, self loops, multi edges) |
||
* @param[in] max_level (optional) maximum number of levels to run (default 100) | ||
* @param[in] resolution (optional) The value of the resolution parameter to use. | ||
* Called gamma in the modularity formula, this changes the size | ||
* of the communities. Higher resolutions lead to more smaller | ||
* communities, lower resolutions lead to fewer larger | ||
* communities. (default 1) | ||
* | ||
* @return a pair containing: | ||
* 1) unique pointer to dendrogram | ||
* 2) modularity of the returned clustering | ||
* | ||
*/ | ||
template <typename graph_t> | ||
std::pair<std::unique_ptr<Dendrogram<typename graph_t::vertex_type>>, typename graph_t::weight_type> | ||
louvain(raft::handle_t const &handle, | ||
graph_t const &graph, | ||
size_t max_level = 100, | ||
typename graph_t::weight_type resolution = typename graph_t::weight_type{1}); | ||
|
||
/** | ||
* @brief Flatten a Dendrogram at a particular level | ||
* | ||
* A Dendrogram represents a hierarchical clustering/partitioning of | ||
* a graph. This function will flatten the hierarchical clustering into | ||
* a label for each vertex representing the final cluster/partition to | ||
* which it is assigned | ||
* | ||
* @throws cugraph::logic_error when an error occurs. | ||
* | ||
* @tparam graph_t Type of graph | ||
* | ||
* @param[in] handle Library handle (RAFT). If a communicator is set in the handle, | ||
* @param[in] graph input graph object | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like the actual param name is There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It's a bit more pervasive. They are all graph views. In fact all of our algorithms are using graph views and calling them graphs. I'm testing a change that changes |
||
* @param[in] dendrogram input dendrogram object | ||
* @param[out] clustering Pointer to device array where the clustering should be stored | ||
* | ||
*/ | ||
template <typename graph_t> | ||
void flatten_dendrogram(raft::handle_t const &handle, | ||
afender marked this conversation as resolved.
Show resolved
Hide resolved
|
||
graph_t const &graph_view, | ||
Dendrogram<typename graph_t::vertex_type> const &dendrogram, | ||
typename graph_t::vertex_type *clustering); | ||
|
||
/** | ||
* @brief Leiden implementation | ||
* | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
(question) for the python binding, are you planning on having a Louvain feature (maybe in cython.cu) that encapsulates the dendrogram aspects? Or will we add bindings for this class?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was hoping to add bindings for a louvain that returns a Dendrogram, eventually. I had to make the C++ change to support MNMG testing which needed the Dendrogram exposed.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like returning a dendrogram too (probably optionally).
Did you take a look at SLHC btw? It should return a dendrogram (might be in RAFT already). Better be consistent as we consider adding SLHC to cuGraph also.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Corey and I talked about the dendrogram and potentially moving it to raft. We thought waiting until the Louvain work was done in cugraph would be prudent.