seams-core v2.14.0
libyodaLib, the C++ engine of d-SEAMS
Loading...
Searching...
No Matches
seams::Neighbours Class Reference

Owned neighbour list. More...

#include <include/seams.hpp>

Inheritance diagram for seams::Neighbours:

Public Member Functions

std::size_t nnz () const
 Number of neighbour pairs, omitting self.
std::vector< int > degrees () const
 Degree of each atom.
std::vector< std::pair< int, int > > pairs () const
 Directed pairs (atom, neighbour).
ChordlessCycles chordless (int size) const
 Chordless cycles of one length on this graph.
Public Member Functions inherited from seams::detail::Handle< seams_neighbours, seams_neighbours_destroy >
 Handle ()=default
Handle & operator= (const Handle &)=delete
 ~Handle ()
 operator bool () const noexcept

Additional Inherited Members

Protected Member Functions inherited from seams::detail::Handle< seams_neighbours, seams_neighbours_destroy >
seams_neighbours * get () const noexcept
void reset () noexcept
Protected Attributes inherited from seams::detail::Handle< seams_neighbours, seams_neighbours_destroy >
seams_neighbours * ptr_

Detailed Description

Owned neighbour list.

Move-only. Destruction frees the C handle. The self entry is omitted. A neighbour list is not safe to share across threads.

Definition at line 640 of file seams.hpp.

Member Function Documentation

◆ chordless()

ChordlessCycles seams::Neighbours::chordless ( int size) const
inlinenodiscard

Chordless cycles of one length on this graph.

Parameters
sizeCycle length, from 3 through 12.
Returns
The rows and the per-atom counts of seams_rings_chordless.

Definition at line 709 of file seams.hpp.

709 {
710 ChordlessCycles out;
711 out.size = size;
712 out.per_atom.resize(static_cast<std::size_t>(seams_neighbours_count(get())));
713 std::size_t count = 0;
714 detail::check(seams_rings_chordless(get(), size, nullptr, 0, &count, out.per_atom.data(),
715 out.per_atom.size()),
716 get());
717 out.atoms.resize(count * static_cast<std::size_t>(size));
718 detail::check(seams_rings_chordless(get(), size, out.atoms.data(), out.atoms.size(), &count,
719 nullptr, 0),
720 get());
721 return out;
722 }
SEAMS_API int seams_neighbours_count(const seams_neighbours *nb)
Number of neighbour rows, as an int.
SEAMS_API seams_status seams_rings_chordless(const seams_neighbours *nb, int size, int *rings, size_t rings_len, size_t *n_rings, int *per_atom, size_t per_atom_len)
Chordless cycles of one size.
void check(int status, const void *handle)
Definition seams.hpp:557

◆ degrees()

std::vector< int > seams::Neighbours::degrees ( ) const
inlinenodiscard

Degree of each atom.

Returns
One integer per atom. The self entry is not counted.

Definition at line 659 of file seams.hpp.

659 {
660 std::size_t n_offsets = 0;
661 std::size_t count = 0;
662 detail::check(seams_neighbours_copy(get(), nullptr, 0, &n_offsets, nullptr, 0, &count), get());
663 std::vector<int> offsets(n_offsets);
664 std::vector<int> cols(count);
665 detail::check(seams_neighbours_copy(get(), offsets.data(), offsets.size(), &n_offsets,
666 cols.data(), cols.size(), &count),
667 get());
668 std::vector<int> degree;
669 if (n_offsets > 0) {
670 degree.reserve(n_offsets - 1);
671 for (std::size_t i = 0; i + 1 < n_offsets; ++i) {
672 degree.push_back(offsets[i + 1] - offsets[i]);
673 }
674 }
675 return degree;
676 }
SEAMS_API seams_status seams_neighbours_copy(const seams_neighbours *nb, int *offsets, size_t offsets_cap, size_t *n_offsets, int *cols, size_t cols_cap, size_t *nnz)
Copy the neighbour CSR into caller buffers.

◆ nnz()

std::size_t seams::Neighbours::nnz ( ) const
inlinenodiscard

Number of neighbour pairs, omitting self.

Returns
The pair count.

Definition at line 648 of file seams.hpp.

648 {
649 std::size_t n_offsets = 0;
650 std::size_t count = 0;
651 detail::check(seams_neighbours_copy(get(), nullptr, 0, &n_offsets, nullptr, 0, &count), get());
652 return count;
653 }

◆ pairs()

std::vector< std::pair< int, int > > seams::Neighbours::pairs ( ) const
inlinenodiscard

Directed pairs (atom, neighbour).

Returns
One pair per stored column. Self is omitted.

Definition at line 682 of file seams.hpp.

682 {
683 std::size_t n_offsets = 0;
684 std::size_t count = 0;
685 detail::check(seams_neighbours_copy(get(), nullptr, 0, &n_offsets, nullptr, 0, &count), get());
686 std::vector<int> offsets(n_offsets);
687 std::vector<int> cols(count);
688 detail::check(seams_neighbours_copy(get(), offsets.data(), offsets.size(), &n_offsets,
689 cols.data(), cols.size(), &count),
690 get());
691 std::vector<std::pair<int, int>> out;
692 out.reserve(count);
693 for (std::size_t atom = 0; atom + 1 < n_offsets; ++atom) {
694 for (int cursor = offsets[atom]; cursor < offsets[atom + 1]; ++cursor) {
695 const int neighbour = cols[static_cast<std::size_t>(cursor)];
696 if (neighbour != static_cast<int>(atom)) {
697 out.emplace_back(static_cast<int>(atom), neighbour);
698 }
699 }
700 }
701 return out;
702 }

The documentation for this class was generated from the following file: