Fork me on GitHub
 All Classes Files Functions Variables Groups Pages
maximal_independent_set.cu
#include <cstddef>
#include <iostream>
// This example computes a maximal independent set (MIS)
// for a 10x10 grid. The graph for the 10x10 grid is
// described by the sparsity pattern of a sparse matrix
// corresponding to a 10x10 Poisson problem.
//
// [1] http://en.wikipedia.org/wiki/Maximal_independent_set
int main(void)
{
size_t N = 10;
// initialize matrix representing 10x10 grid
// allocate storage for the MIS
// compute the MIS
// print MIS as a 2d grid
std::cout << "maximal independent set (marked with Xs)\n";
for (size_t i = 0; i < N; i++)
{
std::cout << " ";
for (size_t j = 0; j < N; j++)
{
std::cout << ((stencil[N * i + j]) ? "X" : "0");
}
std::cout << "\n";
}
return 0;
}