简体   繁体   English

如何使用Boost Graph Library布置顶点?

[英]How can I use the Boost Graph Library to lay out verticies?

I'm trying to lay out vertices using the Boost Graph Library. 我正在尝试使用Boost Graph Library布置顶点。 However, I'm running into some compilation issues which I'm unsure about. 但是,我遇到了一些不确定的编译问题。 Am I using the BGL in an improper manner? 我是否以不当方式使用BGL? My code is: 我的代码是:

PositionVec position_vec(2);
PositionMap position(position_vec.begin(), get(vertex_index, g));
int iterations = 100;
double width = 100.0;
double height = 100.0;
minstd_rand gen;
rectangle_topology<> topology(gen, 0, 0, 100, 100); 
fruchterman_reingold_force_directed_layout(g, position, topology); //Compile fails on this line

The diagnostics produced by clang++(I've also tried GCC) are: clang ++(我也尝试过GCC)产生的诊断结果是:

In file included from test.cpp:2:
/Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:95:3: error: no member named 'dimensions' in
      'boost::simple_point<double>'
  BOOST_STATIC_ASSERT (Point::dimensions == 2);
  ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
In file included from test.cpp:2:
In file included from /Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:13:
In file included from /Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/graph_traits.hpp:15:
In file included from /Volumes/Data/mike/Downloads/boost_1_43_0/boost/tuple/tuple.hpp:24:
/Volumes/Data/mike/Downloads/boost_1_43_0/boost/static_assert.hpp:118:49: note: instantiated from:
      sizeof(::boost::STATIC_ASSERTION_FAILURE< BOOST_STATIC_ASSERT_BOOL_CAST( B ) >)>\
                                                ^
In file included from test.cpp:2:
/Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:95:3: note: instantiated from:
  BOOST_STATIC_ASSERT (Point::dimensions == 2);
  ^                    ~~~~~~~
/Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:95:31: note: instantiated from:
  BOOST_STATIC_ASSERT (Point::dimensions == 2);
                       ~~~~~~~^
/Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:417:19: note: in instantiation of template class
      'boost::grid_force_pairs<boost::rectangle_topology<boost::random::linear_congruential<int, 48271, 0, 2147483647, 399268537> >,
      boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::simple_point<double> *,
      std::vector<boost::simple_point<double>, std::allocator<boost::simple_point<double> > > >,
      boost::vec_adj_list_vertex_id_map<boost::property<boost::vertex_name_t, std::basic_string<char>, boost::no_property>, unsigned
      long>, boost::simple_point<double>, boost::simple_point<double> &> >' requested here
                  make_grid_force_pairs(topology, position, g)),
                  ^
/Volumes/Data/mike/Downloads/boost_1_43_0/boost/graph/fruchterman_reingold.hpp:431:3: note: in instantiation of function template
      specialization
      'boost::fruchterman_reingold_force_directed_layout<boost::rectangle_topology<boost::random::linear_congruential<int, 48271, 0,
      2147483647, 399268537> >, boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
      boost::property<boost::vertex_name_t, std::basic_string<char>, boost::no_property>, boost::no_property, boost::no_property,
      boost::listS>, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::simple_point<double> *,
      std::vector<boost::simple_point<double>, std::allocator<boost::simple_point<double> > > >,
      boost::vec_adj_list_vertex_id_map<boost::property<boost::vertex_name_t, std::basic_string<char>, boost::no_property>, unsigned
      long>, boost::simple_point<double>, boost::simple_point<double> &>, boost::square_distance_attractive_force,
      boost::attractive_force_t, boost::no_property>' requested here
  fruchterman_reingold_force_directed_layout
  ^
test.cpp:48:3: note: in instantiation of function template specialization
      'boost::fruchterman_reingold_force_directed_layout<boost::rectangle_topology<boost::random::linear_congruential<int, 48271, 0,
      2147483647, 399268537> >, boost::adjacency_list<boost::listS, boost::vecS, boost::undirectedS,
      boost::property<boost::vertex_name_t, std::basic_string<char>, boost::no_property>, boost::no_property, boost::no_property,
      boost::listS>, boost::iterator_property_map<__gnu_cxx::__normal_iterator<boost::simple_point<double> *,
      std::vector<boost::simple_point<double>, std::allocator<boost::simple_point<double> > > >,
      boost::vec_adj_list_vertex_id_map<boost::property<boost::vertex_name_t, std::basic_string<char>, boost::no_property>, unsigned
      long>, boost::simple_point<double>, boost::simple_point<double> &> >' requested here
  fruchterman_reingold_force_directed_layout(g, position, topology);
  ^
1 error generated.

I can never make heads or tails of BGL code either :p When I do need to use it for something I usually check out the included unit-test/example file for the function I want to use. :p当我确实需要用它来做某事时,我通常都不会做BGL代码的头或尾。通常,我会为要使用的功能签出随附的单元测试/示例文件。 Many times there is an example in there that can be easily modified. 很多时候那里有一个可以轻易修改的例子。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM