目录
要求
- 图的邻接表和邻接矩阵存储
- 建立下图的邻接表或邻接矩阵,并输出之;
- 思路:
- 通过遍历邻接矩阵,采用头插法即可构造邻接表。
- 图的各种遍历算法实现
- 以0结点为起点实现上述图的深度优先和广度优先遍历算法;
- 思路:
- 用堆栈实现深度优先遍历,用队列实现广度优先遍历。
- 最小生成树的算法实现
- 利用普里姆(Prim)算法或克鲁斯卡尔(Kruskal)算法求上图的最小生成树,算法实现代码必需有注释。
- 思路:
- Prim:从0点出发每次取能到达的最小权重边,走完即为一颗最小生成树。
- 最短路径的算法实现
- 利用狄克斯特拉(Dijkstra)算法求上图中0结点到其它结点的最短路径,算法实现代码必须有注释。
- 思路:
- 循环每次计算到每一个点的最小距离并记录,然后取最小距离的那个点合并。
源代码
若以下显示需要登录,请刷新页面或点击此处下载。
思考
若只求带权有向图G中从顶点i到顶点j的最短路径,如何修改Dijkstra 算法来实现这一功能?
void Dijkstra_way(int first_point)
{
int* widget_list = new int[map_size]; //记录距离0的长度
for (int i = map_size; i--;)
{
widget_list[i] = INF;
adjList[i].weight = -1;
}
widget_list[first_point] = 0;
adjList[first_point].weight = 0;
for (int i = 1; i < map_size; ++i)
for (int j = map_size; j--;) //计算距离
if (adjList[j].weight >= 0)
for (node* node_p = adjList[j].next_p; node_p != NULL; node_p = node_p->next_p)
if (widget_list[j] + node_p->weight < widget_list[node_p->data])
{
widget_list[node_p->data] = widget_list[j] + node_p->weight;
adjList[node_p->data].weight = j;
}
cout << "<< Dijkstra 最短路径:" << endl;
coolQueue<int> stack;
for (int i = 0; i < map_size; ++i)
{
for (int j = i; j != first_point;)
{
stack.End_push(j);
j = adjList[j].weight;
}
cout << "<< " << first_point;
for (int pop_int = 0; stack.End_pop(pop_int);)
cout << " -> " << pop_int;
cout << endl;
stack.clear();
}
adjList_reflush();
}
where can i buy erectile dysfunction pills: Cheapest online ED treatment – online ed meds
Hi, I do think this is a great web site. I stumbledupon it 😉 I’m going to come back yet again since i have book marked it. Money and freedom is the best way to change, may you be rich and continue to help others.
п»їed pills online: Best ED pills non prescription – erectile dysfunction online prescription
I’m impressed, I have to admit. Rarely do I come across a blog that’s equally educative and interesting, and let me tell you, you have hit the nail on the head. The issue is something not enough people are speaking intelligently about. I’m very happy I stumbled across this during my search for something regarding this.
Right here is the perfect site for everyone who really wants to find out about this topic. You realize so much its almost tough to argue with you (not that I personally will need to…HaHa). You certainly put a fresh spin on a subject which has been discussed for many years. Excellent stuff, just excellent.
Of course, the others were somewhat more expensive, while you could buy a Fury for under $3,000 — base price was $2,866 — which didn’t hurt.
This is because financial institutions have become more crucial and sophisticated in evaluating potential investments.
There is certainly a lot to learn about this subject. I really like all the points you’ve made.
http://edpillpharmacy.store/# best online ed pills
where to get ed pills: Best ED pills non prescription – buy ed pills
Very good post. I will be going through a few of these issues as well..
reputable mexican pharmacies online: Best online Mexican pharmacy – medication from mexico pharmacy
http://edpillpharmacy.store/# erectile dysfunction medicine online
Very good post. I will be dealing with many of these issues as well..
п»їlegitimate online pharmacies india: Best Indian pharmacy – п»їlegitimate online pharmacies india
Pretty! This was an extremely wonderful article. Thank you for supplying this info.
So Napster went from zero to 50 million visitors per month in something like six months.
Teach your child his name, complete address (including city and state) and phone number (including area code).
It enables participants to quickly access the information they require, while allowing them to pinpoint the exact result they desire as opposed to being buried in a deluge of data.
In 2003, McDonald鈥檚 launched a global campaign with their tagline 鈥淚鈥檓 Lovin鈥?It.鈥?This slogan is inspired by a song of the same name, which was written by Pusha T and sung by Justin Timberlake, as part of NSYNC鈥檚 album.
You are so awesome! I don’t think I have read a single thing like that before. So good to find somebody with unique thoughts on this topic. Really.. thank you for starting this up. This website is something that’s needed on the internet, someone with a bit of originality.
Use as many wireless devices as you can – your mouse, keyboard and printer – to reduce cable clutter as well.
But even if you didn’t, there’s a very good possibility that you’ll use the ubiquitous company’s search engine or one its related products sometime today.
http://mexicopharmacy.win/# mexico drug stores pharmacies
I would like to thank you for the efforts you’ve put in penning this website. I am hoping to check out the same high-grade content from you later on as well. In fact, your creative writing abilities has motivated me to get my own website now 😉
buying prescription drugs in mexico online: Best online Mexican pharmacy – mexican drugstore online
In this case it’s not toys, but military bases, trade partners and rights to natural resources in foreign countries.
Did you know that one of the most valuable from the line is Valentino the Bear?
I need to to thank you for this great read!! I certainly loved every little bit of it. I have got you bookmarked to check out new things you post…
buy prescription drugs from india: Online pharmacy USA – top 10 online pharmacy in india
Hi, I do think this is an excellent website. I stumbledupon it 😉 I’m going to revisit yet again since i have saved as a favorite it. Money and freedom is the best way to change, may you be rich and continue to help other people.
https://indiapharmacy.shop/# india pharmacy mail order
After exploring a handful of the articles on your web page, I honestly appreciate your way of blogging. I book marked it to my bookmark webpage list and will be checking back soon. Please visit my website as well and let me know what you think.
Great article. I am experiencing some of these issues as well..
buying from online mexican pharmacy: Best online Mexican pharmacy – п»їbest mexican online pharmacies
I love it when individuals get together and share views. Great website, keep it up.
Wonderful post! We will be linking to this particularly great content on our website. Keep up the good writing.
This is a really good tip particularly to those new to the blogosphere. Brief but very accurate information… Thanks for sharing this one. A must read article.
https://indiapharmacy.shop/# indian pharmacies safe
mexican pharmaceuticals online: Best online Mexican pharmacy – reputable mexican pharmacies online
online erectile dysfunction: Best ED meds online – discount ed meds
You can take your teaching knowledge one step further and, rather than signing up with a tutoring service, create your own web-based course and charge people to attend.
https://mexicopharmacy.win/# п»їbest mexican online pharmacies
mexican rx online: Medicines Mexico – medication from mexico pharmacy
Project Portfolio Optimization (PPO) is the effort to make the best decisions possible under these conditions.
I really like your blog.. very nice colors
The US TARP, the Federal Reserve’s discount window, its low rates for “an extended period of time”, its quantitative easing program, the ECB/IMF’s bailout of Greece and, most recently, their European Financial Stability Facility.
But what are your chances of losing everything with just one wrong move?
Oh my goodness! Amazing article dude! Thank you so much, However I am experiencing problems with your RSS. I don’t understand the reason why I am unable to join it. Is there anyone else getting identical RSS problems? Anybody who knows the answer can you kindly respond? Thanks.
When you approach a company to assist you with an investment, they almost always have someone that can assist with getting finance for people.