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

[REVIEW] Expose resolution (gamma) parameter in Louvain #1034

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,7 @@
- PR #1030 MG directory org and documentation
- PR #1020 Updated Louvain to honor max_level, ECG now calls Louvain for 1 level, then full run.
- PR #1031 MG notebook
- PR #1034 Expose resolution (gamma) parameter in Louvain

## Bug Fixes
- PR #936 Update Force Atlas 2 doc and wrapper
Expand Down
17 changes: 9 additions & 8 deletions cpp/include/algorithms.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -605,24 +605,25 @@ void bfs(raft::handle_t const &handle,
*
* @throws cugraph::logic_error when an error occurs.
*
* @tparam VT Type of vertex identifiers.
* @tparam vertex_t Type of vertex identifiers.
* Supported value : int (signed, 32-bit)
* @tparam ET Type of edge identifiers.
* @tparam edge_t Type of edge identifiers.
* Supported value : int (signed, 32-bit)
* @tparam WT Type of edge weights. Supported values : float or double.
* @tparam weight_t Type of edge weights. Supported values : float or double.
*
* @param[in] graph input graph object (CSR)
* @param[out] final_modularity modularity of the returned clustering
* @param[out] num_level number of levels of the returned clustering
* @param[out] clustering Pointer to device array where the clustering should be stored
* @param[in] max_iter (optional) maximum number of iterations to run (default 100)
*/
template <typename VT, typename ET, typename WT>
void louvain(GraphCSRView<VT, ET, WT> const &graph,
WT *final_modularity,
template <typename vertex_t, typename edge_t, typename weight_t>
void louvain(GraphCSRView<vertex_t, edge_t, weight_t> const &graph,
weight_t *final_modularity,
int *num_level,
VT *louvain_parts,
int max_iter = 100);
vertex_t *louvain_parts,
int max_iter = 100,
weight_t resolution = weight_t{1});
Copy link
Contributor

@rlratzel rlratzel Aug 5, 2020

Choose a reason for hiding this comment

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

I'm assuming this default value is fine for ECG?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

The default of 1 makes Louvain behave just as it did before - which should be fine for ECG.


/**
* @brief Computes the ecg clustering of the given graph.
Expand Down
9 changes: 5 additions & 4 deletions cpp/src/community/louvain.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,20 +32,21 @@ void louvain(GraphCSRView<vertex_t, edge_t, weight_t> const &graph,
weight_t *final_modularity,
int *num_level,
vertex_t *louvain_parts,
int max_level)
int max_level,
weight_t resolution)
{
CUGRAPH_EXPECTS(graph.edge_data != nullptr, "API error, louvain expects a weighted graph");
CUGRAPH_EXPECTS(final_modularity != nullptr, "API error, final_modularity is null");
CUGRAPH_EXPECTS(num_level != nullptr, "API error, num_level is null");
CUGRAPH_EXPECTS(louvain_parts != nullptr, "API error, louvain_parts is null");

detail::louvain<vertex_t, edge_t, weight_t>(
graph, final_modularity, num_level, louvain_parts, max_level);
graph, final_modularity, num_level, louvain_parts, max_level, resolution);
}

template void louvain(
GraphCSRView<int32_t, int32_t, float> const &, float *, int *, int32_t *, int);
GraphCSRView<int32_t, int32_t, float> const &, float *, int *, int32_t *, int, float);
template void louvain(
GraphCSRView<int32_t, int32_t, double> const &, double *, int *, int32_t *, int);
GraphCSRView<int32_t, int32_t, double> const &, double *, int *, int32_t *, int, double);

} // namespace cugraph
Loading