图的操作与实现

/ 3,798评论 / 18954阅读 / 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();
}
  1. link tải iwin说道:

    I really like it whenever people get together and share ideas. Great site, stick with it.

  2. porn说道:

    Very nice article. I absolutely appreciate this site. Keep writing!

  3. sex说道:

    This is the right blog for anybody who wishes to understand this topic. You understand a whole lot its almost hard to argue with you (not that I personally will need to…HaHa). You definitely put a fresh spin on a topic which has been discussed for years. Great stuff, just great.

  4. kontol说道:

    This is a topic that is near to my heart… Best wishes! Exactly where are your contact details though?

  5. ngentot说道:

    This web site truly has all of the information I wanted about this subject and didn’t know who to ask.

  6. ngentot说道:

    I was able to find good information from your blog posts.

  7. Very good write-up. I definitely love this site. Keep writing!

  8. 부천퍼블릭说道:

    This excellent website truly has all of the info I wanted concerning this subject and didn’t know who to ask.

  9. best way to travel from madrid to lisbon

  10. minimalist logo说道:

    The very next time I read a blog, I hope that it won’t fail me just as much as this one. After all, I know it was my choice to read through, however I truly believed you would have something useful to say. All I hear is a bunch of moaning about something you could possibly fix if you were not too busy looking for attention.

  11. stikes说道:

    Excellent web site you have here.. It’s hard to find excellent writing like yours these days. I honestly appreciate individuals like you! Take care!!

  12. AiDigiTales说道:

    There is certainly a great deal to find out about this issue. I really like all the points you’ve made.

  13. FIP UMJ说道:

    This is a topic that’s close to my heart… Thank you! Where are your contact details though?

  14. Good post! We will be linking to this great article on our website. Keep up the great writing.

  15. tubidy说道:

    Your style is so unique compared to other people I have read stuff from. Thank you for posting when you’ve got the opportunity, Guess I’ll just bookmark this site.

  16. This is a topic that is close to my heart… Many thanks! Exactly where are your contact details though?

  17. An interesting discussion is worth comment. I think that you should write more on this topic, it might not be a taboo subject but typically people do not talk about such subjects. To the next! Cheers!

  18. bestiptv1说道:

    It’s hard to find experienced people for this topic, however, you sound like you know what you’re talking about! Thanks

  19. I enjoy reading a post that will make men and women think. Also, thanks for allowing for me to comment.

  20. Very good information. Lucky me I came across your blog by accident (stumbleupon). I’ve book-marked it for later.

  21. Slot gacor说道:

    Your style is very unique in comparison to other folks I have read stuff from. Many thanks for posting when you have the opportunity, Guess I’ll just book mark this web site.

  22. ngentot说道:

    Nice post. I learn something totally new and challenging on sites I stumbleupon everyday. It will always be interesting to read content from other authors and use a little something from other web sites.

  23. ngentot pepek说道:

    This site was… how do you say it? Relevant!! Finally I’ve found something which helped me. Appreciate it.

  24. kontol说道:

    I used to be able to find good advice from your content.

  25. dagathomonetcom说道:

    I couldn’t resist commenting. Exceptionally well written!

  26. mp3 juice说道:

    Way cool! Some extremely valid points! I appreciate you penning this article and also the rest of the website is really good.

  27. An outstanding share! I’ve just forwarded this onto a friend who had been conducting a little homework on this. And he actually bought me dinner simply because I stumbled upon it for him… lol. So allow me to reword this…. Thank YOU for the meal!! But yeah, thanks for spending time to discuss this topic here on your blog.

  28. Great post. I used to be checking continuously this blog and I’m impressed! Extremely helpful info particularly the final section I deal with such info much. I was looking for this certain info for a long time. Thank you and best of luck.

  29. There are a handful of interesting points over time in this posting but I do not know if I see every one of them center to heart. There is certainly some validity but I will take hold opinion until I investigate it further. Good article , thanks and now we want much more! Included with FeedBurner also

  30. porn说道:

    I used to be able to find good info from your articles.

  31. Howdy! I simply would like to give a huge thumbs up for the good data you have here on this post. I will probably be coming again to your weblog for more soon.

  32. lowes ant killer说道:

    I fully agree with this above comment, the internet is with a doubt growing in the most fundamental medium of communication across the globe and its due to sites just like this that ideas are spreading so quickly.

  33. I gotta bookmark this site it seems extremely helpful very useful

  34. Sufficiently, this kind of content is usually the best for this noteworthy situation. Document harmonise collectively findings and definitely will thirstily stay up for all your inward bound features. Claiming credit won’t just seem enough, to make the exceptional clearness in your own re-writing. I could right obtain any feed maintain prepared of a typical refreshes. Exceptional perform and a lot popularity within commercial business! Please defense brand new below average English tongue as never ever a few initially language.

  35. roof rats说道:

    Wow! This can be one of the most helpful blogs we have ever come across on thesubject. Basically wonderful info! I am also an expert in this topic therefore I can understand your hard work.

  36. I truly wanted to jot down a word so as to thank you for some of the pleasant tricks you are giving out on this site. My rather long internet look up has at the end been recognized with brilliant suggestions to exchange with my friends and classmates. I would believe that many of us readers actually are unequivocally fortunate to be in a really good network with very many marvellous individuals with great suggestions. I feel really grateful to have encountered your entire web site and look forward to tons of more amazing times reading here. Thank you once more for a lot of things.

  37. An interesting discussion may be worth comment. I do believe that you ought to write much more about this topic, it might certainly be a taboo subject but usually folks are too few to communicate on such topics. Yet another. Cheers

  38. termite company说道:

    Yes, I was totally in tune with that. So was my Dad. He said he definitely intends to check it out soon. We will return before you can say anything.

  39. Last month, when i visited your blog i got an error on the mysql server of yours.*’.*-

  40. It is a massive and a highly intriguing e mail take a look at on this excellent weblog.

  41. Greetings! Very helpful advice in this particular post! It’s the little changes that will make the greatest changes. Thanks for sharing!

  42. AI for children说道:

    I’d like to thank you for the efforts you’ve put in penning this blog. I am hoping to view the same high-grade content from you in the future as well. In fact, your creative writing abilities has motivated me to get my very own website now 😉

  43. jambiprov说道:

    You should be a part of a contest for one of the greatest sites online. I most certainly will highly recommend this website!

  44. 백링크说道:

    This is exactly what I was looking for.SEO

  45. Your analysis is thorough and well-reasoned.무직자 3012만원 대출

  46. Your post has sparked a lot of ideas for me.주부 대출

  47. berita aceh说道:

    Way cool! Some very valid points! I appreciate you writing this article and the rest of the site is also very good.

发表回复

您的电子邮箱地址不会被公开。 必填项已用 * 标注