#include <iostream>
#include <boost/config.hpp>
//图(矩阵实现)
#include <boost/graph/adjacency_matrix.hpp>
#include <boost\graph\graph_utility.hpp>
#include <boost/graph/graph_traits.hpp>
//图(链表实现)
#include <boost/graph/adjacency_list.hpp>
//求最小生成树
#include <boost/graph/kruskal_min_spanning_tree.hpp>
//prim算法求最小生成树
#include <boost/graph/prim_minimum_spanning_tree.hpp>
//深度优先遍历
#include<boost/graph/depth_first_search.hpp>
//广度优先遍历
#include <boost/graph/breadth_first_search.hpp>
using namespace std;
using namespace boost; //顶点名称
enum { A, B, C, D, E, F, G, H ,I};
//顶点个数
#define N 8
const char *name = "ABCDEFGH"; //宏定义
typedef adjacency_list<vecS, vecS, undirectedS, no_property, property<edge_weight_t, int>> mygraph;
typedef property<edge_weight_t, int> EWP; class BFSmyv :public boost::default_bfs_visitor
{
public:
//当前在哪个结点
template<typename vertex,typename Graph>
void discover_vertex(vertex v, Graph g) const
{
cout << "at" << v << endl;
} //输出当前结点下一个要访问的结点
template<typename Edge,typename Graph> const
void examine_edge(Edge e, Graph g)
{
cout << "edges" << e << endl;
}
}; //无向图
void main()
{
//图,每个结点是vec来实现,无向图,有边长与权重的属性
mygraph myg;
add_edge(A, B,, myg);
add_edge(B, C, ,myg);
add_edge(A, C,, myg);
add_edge(A, D,, myg);
add_edge(C, D,, myg);
add_edge(D, E,, myg);
add_edge(E, F, , myg);
add_edge(B, E, , myg);
add_edge(B, F, , myg);
add_edge(B, G, , myg);
add_edge(B, H, , myg);
add_edge(B, I, , myg); adjacency_list<vecS, vecS, undirectedS, no_property, property<edge_weight_t, int>>test;
BFSmyv myd; //用于广度优先遍历
//mygraph test;
breadth_first_search(myg,vertex(,test), visitor(myd)); cin.get();
}

最新文章

  1. python基础(八)面向对象的基本概念
  2. Elasticsearch聚合 之 Ip Range IP地址范围聚合
  3. SVN使用教程总结
  4. FBI是如何破获“美国少女”裸照勒索案的
  5. .NET Core常用配置文件示例
  6. fork/join使用示例
  7. 【部分枚举】【3-21个人赛】ProblemH
  8. WCF 启用multipleSiteBindingsEnabled 情况下报终结点地址错误
  9. 有了SSL证书,如何在IIS环境下部署https?【转载】
  10. MVC和三层架构
  11. 【Java】java 中的泛型通配符——从“偷偷地”地改变集合元素说起
  12. 爬坑二 activiti流数据库版本错误引发的问题
  13. Tasklist使用详解
  14. word2vec skip-gram系列2
  15. C166 -MDH
  16. linux网络设备—mdio总线
  17. 10.16JS日记
  18. 电子邮件-TCP
  19. Integer.parseInt() 和 valueOf()
  20. js的form表单提交url传参数(包含+等特殊字符)的解决方法

热门文章

  1. Linux下配置httpd服务
  2. ES内存持续上升问题定位
  3. webform 下使用autofac
  4. Redis学习笔记(三) 基本命令:Key操作
  5. 维基百科 MediaWiki API 解析
  6. java根据出生日期计算年龄
  7. struts2配置 匹配原则 配置各项默认
  8. 使用LayUI在页面实现加载层(图标)代码:
  9. HDU 2300 Crashing Robots
  10. 利用after和before伪元素在文字两边写横线