从read_graphviz_new.hpp
源代码中:
struct edge_info {
node_and_port source;
node_and_port target;
properties props;
};
node_and_port
的格式如下:
struct node_and_port {
node_name name;
std::string angle;
std::vector<std::string> location;
}
我认为(但尚未验证),如果您直接使用解析器调用以下命令,则可以获得这些结果:
void parse_graphviz_from_string(const std::string& str, parser_result& result, bool want_directed);
在命名空间
boost::read_graphviz_detail
中。如果您直接使用
read_graphviz
,它也可能在
dynamic_property_map
中可用;它内部引用
read_graphviz_new
。
注意:在
graphviz.hpp
中,根据
#ifdef
选择了两个graphviz解析器之一:
#ifdef BOOST_GRAPH_USE_SPIRIT_PARSER
return read_graphviz_spirit(data.begin(), data.end(), graph, dp, node_id);
#else
return read_graphviz_new(data,graph,dp,node_id);
#endif
如果我理解正确的话,那么您需要非Spirit解析器;基于Spirit的解析器似乎忽略了端口。不管怎样,这只是基于对Boost v.1.44源代码的快速查看;对我而言,感兴趣的代码位于/usr/include/boost/graph/detail/read_graphviz_new.hpp。我没有测试过,但看起来所有的工具都在那里。
parser_result
传递给parse_graphviz_from_string
,对于其edges
向量中的每个edge_info
,您查看每个node_and_port
的location
字段。 - jlstreckerread_graphviz
中我们无法获取端口信息。在translate_results_to_graph
函数中,只有ei.source.name
和ei.target.name
被复制到返回的图形中。 - chain ro