C++图常用库boost graph library

本文主要介绍了C++中的Boost Graph Library (BGL),包括如何创建和使用简单图例,重点讲解了Vertex Descriptors、Edge Descriptors、Property Maps以及图的访问和遍历方法。文章旨在帮助读者理解和掌握BGL,以便在需要高性能图算法的场景下使用。
摘要由CSDN通过智能技术生成

接下来一段日子,会写一些跟bgl相关的内容。bgl是一个性能很不错的库,但是源码跟鬼畜一样…文档也写得很乱。因为最近做的论文需要比较好的性能,实在不得不硬着头皮重新用起bgl。所以尽可能的做一些总结,希望能给后面需要使用的同学能有点帮助。

开始: 一个简单的小例子

csdn代码样式不好看,欢迎直接访问我的个人网站

{% codeblock lang:Cpp %}
#include // for std::cout
#include // for std::pair
#include // for std::for_each
#include <boost/graph/graph_traits.hpp>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/dijkstra_shortest_paths.hpp>

using namespace boost;

int main(int,char*[])
{
// create a typedef for the Graph type
typedef adjacency_list<vecS, vecS, bidirectionalS> Graph;

// Make convenient labels for the vertices
enum { A, B, C, D, E, N };
const int num_vertices = N;
const char* name = "ABCDE";

// writing out the edges in the graph
typedef std::
  • 6
    点赞
  • 12
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值