37 namespace algorithms {
81 template< Descriptor descr,
typename OutputType,
typename InputType >
84 const size_t source,
const size_t k,
94 const size_t n =
nrows( A );
95 if( n !=
ncols( A ) ) {
98 if(
size( buf1 ) != n ) {
101 if(
size( u ) != n ) {
113 if(
nnz( u ) != 0 ) {
116 if(
nnz( buf1 ) != 0 ) {
117 ret = ret ? ret :
clear( buf1 );
120 std::cout <<
"grb::algorithms::knn called with source " << source <<
" "
121 <<
"and k " << k <<
".\n";
123 ret = ret ? ret :
setElement( buf1,
true, source );
130 >( u, A, k, buf1, buf1, ring );
134 >( u, A, k, buf1, buf1, ring );
An ALP/GraphBLAS matrix.
Definition: matrix.hpp:71
A generalised semiring.
Definition: semiring.hpp:186
A GraphBLAS vector.
Definition: vector.hpp:64
Standard identitity for the logical or operator.
Definition: identities.hpp:151
Standard identity for the logical AND operator.
Definition: identities.hpp:178
The logical and.
Definition: ops.hpp:492
The logical or.
Definition: ops.hpp:464
The main header to include in order to use the ALP/GraphBLAS API.
size_t nnz(const Vector< DataType, backend, Coords > &x) noexcept
Request the number of nonzeroes in a given vector.
Definition: io.hpp:479
size_t size(const Vector< DataType, backend, Coords > &x) noexcept
Request the size of a given vector.
Definition: io.hpp:235
size_t ncols(const Matrix< InputType, backend, RIT, CIT, NIT > &A) noexcept
Requests the column size of a given matrix.
Definition: io.hpp:339
size_t capacity(const Vector< InputType, backend, Coords > &x) noexcept
Queries the capacity of the given ALP/GraphBLAS container.
Definition: io.hpp:388
RC setElement(Vector< DataType, backend, Coords > &x, const T val, const size_t i, const Phase &phase=EXECUTE, const typename std::enable_if< !grb::is_object< DataType >::value &&!grb::is_object< T >::value, void >::type *const =nullptr)
Sets the element of a given vector at a given position to a given value.
Definition: io.hpp:1128
size_t nrows(const Matrix< InputType, backend, RIT, CIT, NIT > &A) noexcept
Requests the row size of a given matrix.
Definition: io.hpp:286
RC clear(Vector< DataType, backend, Coords > &x) noexcept
Clears a given vector of all nonzeroes.
Definition: io.hpp:574
Implements the matrix powers kernel over arbitrary semirings.
RC mpv(Vector< IOType > &u, const Matrix< InputType > &A, const size_t k, const Vector< IOType > &v, Vector< IOType > &temp, const Ring &ring)
The matrix powers kernel.
Definition: mpv.hpp:94
RC knn(Vector< OutputType > &u, const Matrix< InputType > &A, const size_t source, const size_t k, Vector< bool > &buf1)
Given a graph and a source vertex, indicates which vertices are contained within k hops.
Definition: knn.hpp:82
static constexpr Descriptor transpose_matrix
Transposes the input matrix prior to applying it.
Definition: descriptors.hpp:71
static constexpr Descriptor add_identity
For any call to a matrix computation, the input matrix A is instead interpreted as ,...
Definition: descriptors.hpp:159
The ALP/GraphBLAS namespace.
Definition: graphblas.hpp:452
RC
Return codes of ALP primitives.
Definition: rc.hpp:47
@ ILLEGAL
A call to a primitive has determined that one of its arguments was illegal as per the specification o...
Definition: rc.hpp:143
@ MISMATCH
One or more of the ALP/GraphBLAS objects passed to the primitive that returned this error have mismat...
Definition: rc.hpp:90
@ SUCCESS
Indicates the primitive has executed successfully.
Definition: rc.hpp:54