]> https://gitweb.dealii.org/ - dealii.git/commitdiff
tests added for coloring multiple nodes with no connections 6144/head
authornivesh <nidhinivesh.d@gmail.com>
Mon, 2 Apr 2018 16:31:42 +0000 (18:31 +0200)
committernivesh <nidhinivesh.d@gmail.com>
Mon, 2 Apr 2018 17:35:56 +0000 (19:35 +0200)
tests/zoltan/zoltan_04.cc [new file with mode: 0644]
tests/zoltan/zoltan_04.output [new file with mode: 0644]

diff --git a/tests/zoltan/zoltan_04.cc b/tests/zoltan/zoltan_04.cc
new file mode 100644 (file)
index 0000000..e9341c8
--- /dev/null
@@ -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 <deal.II/base/graph_coloring.h>
+
+
+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<unsigned int> 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<num_indices; i++)
+    {
+      deallog << i << " " << color_indices[i] << std::endl;
+    }
+}
diff --git a/tests/zoltan/zoltan_04.output b/tests/zoltan/zoltan_04.output
new file mode 100644 (file)
index 0000000..cd0bf5f
--- /dev/null
@@ -0,0 +1,8 @@
+
+DEAL:0::Coloring
+DEAL:0::Number of colors used: 1
+DEAL:0::0 1
+DEAL:0::1 1
+DEAL:0::2 1
+DEAL:0::3 1
+DEAL:0::4 1

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.