我正在使用捆绑属性和adjacency_list,并希望使用子图类.
struct Vertex
{
int index;
int seed;
};
struct Edge
{
bool visted;
double weight;
};
typedef adjacency_list<listS, listS, undirectedS, Vertex, property<edge_index_t,int,Edge> > Graph;
typedef subgraph<Graph> testSubgraph;
Run Code Online (Sandbox Code Playgroud)
property<edge_index_t,int,Edge>需要该部分,因为子图需要edge_index_t比较两个边.
现在我的问题是如何在子图中使用捆绑属性添加Edge?在没有property<edge_index_t,int,Edge>我的正常图表中添加如下边缘:
Edge e;
vertex_descriptor u,v;
// fill in u and v;
e.weight = 1.0;
e.visted=false;
add_edge(u,v,e,graph);
Run Code Online (Sandbox Code Playgroud)
但这对Subgraph不起作用.
希望有人知道解决方案.
谢谢
本
我想对boost :: graph的边缘列表进行排序,如下所示:
struct Vertex{
int index;
};
struct Edge{
double weight;
};
boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS, Vertex, Edge> Graph;
Run Code Online (Sandbox Code Playgroud)
添加顶点和边后,如何对边列表进行排序.首先获得最高重量的边缘?
我知道可以使用
std::sort(edgeIt_begin,edgeIt_end,compare);
Run Code Online (Sandbox Code Playgroud)
对于向量,但它不适用于std :: list.