如何在BGL图中获取OutEdgeList [英] How to get the OutEdgeList inside a BGL graph

查看:78
本文介绍了如何在BGL图中获取OutEdgeList的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我使用由Boost图形库制作的图形,并且想要访问OutEdgeList来获取/设置一些内部信息(用于构建OutEdgeList的向量的保留大小).

I use a graph made with the boost graph library and want to access the OutEdgeList to get/set some internal informations (the reserved size of the vectors used to build the OutEdgeList).

我广泛地搜索了文档,但没有找到一个函数/成员,该函数/成员返回了对OutEdgeList的引用或指针.

I extensively searched the docs but didn't find a function/member, which returns a reference or pointer to the OutEdgeList.

我的问题是,是否有一种方法可以获取图表OutEdgeList,或者是否可以通过boost来保护用户免于直接破坏其内部结构.

My question is if there is a way to get the graphs OutEdgeList or if boost 'protects' the user from not messing directly with its internals.

另一个问题中,我找到了一个示例,可以直接使用graph.m_edges访问EdgeList,并且还可以将其用作执行graph.m_edges.reserve(115960001)的向量,因此,我希望也应该有一种方法可以访问OutEdgeList.

In another question I found an example where you could access the EdgeList directly with graph.m_edges and also use it as a vector to do graph.m_edges.reserve(115960001) for example, so I hope there should also be a way to access the OutEdgeList too.

任何帮助表示赞赏!

推荐答案

获取OutEdgeList的正确方法是遍历所有m_vertices并访问其m_out_edges属性.

The proper way to get the OutEdgeList is by iterating over all m_vertices and access their m_out_edges attribute.

VertexIterator vi, vi_end;
for (boost::tie(vi, vi_end) = vertices(graph); vi != vi_end; ++vi){
     graph.m_vertices[*vi].m_out_edges.reserve(6);
}

通过为每个顶点保留适当数量的边缘,我将内存使用量从12GB减少到10.5GB.

By reserving the proper amount of Edges per Vertex I reduced memory usage from 12GB to 10.5GB.

我花了很长时间才找到成员,因为我希望他们位于 boost/graph/adjacency_list.hpp ,但它们在

It took my quite a while to find the members, because I expected them to be in boost/graph/adjacency_list.hpp but they where in boost/graph/detail/adjacency_list.hpp

这篇关于如何在BGL图中获取OutEdgeList的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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