【问题标题】:C++ LEMON Graph Library - Show arc/edge map with graphToEps()C++ LEMON Graph Library - 使用 graphToEps() 显示弧/边图
【发布时间】:2023-03-14 16:05:01
【问题描述】:

使用LEMON C++ 库和GraphToEps,我试图可视化带有边缘(或弧)权重的grid graph,但没有运气。到目前为止,这是我的 ma​​in() 中的内容:

// 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 的权重位于相应边的顶部。

Grid graph image

非常感谢任何帮助。

【问题讨论】:

    标签: c++ graph visualization lemon-graph-library


    【解决方案1】:

    似乎没有内置的方法可以做到这一点。 我最终连接到了 graphToEps 打印节点文本的部分,然后只是找出在哪里放置所有边缘的文本。所有的边都像节点一样被“打印”出来。

    我可能会在今年晚些时候提出拉取请求。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多