Boost Graph library有权有向图节点增删

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基础用法

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值