metis_test.cpp 1.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. // Copyright (C) 2004-2008 The Trustees of Indiana University.
  2. // Use, modification and distribution is subject to the Boost Software
  3. // License, Version 1.0. (See accompanying file LICENSE_1_0.txt or copy at
  4. // http://www.boost.org/LICENSE_1_0.txt)
  5. #include <boost/graph/breadth_first_search.hpp>
  6. #include <boost/graph/adjacency_list.hpp>
  7. #include <boost/graph/metis.hpp>
  8. #include <fstream>
  9. #ifdef BOOST_NO_EXCEPTIONS
  10. void
  11. boost::throw_exception(std::exception const& ex)
  12. {
  13. std::cout << ex.what() << std::endl;
  14. abort();
  15. }
  16. #endif
  17. using namespace boost;
  18. /* An undirected graph with distance values stored on the vertices. */
  19. typedef adjacency_list<vecS, vecS, undirectedS,
  20. property<vertex_distance_t, std::size_t> >
  21. Graph;
  22. int main(int argc, char* argv[])
  23. {
  24. // Parse command-line options
  25. const char* filename = "weighted_graph.gr";
  26. if (argc > 1) filename = argv[1];
  27. // Open the METIS input file
  28. std::ifstream in(filename);
  29. assert (in.good());
  30. graph::metis_reader reader(in);
  31. // Load the graph using the default distribution
  32. Graph g(reader.begin(), reader.end(),
  33. reader.num_vertices());
  34. return 0;
  35. }