如果做有关图论的题,数据用哪种容器存储比较好呢??

wengzhong 2003-04-06 03:08:56
相信大家都做过相关的题
比如货郎卖货要到达所有的城市,
哈密顿环的穷举,
还有就象2003ACM的第一题.
1.这些题在解决时,需要存储很多的数据,这些数据用,邻接矩阵,或者邻接表来存储.
我要是想用C++提供的容器来存储,该用什么呢??
<vector>?<list>?<map>?or 其他的??
2.在标准库里有没有现成的求最短路径的函数呢??或者是哈密顿环的穷举函数??

!!!谢谢!!!
...全文
42 2 打赏 收藏 转发到动态 举报
写回复
用AI写文章
2 条回复
切换为时间正序
请发表友善的回复…
发表回复
Cybergate 2003-04-06
  • 打赏
  • 举报
回复
The Standard Library only provides basic and common containers and algorithms. It is impossible for them to include everything.

A vector is an alternative to built-in arrays that supports random accessing and reallocating, a list is much like a link list, and a map, using the Binary-Tree structure, acts just like a dictionary.

I suggest that an ACM competetor not use the Standard Libarary unless the performance is not too important. We have found that programs using STL is on average 20% slower than those which use your own code even when compiled under Release Mode.
supperbeyond 2003-04-06
  • 打赏
  • 举报
回复
这个一般用vector代替原来的数组就行了
boost库里面还有一些经典的图论泛形算法,配合vector连算法都省了,专注与解决问题的方法即可了

24,854

社区成员

发帖
与我相关
我的任务
社区描述
C/C++ 工具平台和程序库
社区管理员
  • 工具平台和程序库社区
加入社区
  • 近7日
  • 近30日
  • 至今
社区公告
暂无公告

试试用AI创作助手写篇文章吧