? Hi�there, ��I�am�new�to�BGL�library.? ��I�am�walking�through�the�online�tutorial�and�just�finished�the "10.2.�Six�Degrees�of�Kevin�Bacon". �� ��As�it�is�said�at�the�end�of�the�example:?Note�that�vertex�descriptor�objects�can�not�always�be�used�as? indices�into�vectors�or�arrays�such�as�bacon_number.�This�is�valid�with�the? adjacency_list�class�with�VertexList=vecS,�but�not�with�other�variations�of? adjacency_list.�A�more�generic�way�to�index�based�on�vertices�is�to�use�the? ID�property�map?vertex_index_t)�in�coordination�with�the�iterator_property_map.". �� ?So�I�turn�to�have�a�look�at�the�iterator_property_map�page�and�its�sample.? First,�this�sample�uses�VertexList=vecS�too.? Second,�I�know�this sample�is�using�iterator_property_map�to�build�a�property�map,? but�I�think�the�property�is�still indexed�by�the�edge�descriptor�objects.���� �So�what�is�the�difference? I'm not sure I fully understand what you are asking, but here is the general picture of iterator_property_map, vertex_index[_t], and edge_index[_t]: The fastest-to-access property maps in BGL for data storage are the iterator property maps, which use a vector, array, or similar as underlying storage and allow it to be indexed by vertex or edge descriptors. The "catch" with that is that vectors and such require integers to index into them, and a vertex or edge descriptor may not be an integer (or may not map one-to-one onto a contiguous sequence of numbers in the correct range). Although many BGL graph types do have that
Dear Jeremiah Willcock,
Thanks for your reply.
As far as I am walking through the tutorial till now, all the examples use the adjacency_list < vecS, vecS....
Though there are several different ways to construct a graph object, the "internal ids" of each vertex or edge are all 0-based sequence and assigned implicitly.
1.So does it mean the value stored in a vertex descriptor or edge descriptor is the internal ids of the corresponding vertex or edge?
2.And when I am constrcting the graph using either the following 3 ways, do the internal ids of each vertex or edge will be stored in the vertex_index or edge_index
property automatically? or say are the "internal ids" and the vertex_index or edge_index property the same thing?
Thanks.
Example 1:
Edge edge_array[] = { Edge(0, 2),
Edge(1, 1), Edge(1, 3), Edge(1, 4),
Edge(2, 1), Edge(2, 3),
Edge(3, 4),
Edge(4, 0), Edge(4, 1)
};
int num_arcs = sizeof(edge_array) / sizeof(Edge);
graph_t g(edge_array, edge_array + num_arcs, weights, num_nodes);
For this example, I cannot number the vertex id starting from 5 to 9 for the graph which has 5 vertices.
If I did so, when I evaluate num_vertices(g) or loop over all the vertices using vertices(g), I got 10 vertices instead of 5.
And the internal id of edge is the subscript number in the edge_array.
Example 2:
typedef pair