图的操作与实现

/ 2,917评论 / 15774阅读 / 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. NelsonSaIlk说道:

    mexican online pharmacies prescription drugs: mexico drug stores pharmacies – pharmacies in mexico that ship to usa

  2. Arnoldscava说道:

    buying from online mexican pharmacy mexican online pharmacies prescription drugs pharmacies in mexico that ship to usa

  3. Waynetar说道:

    mexican border pharmacies shipping to usa: mexican pharmaceuticals online – buying prescription drugs in mexico online

  4. DominicHOr说道:

    mexican rx online: best online pharmacies in mexico – reputable mexican pharmacies online

  5. NelsonSaIlk说道:

    mexican pharmaceuticals online: mexican online pharmacies prescription drugs – mexican mail order pharmacies

  6. Arnoldscava说道:

    best online pharmacies in mexico medicine in mexico pharmacies buying from online mexican pharmacy

  7. Waynetar说道:

    buying prescription drugs in mexico: purple pharmacy mexico price list – mexican rx online

  8. DominicHOr说道:

    reputable mexican pharmacies online: mexican border pharmacies shipping to usa – pharmacies in mexico that ship to usa

  9. NelsonSaIlk说道:

    mexican pharmaceuticals online: medicine in mexico pharmacies – best online pharmacies in mexico

  10. Arnoldscava说道:

    medication from mexico pharmacy medicine in mexico pharmacies mexican mail order pharmacies

  11. Can I simply say what a comfort to uncover someone who truly understands what they are talking about on the internet. You definitely know how to bring an issue to light and make it important. More and more people ought to read this and understand this side of the story. It’s surprising you are not more popular because you definitely possess the gift.

  12. Waynetar说道:

    mexican border pharmacies shipping to usa: mexico pharmacies prescription drugs – mexican drugstore online

  13. DominicHOr说道:

    purple pharmacy mexico price list: mexico pharmacies prescription drugs – mexican border pharmacies shipping to usa

  14. Howdy! I could have sworn I’ve visited this blog before but after looking at many of the articles I realized it’s new to me. Regardless, I’m certainly pleased I found it and I’ll be bookmarking it and checking back often!

  15. NelsonSaIlk说道:

    mexican pharmaceuticals online: buying prescription drugs in mexico online – mexican rx online

  16. Arnoldscava说道:

    mexican pharmacy mexico drug stores pharmacies medication from mexico pharmacy

  17. Wonderful article! We are linking to this particularly great content on our site. Keep up the good writing.

  18. This site was… how do you say it? Relevant!! Finally I have found something that helped me. Thanks a lot.

  19. Way cool! Some extremely valid points! I appreciate you penning this write-up plus the rest of the site is very good.

  20. DominicHOr说道:

    pharmacies in mexico that ship to usa: mexican pharmaceuticals online – medication from mexico pharmacy

  21. Arnoldscava说道:

    medicine in mexico pharmacies mexican drugstore online mexico drug stores pharmacies

  22. Waynetar说道:

    mexico drug stores pharmacies: mexican drugstore online – mexican mail order pharmacies

  23. DominicHOr说道:

    mexico pharmacies prescription drugs: mexican border pharmacies shipping to usa – pharmacies in mexico that ship to usa

  24. Hi” best wishes to you and your very nice blog”   

  25. RichardMonge说道:

    https://mexicandeliverypharma.online/# mexico drug stores pharmacies

  26. NelsonSaIlk说道:

    п»їbest mexican online pharmacies: mexican online pharmacies prescription drugs – buying prescription drugs in mexico online

  27. Arnoldscava说道:

    mexican mail order pharmacies mexico pharmacies prescription drugs pharmacies in mexico that ship to usa

  28. Waynetar说道:

    mexican mail order pharmacies: buying prescription drugs in mexico online – п»їbest mexican online pharmacies

  29. DominicHOr说道:

    medication from mexico pharmacy: mexican mail order pharmacies – mexican mail order pharmacies

  30. Arnoldscava说道:

    purple pharmacy mexico price list medication from mexico pharmacy reputable mexican pharmacies online

  31. RichardMonge说道:

    https://mexicandeliverypharma.online/# buying prescription drugs in mexico online

  32. DominicHOr说道:

    mexico drug stores pharmacies: medicine in mexico pharmacies – mexican border pharmacies shipping to usa

  33. Waynetar说道:

    mexican border pharmacies shipping to usa: mexico pharmacies prescription drugs – best online pharmacies in mexico

  34. Arnoldscava说道:

    buying from online mexican pharmacy medicine in mexico pharmacies medicine in mexico pharmacies

  35. Waynetar说道:

    best online pharmacies in mexico: reputable mexican pharmacies online – buying prescription drugs in mexico

  36. DominicHOr说道:

    mexico pharmacies prescription drugs: best online pharmacies in mexico – mexico drug stores pharmacies

  37. RichardMonge说道:

    https://mexicandeliverypharma.com/# mexican border pharmacies shipping to usa

  38. Arnoldscava说道:

    mexican pharmacy best online pharmacies in mexico medication from mexico pharmacy

  39. tms 治療とは说道:

    Thus profit is made by selling one currency into another market.

  40. With the advent of computers, backtesting can be performed on entire exchanges over decades of historic data in very short amounts of time.

  41. Mountain U.S. 421 Scenic Byway Follows US 221 and US 421 from the Blue Ridge Parkway, in Deep Hole, to the South Fork New River, near Boone.

  42. Klikx说道:

    You have made some good points there. I checked on the net to learn more about the issue and found most people will go along with your views on this website.

  43. MP3Juice说道:

    When I originally commented I appear to have clicked on the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the exact same comment. There has to be a means you can remove me from that service? Appreciate it.

  44. this page说道:

    I love reading through a post that will make people think. Also, thank you for allowing for me to comment.

  45. CEO quang huy说道:

    Great information. Lucky me I came across your site by accident (stumbleupon). I have book marked it for later!

  46. This web site truly has all the information and facts I needed concerning this subject and didn’t know who to ask.

  47. You have made some good points there. I checked on the internet for more information about the issue and found most people will go along with your views on this web site.

  48. Everything is very open with a precise description of the challenges. It was truly informative. Your website is useful. Many thanks for sharing!

  49. 78win说道:

    This is the right webpage for anybody who hopes to understand this topic. You realize so much its almost hard to argue with you (not that I actually will need to…HaHa). You definitely put a fresh spin on a topic that’s been written about for many years. Great stuff, just great.

  50. Alphonso Bonning说道:

    Pretty! This has been an extremely wonderful post. Thank you for supplying this information.

发表回复

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