Search code examples
boostboost-graph

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


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.


Solution

  • 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)