如何使用 Boost Graph Library 获取边缘的端口标识符?
使用Boost Graph Library,是否可以获得边缘的端口标识符?
示例:调用 read_graphviz
后,我可以迭代该图的边缘并打印它们的 node_id
- 我得到“A -> B,A -> B ”。如何打印“A:p0 -> B:p1, A:p0 -> B:p2”之类的内容?
digraph G {
A [label="A|<p0>p0"];
B [label="B|<p1>p1|<p2>p2"];
A:p0 -> B:p1;
A:p0 -> B:p2;
}
Using the Boost Graph Library, is it possible to get the port identifiers for an edge?
Example: After calling read_graphviz
, I can iterate through the edges of this graph and print their node_id
s -- I get "A -> B, A -> B". How can I print something like "A:p0 -> B:p1, A:p0 -> B:p2"?
digraph G {
A [label="A|<p0>p0"];
B [label="B|<p1>p1|<p2>p2"];
A:p0 -> B:p1;
A:p0 -> B:p2;
}
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
来自
read_graphviz_new.hpp
源:其中
node_and_port
看起来像这样:我认为(但尚未验证)如果您直接使用以下方式调用解析器,这些结果是可用的:
在命名空间中
boost::read_graphviz_detail
。如果您直接使用read_graphviz
,它也可能在dynamic_property_map
中可用;它在内部引用read_graphviz_new
。注意:在
graphviz.hpp
中,基于#ifdef
选择两个graphviz解析器之一:如果我正确地阅读了这个,那么非精神解析器就是你想要的;精神系的看起来像是无视端口的。
无论如何,这只是基于快速查看 boost v. 1.44 的源代码;对我来说,感兴趣的代码位于
/usr/include/boost/graph/detail/read_graphviz_new.hpp
中。我还没有测试过,但看起来所有的管道都在那里。From the
read_graphviz_new.hpp
source:Where
node_and_port
looks like this:I think (but have not verified) that these results are available if you call the parser directly using:
in namespace
boost::read_graphviz_detail
. It may also be available in thedynamic_property_map
if you useread_graphviz
directly; it internally refers toread_graphviz_new
.Note: In
graphviz.hpp
, one of two graphviz parsers is selected, based on an#ifdef
:If I am reading this correctly, then the non-spirit parser is the one you want; the spirit-based one looks like it disregards ports.
Anyway, this is just based on a quick look at the source for boost v. 1.44; for me code of interest lives in
/usr/include/boost/graph/detail/read_graphviz_new.hpp
. I have not tested this, but it looks like all the plumbing is there.