C++ Boost

Graph Structure Performance Reference

This page provides detailed performance characteristics and complexity analysis for different adjacency_list selector choices. For guidance on choosing a graph structure, see Choosing Your Graph Structure.

Template Parameters

The adjacency_list has the following declaration:

template <class OutEdgeList, class VertexList, class Directed,
          class VertexProperties, class EdgeProperties,
          class GraphProperties, class EdgeList>
class adjacency_list;

The most important choices are the first three template parameters:

Selector Types

BGL provides selector types that specify which underlying container to use:

VertexList Performance

This table summarizes the space and time complexities for different VertexList choices:

Table: Asymptotic Complexities for Different VertexList Choices
VertexList Space add_vertex() remove_vertex() Vertex Descriptor Stability
vecS O(V) O(1) amortized O(V + E) Invalidated on removal
listS O(V) O(1) O(E) Stable
setS O(V) O(log(V)) O(log(V) + E) Stable

Analysis:

OutEdgeList Performance

This table summarizes complexities for different OutEdgeList choices:

Table: Asymptotic Complexities for Different OutEdgeList Choices
OutEdgeList Space add_edge() remove_edge() edge() Parallel Edges
vecS O(E) O(1) amortized O(E/V) O(E/V) Allowed
listS O(E) O(1) O(E/V) O(E/V) Allowed
slistS O(E) O(1) O(E/V) O(E/V) Allowed
setS O(E) O(log(E/V)) O(log(E/V)) O(log(E/V)) Prevented
hash_setS O(E) O(1) average O(1) average O(1) average Prevented

Analysis:

Iterator Performance

The choice of OutEdgeList affects iterator performance, which is critical since iterating over edges is the workhorse of most graph algorithms:

out_edge_iterator::operator++()

Speed ordering (fastest to slowest): vecS, slistS, listS, setS, hash_setS

Explanation:


Back to Choosing Your Graph Structure

Copyright © 2000-2001 Jeremy Siek, Indiana University