如何打印与属性之一graphviz的升压图形显示? [英] How to print a boost graph in graphviz with one of the properties displayed?

查看:113
本文介绍了如何打印与属性之一graphviz的升压图形显示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我看到这样的例子使用属性映射的时候,而不是使用结构来处理顶点和边(我想这就是所谓的'包')。在

I see examples of this when using property maps, but not when using structs to handle the vertices and edges (I think this is called 'bundles').

我的顶点和边定义为这样,在邻接表图。

I have vertices and edges defined as such, in an adjacency list graph.

struct Vertex
{
    string name;
    int some_int;
};

struct Edge
{
    double weight;
};

该图的结构如下:

The graph is constructed as follows:

typedef boost::adjacency_list<boost::listS, boost::vecS, boost::directedS, Vertex, Edge> boost_graph;

我想打印在的Graphviz 格式我的这些对象的图,这样我就可以把它看作一个图像。不过,我不只是想节点和边缘。我也想名称顶点和重量上边缘属性出现在影像中。我怎样才能做到这一点?

I want to print my graph of these objects in Graphviz format, so I can view it as an image. However, I don't only want the nodes and edges. I also want the attribute name on vertices and weight on edges to appear in the image. How can I do this?

推荐答案

我给不良信息的第一次。这是正确的答案。

I gave bad info the first time. Here is the correct answer.

#include <boost/graph/graphviz.hpp>

using namespace boost;

// Graph type
typedef adjacency_list<vecS, vecS, directedS, VertexProperties, EdgeProperty> Graph;
Graph g;
std::vector<std::string> NameVec; // for dot file names


// write the dot file
std::ofstream dotfile (strDotFile.c_str ());
write_graphviz (dotfile, g, make_label_writer(&NameVec[0]));

这篇关于如何打印与属性之一graphviz的升压图形显示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆