From cbbfe23b81b44b86b4b914632036e2ed04fa190e Mon Sep 17 00:00:00 2001 From: Jeremiah Willcock Date: Tue, 7 Apr 2009 21:05:25 +0000 Subject: [PATCH] Added METIS reader test from Nick Edmonds [SVN r52244] --- test/Jamfile.v2 | 3 +++ test/metis_test.cpp | 43 ++++++++++++++++++++++++++++++++++++++++++ test/weighted_graph.gr | 6 ++++++ 3 files changed, 52 insertions(+) create mode 100644 test/metis_test.cpp create mode 100644 test/weighted_graph.gr diff --git a/test/Jamfile.v2 b/test/Jamfile.v2 index cfa8bd8b..c1562ee2 100644 --- a/test/Jamfile.v2 +++ b/test/Jamfile.v2 @@ -15,6 +15,8 @@ path-constant PLANAR_INPUT_FILES : ./planar_input_graphs ; path-constant CYCLE_RATIO_INPUT_FILE : ./cycle_ratio_s382.90.dot ; +path-constant METIS_INPUT_FILE : ./weighted_graph.gr ; + if [ modules.peek : EXPAT_INCLUDE ] && [ modules.peek : EXPAT_LIBPATH ] { optional_tests += [ run graphml_test.cpp ../build//boost_graph : : "graphml_test.xml" ] ; @@ -56,6 +58,7 @@ test-suite graph_test : [ run graphviz_test.cpp /boost/test//boost_test_exec_monitor/static ../build//boost_graph ] + [ run metis_test.cpp : $(METIS_INPUT_FILE) ] [ run gursoy_atun_layout_test.cpp ] [ run layout_test.cpp : : : always_show_run_output intel:off ] diff --git a/test/metis_test.cpp b/test/metis_test.cpp new file mode 100644 index 00000000..fd93868b --- /dev/null +++ b/test/metis_test.cpp @@ -0,0 +1,43 @@ +// Copyright (C) 2004-2008 The Trustees of Indiana University. + +// Use, modification and distribution is subject to the Boost Software +// License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at +// http://www.boost.org/LICENSE_1_0.txt) + +#include +#include +#include +#include + +#ifdef BOOST_NO_EXCEPTIONS +void +boost::throw_exception(std::exception const& ex) +{ + std::cout << ex.what() << std::endl; + abort(); +} +#endif + +using namespace boost; + +/* An undirected graph with distance values stored on the vertices. */ +typedef adjacency_list > + Graph; + +int main(int argc, char* argv[]) +{ + // Parse command-line options + const char* filename = "weighted_graph.gr"; + if (argc > 1) filename = argv[1]; + + // Open the METIS input file + std::ifstream in(filename); + graph::metis_reader reader(in); + + // Load the graph using the default distribution + Graph g(reader.begin(), reader.end(), + reader.num_vertices()); + + return 0; +} diff --git a/test/weighted_graph.gr b/test/weighted_graph.gr new file mode 100644 index 00000000..1aaa2618 --- /dev/null +++ b/test/weighted_graph.gr @@ -0,0 +1,6 @@ +5 9 1 +3 1 +2 2 4 1 5 2 +2 7 4 3 +5 1 +1 1 2 1 \ No newline at end of file