如何使用Boost C 复制图
How to copy a graph using boost c++?
我在使用boost复制图表时遇到问题吗?我的代码如下:它不允许我创建索引图作为一种类型。
template <class Graph>
int abc(Graph& G){
typename graph_traits<Graph>::vertex_descriptor NodeID;
typedef map<size_t, NodeID> IndexMap; //It doesn't let me to create NodeID type
typedef map<NodeID, size_t> IndexMap;
IndexMap mapIndex;
associative_property_map<IndexMap> propmapIndex(mapIndex);
Graph g1, g2;
int i=0;
BGL_FORALL_VERTICES(v, g2, Graph)
{
put(propmapIndex, v, i++);
}
g1.clear();
copy_graph( g2, g1, vertex_index_map( propmapIndex ) );
g2.clear();
}
int main(){
typedef adjacency_list<listS, vecS, undirectedS,
WeightProperty, property<edge_color_t, default_color_type> MyGraphType;
typename graph_traits<MyGraphType>::adjacency_iterator ai, ai_end;
typename graph_traits<MyGraphType>::vertex_descriptor Vertex;
...
...
MyGraphType G;
... //addition of vertices and edges
abc(G);
}
谢谢您的帮助。
我猜
typename graph_traits<Graph>::vertex_descriptor NodeID;
应该是
typedef typename graph_traits<Graph>::vertex_descriptor NodeID;
上部变体是类型graph_traits<Graph>::vertex_descriptor
的变量NodeID
的声明,而后者是同一类型的类型。
相关文章:
- 将所选值(通过视图)从 boost::multi_array 复制到另一个数组 (C++)
- 在 boost::variant 中类 holden 的复制构造函数存在问题
- 如何复制 boost::aligned_storage 对象中的数据?
- boost::asio 以async_read复制输入数据
- 使用BOOST :: PYTHON返回裸露的类对象列表,这些对象是不可复制的
- BOOST :: iostreams ::::复制似乎太慢了
- 错误:无法通过'...'传递非平凡可复制类型的对象'class boost::filesystem::path'
- 如何复制或重复使用boost :: asio :: streambuf
- 为什么 boost::make_shared 使用复制语义
- 复制boost :: shared_ptr的内容 - 有办法
- 为什么Boost.Asio处理程序必须是可复制的
- 使用boost递归地将给定目录中每个最低级别文件夹的文件复制到另一个目录-C++
- 当类包含boost::container::flat_set时,复制对象时出错
- 如何在使用 Boost.bimap 时避免密钥复制
- 如何将 int 复制到 boost/std::char 数组?
- boost::与boost:asio绑定在一起.boost::绑定不起作用,从示例中复制
- 将std::map复制/插入到boost::bimap中
- CMAKE:复制 Boost-Build 的"build everything in Jamfile"行为?
- 使用BOOST复制具有相邻顶点的边及其属性
- 使用BOOST复制边及其顶点和特性