如何将自定义图形设置为boost图形库模板? [英] How to fit a custom graph to the boost graph library template?

查看:202
本文介绍了如何将自定义图形设置为boost图形库模板?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在C ++模板上生锈,我使用的是boost graph库(一个致命的组合)。我已经搜索到网页,找不到任何关于如何采取自定义图形结构并足够适合BGL(boost图形库)的直接说明,我可以使用boosts图遍历算法。任何熟悉图书馆的人都可以帮助我吗?



编辑:所以,我一直在找的主要问题是找到一个来源,总要求的地图BGL图的任意图。我真的很新的模板,所以我很难阅读BGL的规范/例子。也许我应该寻找模板的一般来源?

解决方案

我的建议是放弃使用BGL,除非你已经有大量的代码写在它的顶部。最近我在大型图形分析项目中进行测试,而且由于过于复杂和设计不当的API,我发现它几乎不可用。



在BGL中不是简单的任务,只是复杂的任务,而且由于BGL具有过于复杂的模板层次结构,我也在不断地对编译器进行编译。很少到没有有用的文件(至少不是真正需要的),没有足够的例子只会加剧事情。这是没有办法编写代码。



我建议切换到 LEMON 。它稳定,用C ++编写,易于理解和代码编写,提供了几种特殊形式的图形来支持不同的使用需求,并支持BFS和DFS搜索/访问功能。它还具有自己相当于节点/边缘的属性映射,因此您应该能够将自己的图形结构和其他数据放在其上。



尝试LEMON;它味道好多了,会导致更少的溃疡。 ; - )


I'm rusty on C++ templates and I'm using the boost graph library (a fatal combination). I've searched the web and can't find any direct instructions on how to take a custom graph structure and fit enough of it to BGL (boost graph library) that I can use boosts graph traversing algorithms. Anyone familiar enough with the library to help me out?

EDIT: So, the main problem I've been having is where to find a source where the total requirements to map an arbitrary graph to a BGL graph. I'm really new to templates so it's hard for me to read BGL's specification/examples. Maybe I should look for a general source on templates?

解决方案

My suggestion would be to abandon use of BGL entirely unless you already have a significant amount of code written on top of it. I was testing it out recently for future use on a large graph analysis project, and I found it to be almost unusable due to an overly complex and poorly designed API.

There are no simple tasks in BGL, only complex ones, and I was constantly fighting the compiler due to the excessively complicated template hierarchy that BGL has. Little to no useful documentation (at least not where it's really needed) and not enough examples only aggravate matters. That's no way to write code.

I'd recommend switching to LEMON. It's stable, written in C++, easy-to-understand and code in, offers several specialized forms of graphs to support different usage needs, and it supports both BFS and DFS search/visitor functions. It also has its own equivalent of property maps for nodes/edges, so you should be able to fit your own graph structure and other data onto it.

Try LEMON; it tastes a lot better and will cause fewer ulcers. ;-)

这篇关于如何将自定义图形设置为boost图形库模板?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆