58 using BaseVertexID = std::remove_cv_t<VertexID>;
60 static_assert(std::is_integral_v<BaseVertexID>,
61 "The VertexID must be an integral type");
68 using Offset =
typename Neighbours::size_type;
71 using Start = std::vector<Offset>;
105 bool expandExistingIdxMap =
false);
119 return this->csr_.startPointers();
126 return this->csr_.columnIndices();
136 template <
typename Ret = const Start&>
139 return this->csr_.compressedIndexMap();
143 template <
class MessageBufferType>
144 void write(MessageBufferType& buffer)
const
146 this->csr_.write(buffer);
150 template <
class MessageBufferType>
151 void read(MessageBufferType& buffer)
157 .add(other.maxRowID(),
159 other.coordinateFormatRowIndices(),
160 other.columnIndices());
174 void add(VertexID v1, VertexID v2);
189 void add(VertexID maxRowIdx,
204 bool isValid()
const;
207 std::optional<BaseVertexID> maxRow()
const;
210 std::optional<BaseVertexID> maxCol()
const;
213 typename Neighbours::size_type numContributions()
const;
229 std::optional<VertexID> max_i_{};
232 std::optional<VertexID> max_j_{};
257 void merge(
const Connections& conns,
258 const Offset maxNumVertices,
259 const bool expandExistingIdxMap);
265 BaseVertexID maxRowID()
const;
268 BaseVertexID maxColID()
const;
271 const Start& startPointers()
const;
279 Neighbours coordinateFormatRowIndices()
const;
281 template <
typename Ret = const Start&>
282 std::enable_if_t<TrackCompressedIdx, Ret> compressedIndexMap()
const
284 return this->compressedIdx_;
288 template <
class MessageBufferType>
289 void write(MessageBufferType& buffer)
const
291 this->writeVector(this->ia_, buffer);
292 this->writeVector(this->ja_, buffer);
294 if constexpr (TrackCompressedIdx) {
295 this->writeVector(this->compressedIdx_, buffer);
298 buffer.write(this->numRows_);
299 buffer.write(this->numCols_);
303 template <
class MessageBufferType>
304 void read(MessageBufferType& buffer)
306 this->readVector(buffer, this->ia_);
307 this->readVector(buffer, this->ja_);
309 if constexpr (TrackCompressedIdx) {
310 this->readVector(buffer, this->compressedIdx_);
313 buffer.read(this->numRows_);
314 buffer.read(this->numCols_);
321 struct EmptyPlaceHolder {};
335 std::conditional_t<TrackCompressedIdx, Start, EmptyPlaceHolder> compressedIdx_{};
338 BaseVertexID numRows_{};
342 BaseVertexID numCols_{};
348 template <
typename T,
class A,
class MessageBufferType>
349 void writeVector(
const std::vector<T,A>& vec,
350 MessageBufferType& buffer)
const
352 const auto n = vec.size();
355 for (
const auto& x : vec) {
360 template <
class MessageBufferType,
typename T,
class A>
361 void readVector(MessageBufferType& buffer,
362 std::vector<T,A>& vec)
364 auto n = 0 * vec.size();
369 for (
auto& x : vec) {
408 BaseVertexID maxRowID,
409 BaseVertexID maxColID,
410 bool expandExistingIdxMap);
422 void compress(
const Offset maxNumVertices);
430 void sortColumnIndicesPerRow();
441 void condenseDuplicates();
460 void preparePushbackRowGrouping(
const int numRows,
474 void groupAndTrackColumnIndicesByRow(
const Neighbours& rowIdx,
503 void condenseAndTrackUniqueColumnsForSingleRow(
typename Neighbours::const_iterator begin,
504 typename Neighbours::const_iterator end);
515 void remapCompressedIndex(
Start&& compressedIdx,
516 std::optional<typename Start::size_type> numOrigNNZ = std::nullopt);
521 Connections uncompressed_;
std::enable_if_t< TrackCompressedIdx, Ret > compressedIndexMap() const
Read-only access to mapping from input order vertex pairs to compressed structure's edge index (locat...
Definition CSRGraphFromCoordinates.hpp:137
void compress(Offset maxNumVertices, bool expandExistingIdxMap=false)
Form CSR adjacency matrix representation of input graph from connections established in previous call...
Definition CSRGraphFromCoordinates_impl.hpp:583