From: nivesh Date: Mon, 2 Apr 2018 16:31:42 +0000 (+0200) Subject: tests added for coloring multiple nodes with no connections X-Git-Tag: v9.0.0-rc1~247^2 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=refs%2Fpull%2F6144%2Fhead;p=dealii.git tests added for coloring multiple nodes with no connections --- diff --git a/tests/zoltan/zoltan_04.cc b/tests/zoltan/zoltan_04.cc new file mode 100644 index 0000000000..e9341c8bd4 --- /dev/null +++ b/tests/zoltan/zoltan_04.cc @@ -0,0 +1,74 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2004 - 2017 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +/* + * check GraphColoring::color_sparsity_pattern with 5 nodes with + * no connections with each other. All nodes will be colored with + * one color. + */ + + +#include "../tests.h" +#include + + +void fill_graph (DynamicSparsityPattern &graph) +{ + //Edges in only one direction + graph.add(0,0); + graph.add(1,1); + graph.add(2,2); + graph.add(3,3); + graph.add(4,4); +} + + +int main (int argc, char **argv) +{ + //Initialize MPI and Zoltan + Utilities::MPI::MPI_InitFinalize mpi_initialization (argc, argv); + MPILogInitAll all; + + //Number of nodes + unsigned int num_indices = 5; + + //Create temporary object to hold graph connection info. + DynamicSparsityPattern dynamic_sparse_graph; + dynamic_sparse_graph.reinit(num_indices,num_indices); + + //fill dynamic sparsity pattern + fill_graph(dynamic_sparse_graph); + + //Create sparity pattern to hold graph connection info. + SparsityPattern sp_graph; + sp_graph.copy_from(dynamic_sparse_graph); + + Assert( num_indices == sp_graph.n_rows() , ExcInternalError() ); + + std::vector color_indices; + unsigned int num_colors; + + color_indices.resize(num_indices); + num_colors = GraphColoring::color_sparsity_pattern (sp_graph, color_indices); + + //color + deallog << "Coloring" << std::endl; + deallog << "Number of colors used: " << num_colors << std::endl; + for (unsigned int i=0; i