Skip to content

Commit

Permalink
Coarsening symmetric graphs leads to slightly asymmetric edge weights (
Browse files Browse the repository at this point in the history
…#2080)

If you coarsen a symmetric (i.e. undirected) graph, the output graph should be symmetric as well.

However, due to limited floating point resolution, edge weights can be slightly asymmetric after coarsening (e.g. for a triplet of src, dst, weight, we may see (1, 2, 1.0) and its reverse edge (2, 1, 1.0 + 1e-7), this is only approximately symmetric and not strictly symmetric).

This PR fixes this by coarsening using only the lower triangular part (including the diagonal) after relabeling and reconstructing a symmetric graph from the lower triangular part (if the input graph is symmetric).

Authors:
  - Seunghwa Kang (https://github.com/seunghwak)

Approvers:
  - Chuck Hastings (https://github.com/ChuckHastings)

URL: #2080
  • Loading branch information
seunghwak authored Feb 22, 2022
1 parent 4679a28 commit f80bce7
Show file tree
Hide file tree
Showing 5 changed files with 458 additions and 177 deletions.
8 changes: 4 additions & 4 deletions cpp/include/cugraph/detail/decompress_matrix_partition.cuh
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright (c) 2020-2021, NVIDIA CORPORATION.
* Copyright (c) 2020-2022, NVIDIA CORPORATION.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
Expand Down Expand Up @@ -184,9 +184,9 @@ template <typename vertex_t, typename edge_t, typename weight_t, bool multi_gpu>
void decompress_matrix_partition_to_edgelist(
raft::handle_t const& handle,
matrix_partition_device_view_t<vertex_t, edge_t, weight_t, multi_gpu> const matrix_partition,
vertex_t* edgelist_majors /* [INOUT] */,
vertex_t* edgelist_minors /* [INOUT] */,
std::optional<weight_t*> edgelist_weights /* [INOUT] */,
vertex_t* edgelist_majors /* [OUT] */,
vertex_t* edgelist_minors /* [OUT] */,
std::optional<weight_t*> edgelist_weights /* [OUT] */,
std::optional<std::vector<vertex_t>> const& segment_offsets)
{
auto number_of_edges = matrix_partition.get_number_of_edges();
Expand Down
10 changes: 10 additions & 0 deletions cpp/include/cugraph/detail/graph_utils.cuh
Original file line number Diff line number Diff line change
Expand Up @@ -86,5 +86,15 @@ struct is_first_in_run_t {
}
};

template <typename vertex_t>
struct is_first_in_run_pair_t {
vertex_t const* vertices0{nullptr};
vertex_t const* vertices1{nullptr};
__device__ bool operator()(size_t i) const
{
return (i == 0) || ((vertices0[i - 1] != vertices0[i]) || (vertices1[i - 1] != vertices1[i]));
}
};

} // namespace detail
} // namespace cugraph
Loading

0 comments on commit f80bce7

Please sign in to comment.