提升 Kamada-Kawai spring 布局顶点碰撞

boost Kamada-Kawai spring layout vertices collision

我正在尝试使用 boost Kamada-Kawai-spring-layout 布局图 algorithm.The 问题是顶点在某些 graphs.I 中相互碰撞添加所有边重量 1.0

add_edge(a,b,1.0,g);

然后我这样布置图表:

minstd_rand gen;
topology_type topo(gen,0,0,widht,height);
random_graph_layout(g,position,topo);
bool kamada=kamada_kawai_spring_layout(g,position,get(edge_weight,g),topo,side_length(width),kamada_kawai_done());

有些图表工作正常,而其他图表产生这样的输出

我觉得布局很好,但边的长度需要增加,但我不知道如何

您可以使用 boost::edge_length(e) 而不是 boost::side_length(s) 来控制图上的边长

bool kamada=kamada_kawai_spring_layout(g,position,get(edge_weight,g),topo,boost::edge_length(length),kamada_kawai_done());