mirror of
https://github.com/boostorg/graph.git
synced 2025-05-09 23:14:00 +00:00
Added METIS reader test from Nick Edmonds
[SVN r52244]
This commit is contained in:
parent
cd2f3a3a5c
commit
cbbfe23b81
@ -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/<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 ]
|
||||
|
||||
|
43
test/metis_test.cpp
Normal file
43
test/metis_test.cpp
Normal file
@ -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;
|
||||
}
|
6
test/weighted_graph.gr
Normal file
6
test/weighted_graph.gr
Normal file
@ -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
|
Loading…
x
Reference in New Issue
Block a user