【发布时间】:2023-03-14 16:05:01
【问题描述】:
使用LEMON C++ 库和GraphToEps,我试图可视化带有边缘(或弧)权重的grid graph,但没有运气。到目前为止,这是我的 main() 中的内容:
// Create graph and init maps
GridGraph g = GridGraph(5, 5);
GridGraph::NodeMap<Point> coords(g);
GridGraph::EdgeMap<int> weights(g, 1);
// Set positions of nodes for graphToEps use
for(GridGraph::NodeIt u(g); u != INVALID; ++u ) {
coords[u] = g.pos(u);
}
cout << "Create 'graph.eps'" << endl;
graphToEps(g,"graph.eps").
coords(coords).
title("Sample .eps figure").
run();
我可以使用graphToEps.nodeTexts(id) 获取节点文本(为简单起见,我在上面的代码中省略了),如图graphToEps demo 所示,但我找不到类似edgeTexts(weights(id)) 或arcTexts(weights(id)) 的内容。
上述代码的输出如下所示,我希望地图weights 的权重位于相应边的顶部。
非常感谢任何帮助。
【问题讨论】:
标签: c++ graph visualization lemon-graph-library