Boost Graph library通过创建有权有向图,并删除单条有向边,最后实现搜索
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <iostream>
using namespace std;
using namespace boost;
typedef property<edge_weight_t, int>
EdgeWeightProperty;
typedef boost::adjacency_list
< listS, vecS, directedS, no_property, EdgeWeightProperty>
mygraph;
class custom_dfs_visitor : public boost::default_dfs_visitor
{
public: template < typename Vertex, typename Graph >
void discover_vertex(Vertex u, const Graph & g)
const {
std::cout << "At " << u << std::endl;
}
template < typename Edge, typename Graph >
void examine_edge(Edge e, const Graph& g)
const {
std::cout << "Examining edges " << e << std::endl;
}
};
int main()
{
mygraph g; add_edge(0, 1, 8, g);
add_edge(0, 3, 18, g);
add_edge(1, 2, 20, g);
add_edge(2, 3, 2, g);
add_edge(3, 1, 1, g);
add_edge(1, 3, 7, g);
remove_edge(1, 3, g);
custom_dfs_visitor vis;
depth_first_search(g, visitor(vis));
}
在这里插入图片描述
> http://blog.sina.com.cn/s/blog_69de213f0100l42p.html
//关于每种数据结构的删除边操作的说明
https://www.ibm.com/developerworks/cn/aix/library/au-aix-boost-graph/
//Boost Graph Library基础用法