升力定向布局问题
Boost force directed layout problem
我是boost库的新手,我试图从boost文档网站应用强制定向布局,但当我试图编译我的代码时,我遇到了这样的错误:
错误:没有匹配的函数调用
‘random_graph_layout(MyGraph&, CoordSqMap&, double, double, double, double, boost::minstd_rand&)’
错误:没有匹配的函数调用
‘fruchterman_reingold_force_directed_layout(MyGraph&, CoordSqMap&, double&, double&, boost::bgl_named_params<progress_cooling, boost::cooling_t, boost::no_property>)’
我已经附上了我的代码。
#include <boost/graph/fruchterman_reingold.hpp>
#include <boost/graph/random_layout.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/simple_point.hpp>
#include <boost/lexical_cast.hpp>
#include <string>
#include <iostream>
#include <map>
#include <vector>
#include <boost/random/linear_congruential.hpp>
#include <boost/progress.hpp>
#include <boost/shared_ptr.hpp>
#include <boost/graph/small_world_generator.hpp>
#include <boost/random/linear_congruential.hpp>
using namespace boost;
struct decomposition_index_t{
typedef vertex_property_tag kind;
};
struct coordinates_sq_t{
typedef vertex_property_tag kind;
};
struct coordinates_circle_t{
typedef vertex_property_tag kind;
};
template<typename T>
struct Polar {
T rad;
T angle;
};
struct VParams {
int a;
double b;
long c;
// std::complex<double> d;
};
typedef adjacency_list<vecS, vecS, undirectedS,
property<vertex_name_t, std::string,
property<decomposition_index_t, int,
property<coordinates_sq_t, simple_point<double>,
property<coordinates_circle_t, Polar<double>,
VParams > > > > > MyGraph;
typedef property_map<MyGraph,coordinates_sq_t>::type CoordSqMap;
typedef property_map<MyGraph,coordinates_circle_t>::type CoordCMap;
typedef graph_traits<MyGraph>::vertex_descriptor Vertex;
class progress_cooling : public linear_cooling<double>
{
typedef linear_cooling<double> inherited;
public:
explicit progress_cooling(std::size_t iterations) : inherited(iterations)
{
display.reset(new progress_display(iterations + 1, std::cerr));
}
double operator()()
{
++(*display);
return inherited::operator()();
}
private:
shared_ptr<boost::progress_display> display;
};
typedef boost::small_world_iterator<boost::minstd_rand, MyGraph> SWGen;
int main()
{
boost::minstd_rand gen;
// Create graph with 10000 nodes
int nodecount = 90000;
MyGraph g(SWGen(gen, nodecount, 6, 0.03), SWGen(), nodecount);
double width = 2;
double height = 2;
CoordSqMap position = get(coordinates_sq_t(), g);
random_graph_layout(g, position, -width/2, width/2, -height/2, height/2, gen);
int iterations = 20;
fruchterman_reingold_force_directed_layout
(g, position, width, height,
cooling(progress_cooling(iterations)) /* .force_pairs(all_force_pairs()) */ );
return 0;
}
我尽了我最大的可能的方法来解决这个问题,但还是做不到。你对此有什么建议吗?你有一个可行的示例代码为Kamada kawai弹簧布局。
如果您使用的是相对较新的版本,但不是最新版本,则在某些版本中存在一个错误,即函数的接口已经更新,但文档没有更新。正确的文档在http://www.boost.org/doc/libs/1_47_0/libs/graph/doc/fruchterman_reingold.html(以及其他当前的BGL文档页面)。
相关文章:
- 警告处理为错误这里有什么问题
- 最小硬币更换问题(自上而下方法)
- 为"adjacent"变量赋值时出现问题
- 我的神经网络不起作用 [XOR 问题]
- 在Ubuntu 16.04上安装Cilk时出现问题
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 编译包含字符串的代码时遇到问题
- Project Euler问题4的错误解决方案
- 问题:什么是QAbstractItemView::NoEditTriggers的反面
- 在编译C++代码(具有dlib和opencv)到WASM时面临问题
- 在进程中对同一管道进行读取和写入时C++管道出现问题
- 静态数据成员的问题-修复链接错误会导致编译器错误
- C++ 雷神库 - 使用资源加载器类时出现问题(不命名类型)
- 有关C++/组件数据布局、数据成员访问、方法的一般问题
- 使用tesseract 3.01的页面布局分析时出现的奇怪问题
- 布局问题:当表单的布局设置为垂直时,组框中的Qlistbox会自动展开
- Blackberry 10 Cascades,qml(C++和QT)中的布局出现问题
- XAML UI布局问题
- Qt c++ QMenuBar在滚动时的布局问题
- 升力定向布局问题