【发布时间】:2021-01-07 18:38:16
【问题描述】:
我有一个连通图 A(第 0 级),我想用图 B、C、D... 填充下一个级别,方法是在 A 中一次删除一条边。这是我的代码开始的方式:
struct VertexData
{
long ID;
};
typedef boost::adjacency_list<boost::listS, boost::listS, boost::undirectedS,VertexData, property< edge_index_t, int > >> SimpleGraph;
typedef boost::graph_traits<SimpleGraph>::vertex_descriptor vertex_t;
typedef boost::graph_traits<SimpleGraph>::edge_descriptor edge_t;
int main(){
SimpleGraph A;
}
我曾尝试在 A 的边上循环并在复制图 A 后一次删除一条边:
SimpleGraph tempStructure;
vector<SimpleGraph> newStructures;
vector<long> parentList;
// loop over the edges
auto es = boost::edges(A);
pred = A.ID;
for (auto eit = es.first; eit != es.second; ++eit){
// 1. copy structure
cout << "Copy structure." <<endl;
boost::copy_graph(A, tempStructure);
// 2. remove a particular edge
cout << "Remove edge." << endl;
boost::remove_edge(*eit, tempStructure);
// 3. save structure
cout << "Saving structure." << endl;
newStructures.push_back(tempStructure);
// 4. save parent of old structure]
cout << "Saving parent." << endl;
parentList.push_back(pred);
}
但正如我所阅读的here, 我理解这是一个非常幼稚的尝试。我找到了以下解决方案 (Boost filtered graph with blacklisted edges) 并看到过滤图似乎是要走的路。但是,我在实现它时遇到了麻烦......
是否可以一次过滤掉父图中的一条边,以便子图是 A 的过滤版本,在 A 中缺少一条边?
【问题讨论】:
标签: c++ boost graph boost-graph filtered