adjacency_list with VertexList different from vecS

后端 未结 2 1852
再見小時候
再見小時候 2021-01-22 09:30

I have two structs containing some fields: struct MyNodeData, and struct MyEdgeData. When I create a graph with VertexList as vecS, there is no problem to access the descriptor

2条回答
  •  滥情空心
    2021-01-22 10:18

    Currently, you just need to provide an associative property map.

    <...>
    typedef Graph::vertex_descriptor NodeID;
    
    typedef map IndexMap;
    IndexMap mapIndex;
    associative_property_map propmapIndex(mapIndex);
    <...>
    
    // indexing all vertices
    int i=0;
    BGL_FORALL_VERTICES(v, g, Graph)
    {
       put(propmapIndex, v, i++);
    }
    

提交回复
热议问题