Should I use iterators or descriptors to keep a reference on an edge or vertex?

与世无争的帅哥 提交于 2019-12-06 02:26:54

Stability of iterators/descriptors and efficiency of iterators both depend on your vertex container.

For vectorS for example the vertex descriptor is just the index of the vertex in the vector, so lookups in the container are as fast as indexing into a vector. The descriptor is just as unstable as the iterator in this instance as insertions & deletions can cause elements to move around.

For listS I expect (read: 'guess') the descriptor is the address of the element, so both descriptor and iterator are likely to have the same stability guarantees. In this case, using the vertex descriptor to get access to the property may well be as efficient as the iterator.

For more information on adjacency_list iterator/descriptor stability read the section titled Iterator and Descriptor Stability/Invalidation on this page. With performance concerns you're best profiling the 2 to compare, and only when it seems to be a bottleneck in your application.

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!