C++ Boost图形库C++;/幂律

C++ Boost图形库C++;/幂律,c++,boost,boost-graph,power-law,C++,Boost,Boost Graph,Power Law,我有一个id为x&y坐标的顶点向量,我想为我的顶点生成一个幂律图。Boost库图提供了幂律plod_迭代器(),但是如何用顶点生成它呢。有人能帮忙吗 Boost文档说明这些是发电机 “此类模板使用幂律出度(PLOD)算法实现无标度图生成器”() 它说的迭代器有点让人困惑 我会用数据创建一个结构向量,然后生成一个节点数相同的幂律图 从boost文档中修改: #include <boost/graph/adjacency_list.hpp> #include <boost/grap

我有一个id为x&y坐标的顶点向量,我想为我的顶点生成一个幂律图。Boost库图提供了幂律plod_迭代器(),但是如何用顶点生成它呢。有人能帮忙吗

Boost文档说明这些是发电机

“此类模板使用幂律出度(PLOD)算法实现无标度图生成器”()

它说的迭代器有点让人困惑

我会用数据创建一个结构向量,然后生成一个节点数相同的幂律图

从boost文档中修改:

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/plod_generator.hpp>
#include <boost/random/linear_congruential.hpp>

struct VertData{
  size_t id;
  size_t x;
  size_t y;
};

typedef boost::adjacency_list<> Graph;
typedef boost::plod_iterator<boost::minstd_rand, Graph> SFGen;

int main()
{

  vector<VertData> vertData;
  //... Initialize with data ...


  boost::minstd_rand gen;
  // Create graph with 100 nodes 
  Graph g(SFGen(gen, 100, 2.5, 1000), SFGen(), 100);


  typedef property_map<Graph, vertex_index_t >::type VertexIndexMap;
  VertexIndexMap iMap = get(vertex_index,g);
  // ... get some vertex v
  size_t vertexIndex = iMap[v];
  //...
  vertexData.at(vertexIndex).x = 4;//or what ever



  return 0;
}
#包括
#包括
#包括
结构顶点数据{
尺寸标识;
尺寸x;
大小;
};
typedef boost::邻接列表图;
typedef boost::plod_迭代器SFGen;
int main()
{
矢量数据;
//…使用数据初始化。。。
推进:明特德·兰特发电厂;
//创建具有100个节点的图形
图g(SFGen(gen,100,2.51000),SFGen(),100);
typedef属性_映射::type VertexIndexMap;
顶点索引xmap iMap=get(顶点索引,g);
//…得到一些顶点v
尺寸t顶点索引=iMap[v];
//...
vertexData.at(vertexIndex).x=4;//或者其他什么
返回0;
}
这里将使用幂律指数2.5创建一组具有100个节点的无标度图

然后,当您想要访问节点的数据时,只需访问其索引并在结构向量中查找即可。您可以按如下方式获取索引:

typedef property_map<Graph, vertex_index_t >::type VertexIndexMap;
VertexIndexMap iMap = get(vertex_index,g);
size_t vertexIndex = iMap[v];
...
vertexData.at(vertexIndex).x = 4;//or what ever
typedef属性映射::type VertexIndexMap;
顶点索引xmap iMap=get(顶点索引,g);
尺寸t顶点索引=iMap[v];
...
顶点数据.at(顶点索引).x=4//或者什么

这可能不是绝对最好的方法,但它使我能够完成我的工作。

Boost文档说明这些是生成器

“此类模板使用幂律出度(PLOD)算法实现无标度图生成器”()

它说的迭代器有点让人困惑

我会用数据创建一个结构向量,然后生成一个节点数相同的幂律图

从boost文档中修改:

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/plod_generator.hpp>
#include <boost/random/linear_congruential.hpp>

struct VertData{
  size_t id;
  size_t x;
  size_t y;
};

typedef boost::adjacency_list<> Graph;
typedef boost::plod_iterator<boost::minstd_rand, Graph> SFGen;

int main()
{

  vector<VertData> vertData;
  //... Initialize with data ...


  boost::minstd_rand gen;
  // Create graph with 100 nodes 
  Graph g(SFGen(gen, 100, 2.5, 1000), SFGen(), 100);


  typedef property_map<Graph, vertex_index_t >::type VertexIndexMap;
  VertexIndexMap iMap = get(vertex_index,g);
  // ... get some vertex v
  size_t vertexIndex = iMap[v];
  //...
  vertexData.at(vertexIndex).x = 4;//or what ever



  return 0;
}
#包括
#包括
#包括
结构顶点数据{
尺寸标识;
尺寸x;
大小;
};
typedef boost::邻接列表图;
typedef boost::plod_迭代器SFGen;
int main()
{
矢量数据;
//…使用数据初始化。。。
推进:明特德·兰特发电厂;
//创建具有100个节点的图形
图g(SFGen(gen,100,2.51000),SFGen(),100);
typedef属性_映射::type VertexIndexMap;
顶点索引xmap iMap=get(顶点索引,g);
//…得到一些顶点v
尺寸t顶点索引=iMap[v];
//...
vertexData.at(vertexIndex).x=4;//或者其他什么
返回0;
}
这里将使用幂律指数2.5创建一组具有100个节点的无标度图

然后,当您想要访问节点的数据时,只需访问其索引并在结构向量中查找即可。您可以按如下方式获取索引:

typedef property_map<Graph, vertex_index_t >::type VertexIndexMap;
VertexIndexMap iMap = get(vertex_index,g);
size_t vertexIndex = iMap[v];
...
vertexData.at(vertexIndex).x = 4;//or what ever
typedef属性映射::type VertexIndexMap;
顶点索引xmap iMap=get(顶点索引,g);
尺寸t顶点索引=iMap[v];
...
顶点数据.at(顶点索引).x=4//或者什么

这可能不是绝对最好的方法,但它使我能够完成我的工作。

Boost文档说明这些是生成器

“此类模板使用幂律出度(PLOD)算法实现无标度图生成器”()

它说的迭代器有点让人困惑

我会用数据创建一个结构向量,然后生成一个节点数相同的幂律图

从boost文档中修改:

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/plod_generator.hpp>
#include <boost/random/linear_congruential.hpp>

struct VertData{
  size_t id;
  size_t x;
  size_t y;
};

typedef boost::adjacency_list<> Graph;
typedef boost::plod_iterator<boost::minstd_rand, Graph> SFGen;

int main()
{

  vector<VertData> vertData;
  //... Initialize with data ...


  boost::minstd_rand gen;
  // Create graph with 100 nodes 
  Graph g(SFGen(gen, 100, 2.5, 1000), SFGen(), 100);


  typedef property_map<Graph, vertex_index_t >::type VertexIndexMap;
  VertexIndexMap iMap = get(vertex_index,g);
  // ... get some vertex v
  size_t vertexIndex = iMap[v];
  //...
  vertexData.at(vertexIndex).x = 4;//or what ever



  return 0;
}
#包括
#包括
#包括
结构顶点数据{
尺寸标识;
尺寸x;
大小;
};
typedef boost::邻接列表图;
typedef boost::plod_迭代器SFGen;
int main()
{
矢量数据;
//…使用数据初始化。。。
推进:明特德·兰特发电厂;
//创建具有100个节点的图形
图g(SFGen(gen,100,2.51000),SFGen(),100);
typedef属性_映射::type VertexIndexMap;
顶点索引xmap iMap=get(顶点索引,g);
//…得到一些顶点v
尺寸t顶点索引=iMap[v];
//...
vertexData.at(vertexIndex).x=4;//或者其他什么
返回0;
}
这里将使用幂律指数2.5创建一组具有100个节点的无标度图

然后,当您想要访问节点的数据时,只需访问其索引并在结构向量中查找即可。您可以按如下方式获取索引:

typedef property_map<Graph, vertex_index_t >::type VertexIndexMap;
VertexIndexMap iMap = get(vertex_index,g);
size_t vertexIndex = iMap[v];
...
vertexData.at(vertexIndex).x = 4;//or what ever
typedef属性映射::type VertexIndexMap;
顶点索引xmap iMap=get(顶点索引,g);
尺寸t顶点索引=iMap[v];
...
顶点数据.at(顶点索引).x=4//或者什么

这可能不是绝对最好的方法,但它使我能够完成我的工作。

Boost文档说明这些是生成器

“此类模板使用幂律出度(PLOD)算法实现无标度图生成器”()

它说的迭代器有点让人困惑

我会用数据创建一个结构向量,然后生成一个节点数相同的幂律图

从boost文档中修改:

#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/plod_generator.hpp>
#include <boost/random/linear_congruential.hpp>

struct VertData{
  size_t id;
  size_t x;
  size_t y;
};

typedef boost::adjacency_list<> Graph;
typedef boost::plod_iterator<boost::minstd_rand, Graph> SFGen;

int main()
{

  vector<VertData> vertData;
  //... Initialize with data ...


  boost::minstd_rand gen;
  // Create graph with 100 nodes 
  Graph g(SFGen(gen, 100, 2.5, 1000), SFGen(), 100);


  typedef property_map<Graph, vertex_index_t >::type VertexIndexMap;
  VertexIndexMap iMap = get(vertex_index,g);
  // ... get some vertex v
  size_t vertexIndex = iMap[v];
  //...
  vertexData.at(vertexIndex).x = 4;//or what ever



  return 0;
}
#包括
#包括
#包括
结构顶点数据{
尺寸标识;
尺寸x;
大小;
};
typedef boost::邻接列表图;
typedef boost::plod_迭代器SFGen;
int main()
{
矢量数据;
//…使用数据初始化。。。
推进:明特德·兰特发电厂;
//创建具有100个节点的图形
图g(SFGen(gen,100,2.51000),SFGen(),100);
typedef属性_映射::type VertexIndexMap;
顶点索引xmap iMap=get(顶点索引,g);
//…得到一些顶点v
尺寸t顶点索引=iMap[v];
//...
vertexData.at(vertexIndex).x=4;//或者其他什么
返回0;
}
这里将使用幂律指数2.5创建一组具有100个节点的无标度图

然后,当您想访问节点的数据时,只需访问其索引并在结构中查找即可