Skip to content

Commit

Permalink
Louvain needs weighted input graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
Naim committed Feb 7, 2024
1 parent 2702f0d commit 2f2f192
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 30 deletions.
14 changes: 6 additions & 8 deletions cpp/examples/cugraph_operations/graph_operations.cu
Original file line number Diff line number Diff line change
Expand Up @@ -162,11 +162,10 @@ void perform_example_graph_operations(raft::handle_t const& handle,
src_vertex_weights_cache.view(),
dst_vertex_weights_cache.view(),
(*edge_weight_view),
[new_to_original_id_map = (*renumber_map).data()] __device__(
auto src, auto dst, auto src_prop, auto dst_prop, auto edge_prop) {
[] __device__(auto src, auto dst, auto src_prop, auto dst_prop, auto edge_prop) {
printf("\nsrc ---> %d dst = %d : src_prop = %f dst_prop = %f edge_prop = %f\n",
static_cast<int>(new_to_original_id_map[src]),
static_cast<int>(new_to_original_id_map[dst]),
static_cast<int>(src),
static_cast<int>(dst),
static_cast<float>(src_prop),
static_cast<float>(dst_prop),
static_cast<float>(edge_prop));
Expand Down Expand Up @@ -205,11 +204,10 @@ void perform_example_graph_operations(raft::handle_t const& handle,
src_vertex_weights_cache.view(),
dst_vertex_weights_cache.view(),
cugraph::edge_dummy_property_t{}.view(),
[new_to_original_id_map = (*renumber_map).data()] __device__(
auto src, auto dst, auto src_prop, auto dst_prop, auto) {
[] __device__(auto src, auto dst, auto src_prop, auto dst_prop, auto) {
printf("\nsrc ---> %d dst = %d : src_prop = %f dst_prop = %f\n",
static_cast<int>(new_to_original_id_map[src]),
static_cast<int>(new_to_original_id_map[dst]),
static_cast<int>(src),
static_cast<int>(dst),
static_cast<float>(src_prop),
static_cast<float>(dst_prop));
return dst_prop;
Expand Down
31 changes: 11 additions & 20 deletions cpp/examples/graph_partition/vertex_and_edge_partition.cu
Original file line number Diff line number Diff line change
Expand Up @@ -239,25 +239,23 @@ void look_into_vertex_and_edge_partitions(raft::handle_t const& handle,
indices,
major_range_first,
is_weighted,
weights = weights_of_edges_stored_in_this_edge_partition.begin(),
new_to_original_id_map = (*renumber_map).data()] __device__(auto i) {
weights = weights_of_edges_stored_in_this_edge_partition.begin()] __device__(auto i) {
auto v = major_range_first + i;
auto deg_of_v_in_this_edge_partition = offsets[i + 1] - offsets[i];

thrust::for_each(
thrust::seq,
thrust::make_counting_iterator(edge_t{offsets[i]}),
thrust::make_counting_iterator(edge_t{offsets[i + 1]}),
[comm_rank, ep_idx, v, indices, new_to_original_id_map, is_weighted, weights] __device__(
auto pos) {
[comm_rank, ep_idx, v, indices, is_weighted, weights] __device__(auto pos) {
if (is_weighted) {
printf(
"\n[comm_rank = %d local edge partition id = %d] edge: source = %d "
"destination = %d weight = %f\n",
static_cast<int>(comm_rank),
static_cast<int>(ep_idx),
static_cast<int>(new_to_original_id_map[v]),
static_cast<int>(new_to_original_id_map[indices[pos]]),
static_cast<int>(v),
static_cast<int>(indices[pos]),
static_cast<float>(weights[pos]));

} else {
Expand All @@ -266,8 +264,8 @@ void look_into_vertex_and_edge_partitions(raft::handle_t const& handle,
"destination = %d\n",
static_cast<int>(comm_rank),
static_cast<int>(ep_idx),
static_cast<int>(new_to_original_id_map[v]),
static_cast<int>(new_to_original_id_map[indices[pos]]));
static_cast<int>(v),
static_cast<int>(indices[pos]));
}
});
});
Expand All @@ -285,7 +283,6 @@ void look_into_vertex_and_edge_partitions(raft::handle_t const& handle,
major_range_first,
is_weighted,
weights = weights_of_edges_stored_in_this_edge_partition.begin(),
new_to_original_id_map = (*renumber_map).data(),
dcs_nzd_vertices = (*dcs_nzd_vertices),
major_hypersparse_first = (*major_hypersparse_first)] __device__(auto i) {
auto v = dcs_nzd_vertices[i];
Expand All @@ -296,21 +293,15 @@ void look_into_vertex_and_edge_partitions(raft::handle_t const& handle,
thrust::seq,
thrust::make_counting_iterator(edge_t{offsets[major_idx]}),
thrust::make_counting_iterator(edge_t{offsets[major_idx + 1]}),
[comm_rank,
ep_idx,
v,
indices,
new_to_original_id_map,
is_weighted,
weights] __device__(auto pos) {
[comm_rank, ep_idx, v, indices, is_weighted, weights] __device__(auto pos) {
if (is_weighted) {
printf(
"\n[comm_rank = %d local edge partition id = %d] edge: source = %d "
"destination = %d weight = %f\n",
static_cast<int>(comm_rank),
static_cast<int>(ep_idx),
static_cast<int>(new_to_original_id_map[v]),
static_cast<int>(new_to_original_id_map[indices[pos]]),
static_cast<int>(v),
static_cast<int>(indices[pos]),
static_cast<float>(weights[pos]));

} else {
Expand All @@ -319,8 +310,8 @@ void look_into_vertex_and_edge_partitions(raft::handle_t const& handle,
"destination = %d\n",
static_cast<int>(comm_rank),
static_cast<int>(ep_idx),
static_cast<int>(new_to_original_id_map[v]),
static_cast<int>(new_to_original_id_map[indices[pos]]));
static_cast<int>(v),
static_cast<int>(indices[pos]));
}
});
});
Expand Down
2 changes: 1 addition & 1 deletion cpp/examples/multi_gpu_application/mg_graph_algorithms.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -203,5 +203,5 @@ int main(int argc, char** argv)
using weight_t = float;
constexpr bool multi_gpu = true;

run_graph_algos<vertex_t, edge_t, weight_t, multi_gpu>(*handle, csv_graph_file_path, false);
run_graph_algos<vertex_t, edge_t, weight_t, multi_gpu>(*handle, csv_graph_file_path, true);
}
Original file line number Diff line number Diff line change
Expand Up @@ -155,5 +155,5 @@ int main(int argc, char** argv)
using edge_t = int32_t;
using weight_t = float;

run_graph_algos<vertex_t, edge_t, weight_t, multi_gpu>(*handle, argv[1], false);
run_graph_algos<vertex_t, edge_t, weight_t, multi_gpu>(*handle, argv[1], true);
}

0 comments on commit 2f2f192

Please sign in to comment.