From 2b1ac70272c2f9a08d688496c4ae88104acb2c62 Mon Sep 17 00:00:00 2001 From: jnke2016 Date: Thu, 2 Jan 2025 17:37:56 -0800 Subject: [PATCH] fix style --- cpp/src/community/leiden_impl.cuh | 63 +++++++++---------- .../cugraph/cugraph/dask/community/leiden.py | 2 +- 2 files changed, 32 insertions(+), 33 deletions(-) diff --git a/cpp/src/community/leiden_impl.cuh b/cpp/src/community/leiden_impl.cuh index ecd3d6b853..cdc119ad32 100644 --- a/cpp/src/community/leiden_impl.cuh +++ b/cpp/src/community/leiden_impl.cuh @@ -1,5 +1,5 @@ /* - * Copyright (c) 2022-2024, NVIDIA CORPORATION. + * Copyright (c) 2022-2025, NVIDIA CORPORATION. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -718,53 +718,52 @@ std::pair leiden( rmm::device_uvector unique_cluster_ids(local_num_verts, handle.get_stream()); thrust::copy(handle.get_thrust_policy(), - clustering, - clustering + local_num_verts, - unique_cluster_ids.begin()); + clustering, + clustering + local_num_verts, + unique_cluster_ids.begin()); thrust::sort(handle.get_thrust_policy(), unique_cluster_ids.begin(), unique_cluster_ids.end()); - unique_cluster_ids.resize( - thrust::distance( - unique_cluster_ids.begin(), - thrust::unique(handle.get_thrust_policy(), unique_cluster_ids.begin(), unique_cluster_ids.end())), - handle.get_stream()); - + unique_cluster_ids.resize(thrust::distance(unique_cluster_ids.begin(), + thrust::unique(handle.get_thrust_policy(), + unique_cluster_ids.begin(), + unique_cluster_ids.end())), + handle.get_stream()); + if constexpr (multi_gpu) { auto recvcounts = cugraph::host_scalar_allgather( handle.get_comms(), unique_cluster_ids.size(), handle.get_stream()); std::vector displacements(recvcounts.size()); std::exclusive_scan(recvcounts.begin(), recvcounts.end(), displacements.begin(), size_t{0}); - rmm::device_uvector allgathered_unique_cluster_ids(displacements.back() + recvcounts.back(), - handle.get_stream()); + rmm::device_uvector allgathered_unique_cluster_ids( + displacements.back() + recvcounts.back(), handle.get_stream()); cugraph::device_allgatherv(handle.get_comms(), - unique_cluster_ids.begin(), - allgathered_unique_cluster_ids.begin(), - recvcounts, - displacements, - handle.get_stream()); - - thrust::sort( - handle.get_thrust_policy(), - allgathered_unique_cluster_ids.begin(), - allgathered_unique_cluster_ids.end()); + unique_cluster_ids.begin(), + allgathered_unique_cluster_ids.begin(), + recvcounts, + displacements, + handle.get_stream()); + + thrust::sort(handle.get_thrust_policy(), + allgathered_unique_cluster_ids.begin(), + allgathered_unique_cluster_ids.end()); allgathered_unique_cluster_ids.resize( - thrust::distance( - allgathered_unique_cluster_ids.begin(), - thrust::unique(handle.get_thrust_policy(), - allgathered_unique_cluster_ids.begin(), - allgathered_unique_cluster_ids.end())), - handle.get_stream()); - - detail::relabel_cluster_ids(handle, allgathered_unique_cluster_ids, clustering, local_num_verts); + thrust::distance(allgathered_unique_cluster_ids.begin(), + thrust::unique(handle.get_thrust_policy(), + allgathered_unique_cluster_ids.begin(), + allgathered_unique_cluster_ids.end())), + handle.get_stream()); + + detail::relabel_cluster_ids( + handle, allgathered_unique_cluster_ids, clustering, local_num_verts); } else { - detail::relabel_cluster_ids(handle, unique_cluster_ids, clustering, local_num_verts); + detail::relabel_cluster_ids( + handle, unique_cluster_ids, clustering, local_num_verts); } - return std::make_pair(dendrogram->num_levels(), modularity); } diff --git a/python/cugraph/cugraph/dask/community/leiden.py b/python/cugraph/cugraph/dask/community/leiden.py index beff0b59b5..1c327853c7 100644 --- a/python/cugraph/cugraph/dask/community/leiden.py +++ b/python/cugraph/cugraph/dask/community/leiden.py @@ -1,4 +1,4 @@ -# Copyright (c) 2022-2024, NVIDIA CORPORATION. +# Copyright (c) 2022-2025, NVIDIA CORPORATION. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License.