Boost logo

Boost-Commit :

Subject: [Boost-commit] svn:boost r52244 - trunk/libs/graph/test
From: jewillco_at_[hidden]
Date: 2009-04-07 17:05:26


Author: jewillco
Date: 2009-04-07 17:05:25 EDT (Tue, 07 Apr 2009)
New Revision: 52244
URL: http://svn.boost.org/trac/boost/changeset/52244

Log:
Added METIS reader test from Nick Edmonds
Added:
   trunk/libs/graph/test/metis_test.cpp (contents, props changed)
   trunk/libs/graph/test/weighted_graph.gr (contents, props changed)
Text files modified:
   trunk/libs/graph/test/Jamfile.v2 | 3 +++
   1 files changed, 3 insertions(+), 0 deletions(-)

Modified: trunk/libs/graph/test/Jamfile.v2
==============================================================================
--- trunk/libs/graph/test/Jamfile.v2 (original)
+++ trunk/libs/graph/test/Jamfile.v2 2009-04-07 17:05:25 EDT (Tue, 07 Apr 2009)
@@ -15,6 +15,8 @@
 
 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 @@
     [ run graphviz_test.cpp
             /boost/test//boost_test_exec_monitor/<link>static
             ../build//boost_graph ]
+ [ run metis_test.cpp : $(METIS_INPUT_FILE) ]
     [ run gursoy_atun_layout_test.cpp ]
     [ run layout_test.cpp : : : <test-info>always_show_run_output <toolset>intel:<debug-symbols>off ]
 

Added: trunk/libs/graph/test/metis_test.cpp
==============================================================================
--- (empty file)
+++ trunk/libs/graph/test/metis_test.cpp 2009-04-07 17:05:25 EDT (Tue, 07 Apr 2009)
@@ -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 <boost/graph/breadth_first_search.hpp>
+#include <boost/graph/adjacency_list.hpp>
+#include <boost/graph/metis.hpp>
+#include <fstream>
+
+#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<vecS, vecS, undirectedS,
+ property<vertex_distance_t, std::size_t> >
+ 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;
+}

Added: trunk/libs/graph/test/weighted_graph.gr
==============================================================================
--- (empty file)
+++ trunk/libs/graph/test/weighted_graph.gr 2009-04-07 17:05:25 EDT (Tue, 07 Apr 2009)
@@ -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


Boost-Commit list run by bdawes at acm.org, david.abrahams at rcn.com, gregod at cs.rpi.edu, cpdaniel at pacbell.net, john at johnmaddock.co.uk