14.boost最小生成树 kruskal_min_spainning_tree
#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>
using namespace std;
using namespace boost; //顶点名称
enum { A, B, C, D, E, F };
//顶点个数
#define N 6
const char *name = "ABCDEF"; //无向图
void main()
{
//图,每个结点是vec来实现,无向图,有边长与权重的属性
adjacency_list<vecS, vecS, undirectedS, no_property, property<edge_weight_t, int>> 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(B, D,, myg); //链表
typedef adjacency_list<vecS, vecS, undirectedS, property<edge_weight_t, int>> mygraph;
//创建边的链表
list<mygraph::edge_descriptor> mylist;
//生成的结果尾插到mylist
kruskal_minimum_spanning_tree(myg, back_inserter(mylist)); //创建边与权重的映射(weight是函数指针)
auto weight= get(edge_weight,myg);
//property_map<mygraph, edge_weight_t>::type weight = get(edge_weight, myg); for (auto ib = mylist.begin(); ib != mylist.end(); ib++)
{
//输出边
//cout << *ib << endl;
cout << source(*ib, myg) << "->" << target(*ib, myg) << "权重" << weight(*ib) << endl;
}
cin.get();
}
14.boost最小生成树 kruskal_min_spainning_tree的更多相关文章
- 15.boost最小生成树 prim_minimum_spanning_tree
#include <iostream> #include <boost/config.hpp> //图(矩阵实现) #include <boost/graph/adjac ...
- (转)boost::bind介绍
转自:http://www.cnblogs.com/sld666666/archive/2010/12/14/1905980.html 这篇文章介绍boost::bind()的用法, 文章的主要内容是 ...
- boost::bind 介绍
boost::bind 介绍 这篇文章介绍boost::bind()的用法, 文章的主要内容是参考boost的文档. 1. 目的 boost::bind 是std::bindlist 和 std: ...
- boost::tie()和boost::variant()解说
#include<iostream> #include<boost/tuple/tuple.hpp> #include<boost/variant.hpp> #in ...
- [Fundamental of Power Electronics]-PART I-2.稳态变换器原理分析-2.3 Boost 变换器实例
2.3 Boost 变换器实例 图2.13(a)所示的Boost变换器器是另一个众所周知的开关模式变换器,其能够产生幅值大于直流输入电压的直流输出电压.图2.13(b)给出了使用MOSFET和二极管的 ...
- Awesome C/C++
Awesome C/C++ A curated list of awesome C/C++ frameworks, libraries, resources, and shiny things. In ...
- C/C++ 框架,类库,资源集合
很棒的 C/C++ 框架,类库,资源集合. Awesome C/C++ Standard Libraries Frameworks Artificial Intelligence Asynchrono ...
- awesome cpp
https://github.com/fffaraz/awesome-cpp Awesome C/C++ A curated list of awesome C/C++ frameworks, lib ...
- 【干货】国外程序员整理的 C++ 资源大全【转】
来自 https://github.com/fffaraz/awesome-cpp A curated list of awesome C/C++ frameworks, libraries, res ...
随机推荐
- WebBrowser网页操作之提取获取元素和标签(完整篇)
最近使用WebBrower做了几个Hook小程序,收集积累如下: using System; using System.Collections.Generic; using System.Linq; ...
- SPFA(Shortest Path Faster Algorithm)
特别说明 本文转载自三金(frinemore)的博客: 点这 前言 1.关于SPFA,它没死. 2.接下来的所有代码,都是自己手写的(未检查正确性,补充的代码有检查过,是对的),有错误请帮忙指出. S ...
- React中多行文本省略不生效原因
在普通的前端项目中,在不考虑兼容问题的时候,可以用以下代码实现: overflow : hidden; text-overflow: ellipsis; display: -webkit-box; - ...
- [转]Linux+XAMPP+eolinker开源版v3.2.4
eolinker是一个由国人开源的接口管理系统(AMS),特性及介绍详见开源中国-eolinker首页. 搭建步骤参考:eolinker开源指南 系统环境:CentOS Linux release 7 ...
- 前端学习笔记-CSS
- JavaScript DOM编程艺术(第2版)学习笔记2(4~6章应用实例)
本书的第4章使用第3章学到的操作DOM的方法和属性写了一个展示图片的网页,并在第5,6章对代码进行了优化. 第一版,搭建网页的静态结构,包括一级标题<h1>,无序列表清单<ul> ...
- Array.prototype.slice.call(arguments) 通俗法理解
Array.prototype.slice.call(arguments,num) 能将具有length属性的对象转成数组. slice 从字面上的意思可以理解为截取数组的一部分. call 从字 ...
- CorelDRAW X6+PhotoZoom这组合,无敌了啊!
520就这样毫无察觉的过去了,对于额这种单身狗,额表示,什么520,什么情人节,统统略过,,可是,可是,即便这样,还是硬生生的吃了一把来势凶猛的远在天际的狗粮,当我看到CorelDRAW X6和Pho ...
- 第四章 Python之文件处理
文件操作 文件操作一般分为三步:打开文件得到文件句柄并赋值给一个变量--->通过句柄对文件进行操作-->关闭文件 f=open(r'C:\Users\hesha\PycharmProjec ...
- Java以流的方式将指定文件夹里的.txt文件全部复制到另一文件夹,并删除原文件夹中所有.txt文件
import java.io.BufferedReader; import java.io.BufferedWriter; import java.io.File; import java.io.Fi ...