Reason for not allowing random access to the vecto

2019-07-27 11:57发布

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条回答
贼婆χ
2楼-- · 2019-07-27 12:32

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)

查看更多
登录 后发表回答