Reason for not allowing random access to the vector of edges in adjacency lists

社会主义新天地 提交于 2019-12-24 07:16:33

问题


Why is edge_iterator not an integer_iterator like vertex_iterator? I am using undirected adjacency list with vectors to store both vertices and edges.


回答1:


Adjacency lists store a list of adjacencies.

That is, per vertex, it stores a list of adjacent vertices.

That means that vertices can be stored in a single container, but each vertex contains its own (separate) container of adjacencies ("other vertex references").

This should explain: there is no such thing as "the edge container", making it impossible to directly address the edges by index or as a single adjacent container.

Note there are other graph models (e.g. EdgeList concept, as modeled by edge_list)



来源:https://stackoverflow.com/questions/39603089/reason-for-not-allowing-random-access-to-the-vector-of-edges-in-adjacency-lists

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