On Wed, 29 May 2013, lizy10b wrote:
> ?
> Hi爐here,
> 牋I燼m爊ew爐o燘GL爈ibrary.?
> 牋I燼m爓alking爐hrough爐he爋nline爐utorial燼nd爅ust爁inished爐he "10.2.燬ix燚egrees爋f燢evin燘acon".
> 牋
> 牋As爄t爄s爏aid燼t爐he爀nd爋f爐he爀xample:?Note爐hat爒ertex燿escriptor爋bjects燾an爊ot燼lways燽e爑sed燼s?
> indices爄nto爒ectors爋r燼rrays爏uch燼s燽acon_number.燭his爄s爒alid爓ith爐he?
> adjacency_list燾lass爓ith燰ertexList=vecS,燽ut爊ot爓ith爋ther爒ariations爋f?
> adjacency_list.燗爉ore爂eneric爓ay爐o爄ndex燽ased爋n爒ertices爄s爐o爑se爐he?
> ID爌roperty爉ap?vertex_index_t)爄n燾oordination爓ith爐he爄terator_property_map.".
> 牋
> ?So營爐urn爐o爃ave燼爈ook燼t爐he爄terator_property_map爌age燼nd爄ts爏ample.?
> First,爐his爏ample爑ses燰ertexList=vecS爐oo.?
> Second,營爇now爐his sample爄s爑sing爄terator_property_map爐o燽uild燼爌roperty爉ap,?
> but營爐hink爐he爌roperty爄s爏till indexed燽y爐he爀dge燿escriptor爋bjects.牋牋
> 燬o爓hat爄s爐he燿ifference?
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
property for vertex descriptors (such as the vecS case you mention), some
don't (such as grid_graph) and most do not have it for edge descriptors.
Thus, a separate property map is needed to map from descriptors to indexes
into the underlying containers. By default, the vertex_index and
edge_index property maps of a graph are used for that. In the vecS case,
the vertex index map is an identity function, but generic code cannot rely
on that. For grid_graph, the mapping can be accessed but is not the
identity function, and the same is true for edge descriptors in
compressed_sparse_row_graph.
One problem you may see with this is how you would create an index map
when it is not built into a graph: after all, iterator_property_map
requires the index map to already exist. There are two solutions for
that, both involving the user creating the index numbers manually. The
first is to have a vertex_index_t or edge_index_t internal property as one
of the user-defined properties added to the graph, and the other is to use
something like an associative_property_map (assuming there are comparison
operators on the descriptors in question). For either type of storage,
the user would need to loop over the vertices and edges, assign them
sequential numbers, and put those into the map.
Does that start to answer your question, or did you intend to ask
something else?
-- Jeremiah Willcock
_______________________________________________
Boost-users mailing list
Boost-users@lists.boost.org
http://lists.boost.org/mailman/listinfo.cgi/boost-users