图的操作与实现

/ 3,077评论 / 17287阅读 / 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. You ought to take part in a contest for one of the highest quality sites online. I most certainly will recommend this blog!

  2. There is certainly a lot to know about this issue. I like all of the points you’ve made.

  3. JamesRok说道:

    furosemide 40mg: furosemide online – lasix online

  4. 토토사이트说道:

    Very good blog post. I absolutely appreciate this site. Keep it up!

  5. StephenJonge说道:

    https://furosemide.win/# generic lasix

  6. How can you “cash out” of the investment.

  7. 真珠 投資说道:

    Zonomics by ING. This disambiguation page lists articles associated with the title Money printing.

  8. Those who came home were profoundly affected by their war experience.

  9. Banking acts lay down rules for banks which they have to observe when they are being established and when they are carrying on their business.

  10. The first essential part of any plan is your emergency fund.

  11. After I originally left a comment I appear to have clicked the -Notify me when new comments are added- checkbox and now each time a comment is added I get 4 emails with the exact same comment. There has to be an easy method you can remove me from that service? Kudos.

  12. シー 意味说道:

    The 10 largest stock exchanges (New York and Mumbai have two exchanges each).

  13. JamesRok说道:

    lipitor 40 mg: buy atorvastatin online – liptor

  14. Rybczynski, Witold. “The Ranch House Anomaly: How America Fell in and out of Love with Them.” Slate.

  15. Studies show an average 50-year-old gets as much light from a 100-watt bulb as a 20-year-old gets from a 50-watt bulb!

  16. Wonderful post! We will be linking to this great content on our website. Keep up the great writing.

  17. I would like to thank you for the efforts you have put in writing this blog. I’m hoping to check out the same high-grade blog posts from you in the future as well. In fact, your creative writing abilities has motivated me to get my own, personal site now 😉

  18. StephenJonge说道:

    https://lipitor.guru/# lipitor 5mg

  19. You made some decent points there. I looked on the internet to learn more about the issue and found most individuals will go along with your views on this site.

  20. JamesRok说道:

    lipitor prescription prices: buy lipitor 20mg – buy lipitor 40 mg

  21. DanielDrync说道:

    cytotec buy online usa http://lipitor.guru/# canada prescription price lipitor
    lasix tablet

  22. It’s hard to come by experienced people in this particular topic, however, you sound like you know what you’re talking about! Thanks

  23. StanleyMaf说道:

    lasix 40 mg lasix side effects lasix dosage

  24. JamesRok说道:

    tamoxifen buy: buy tamoxifen online – how to get nolvadex

  25. prodronessupply说道:

    An interesting discussion is definitely worth comment. I do believe that you ought to publish more about this subject, it may not be a taboo matter but typically folks don’t discuss such issues. To the next! Many thanks.

  26. StephenJonge说道:

    https://lisinopril.guru/# lisinopril 80

  27. Hello there! This article couldn’t be written much better! Looking through this article reminds me of my previous roommate! He continually kept talking about this. I most certainly will send this information to him. Fairly certain he’ll have a great read. Thank you for sharing!

  28. JamesRok说道:

    cytotec online: Misoprostol price in pharmacy – cytotec abortion pill

  29. StanleyMaf说道:

    Cytotec 200mcg price cytotec best price purchase cytotec

  30. Femininity说道:

    Very nice article. I definitely love this website. Stick with it!

  31. StephenJonge说道:

    https://tamoxifen.bid/# how does tamoxifen work

  32. JamesRok说道:

    how to prevent hair loss while on tamoxifen: nolvadex pct – nolvadex for sale

  33. It’s hard to come by knowledgeable people in this particular topic, however, you sound like you know what you’re talking about! Thanks

  34. StanleyMaf说道:

    tamoxifen bone density buy tamoxifen online tamoxifen hair loss

  35. StephenJonge说道:

    http://lipitor.guru/# lipitor generic price

  36. JamesRok说道:

    lipitor brand name: Lipitor 10 mg price – lipitor 10 mg tablet

  37. Amazon affiliate说道:

    Spot on with this write-up, I actually feel this web site needs far more attention. I’ll probably be returning to read more, thanks for the info!

  38. win79说道:

    Oh my goodness! Impressive article dude! Many thanks, However I am going through troubles with your RSS. I don’t understand why I am unable to join it. Is there anybody else having the same RSS issues? Anybody who knows the answer will you kindly respond? Thanx!!

  39. rikvip说道:

    Hi there! I could have sworn I’ve visited this blog before but after browsing through some of the articles I realized it’s new to me. Anyways, I’m definitely happy I stumbled upon it and I’ll be book-marking it and checking back regularly.

  40. Excellent blog post. I absolutely appreciate this website. Keep it up!

  41. mpox pandemic说道:

    That is a really good tip especially to those fresh to the blogosphere. Brief but very precise info… Many thanks for sharing this one. A must read post!

  42. Greetings! Very helpful advice within this post! It’s the little changes that produce the greatest changes. Thanks a lot for sharing!

  43. K8说道:

    Great info. Lucky me I found your site by chance (stumbleupon). I have saved as a favorite for later.

  44. Sugar defender Reviews说道:

    Adored this post. It’s extremely detailed and packed with helpful insights. Excellent effort!

    https://www.youtube.com/watch?v=gCDNPENmMiw

  45. onbet说道:

    Very good article! We are linking to this particularly great content on our website. Keep up the good writing.

  46. Douglasnug说道:

    mexican drugstore online: mexican rx online – mexican rx online

  47. Very good post! We will be linking to this great post on our site. Keep up the great writing.

  48. Douglasnug说道:

    mexican border pharmacies shipping to usa: mexican pharmacy – mexican pharmaceuticals online

  49. Hi there! This post couldn’t be written any better! Reading through this article reminds me of my previous roommate! He continually kept talking about this. I’ll send this article to him. Fairly certain he will have a very good read. I appreciate you for sharing!

  50. friends season1说道:

    I was very pleased to uncover this web site. I need to to thank you for your time due to this wonderful read!! I definitely savored every bit of it and I have you book marked to look at new things on your site.

发表回复

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