From 057b04c1da07e8130594b3e4e0e6054e1f03803b Mon Sep 17 00:00:00 2001
From: nivesh <nidhinivesh.d@gmail.com>
Date: Mon, 2 Apr 2018 18:31:42 +0200
Subject: [PATCH] tests added for coloring multiple nodes with no connections

---
 tests/zoltan/zoltan_04.cc     | 74 +++++++++++++++++++++++++++++++++++
 tests/zoltan/zoltan_04.output |  8 ++++
 2 files changed, 82 insertions(+)
 create mode 100644 tests/zoltan/zoltan_04.cc
 create mode 100644 tests/zoltan/zoltan_04.output

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 <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
index 0000000000..cd0bf5f6b8
--- /dev/null
+++ b/tests/zoltan/zoltan_04.output
@@ -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
-- 
2.39.5