图的操作与实现

/ 3,041评论 / 16966阅读 / 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. Robertperma说道:

    Abortion pills online cytotec pills buy online п»їcytotec pills online

  2. Waynetar说道:

    mexican online pharmacies prescription drugs: buying from online mexican pharmacy – buying prescription drugs in mexico

  3. Slot说道:

    Greetings! Very useful advice within this post! It is the little changes that produce the biggest changes. Thanks for sharing!

  4. NelsonSaIlk说道:

    best online pharmacies in mexico: mexico drug stores pharmacies – mexican rx online

  5. DominicHOr说道:

    buying prescription drugs in mexico: mexican online pharmacies prescription drugs – medicine in mexico pharmacies

  6. Arnoldscava说道:

    mexico pharmacies prescription drugs best online pharmacies in mexico best online pharmacies in mexico

  7. view说道:

    Having read this I thought it was rather informative. I appreciate you spending some time and energy to put this short article together. I once again find myself spending a lot of time both reading and posting comments. But so what, it was still worth it!

  8. Waynetar说道:

    mexican drugstore online: reputable mexican pharmacies online – reputable mexican pharmacies online

  9. NelsonSaIlk说道:

    medication from mexico pharmacy: best online pharmacies in mexico – mexico pharmacies prescription drugs

  10. DominicHOr说道:

    mexican border pharmacies shipping to usa: purple pharmacy mexico price list – best online pharmacies in mexico

  11. iptv说道:

    bookmarked!!, I love your website.

  12. Arnoldscava说道:

    п»їbest mexican online pharmacies mexican mail order pharmacies mexican mail order pharmacies

  13. iptv说道:

    When I initially left a comment I seem to have clicked the -Notify me when new comments are added- checkbox and from now on every time a comment is added I get four emails with the exact same comment. Perhaps there is a means you are able to remove me from that service? Cheers.

  14. iptv说道:

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

  15. Waynetar说道:

    best online pharmacies in mexico: medicine in mexico pharmacies – mexico drug stores pharmacies

  16. NelsonSaIlk说道:

    mexican rx online: reputable mexican pharmacies online – mexican drugstore online

  17. DominicHOr说道:

    medicine in mexico pharmacies: pharmacies in mexico that ship to usa – п»їbest mexican online pharmacies

  18. Arnoldscava说道:

    mexican mail order pharmacies mexican border pharmacies shipping to usa buying prescription drugs in mexico online

  19. iptv说道:

    Good info. Lucky me I discovered your blog by accident (stumbleupon). I’ve book-marked it for later.

  20. Waynetar说道:

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

  21. iptv说道:

    Spot on with this write-up, I really believe this amazing site needs a lot more attention. I’ll probably be returning to read through more, thanks for the information!

  22. DominicHOr说道:

    medicine in mexico pharmacies: buying prescription drugs in mexico – mexican mail order pharmacies

  23. NelsonSaIlk说道:

    mexico drug stores pharmacies: mexican border pharmacies shipping to usa – medication from mexico pharmacy

  24. anime girl说道:

    I really like reading through a post that will make people think. Also, many thanks for allowing for me to comment.

  25. Arnoldscava说道:

    mexican border pharmacies shipping to usa mexican border pharmacies shipping to usa medication from mexico pharmacy

  26. porn说道:

    Nice post. I learn something totally new and challenging on blogs I stumbleupon every day. It’s always useful to read articles from other authors and use something from other websites.

  27. Diwali snacks说道:

    Good post. I absolutely love this site. Continue the good work!

  28. Waynetar说道:

    buying prescription drugs in mexico: purple pharmacy mexico price list – mexico pharmacies prescription drugs

  29. DominicHOr说道:

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

  30. NelsonSaIlk说道:

    buying prescription drugs in mexico online: reputable mexican pharmacies online – medication from mexico pharmacy

  31. Arnoldscava说道:

    mexico drug stores pharmacies medicine in mexico pharmacies mexico drug stores pharmacies

  32. Waynetar说道:

    mexican rx online: mexico drug stores pharmacies – mexico pharmacies prescription drugs

  33. DominicHOr说道:

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

  34. NelsonSaIlk说道:

    mexican rx online: mexican pharmaceuticals online – mexico pharmacies prescription drugs

  35. There were dramatic differences against the bulky 1971-73 models, the II being some 20 inches shorter overall, nearly 13 inches trimmer between wheel centers, four inches narrower, an inch lower, and — the important part — lighter by a whopping 400-500 pounds.

  36. Arnoldscava说道:

    mexican pharmaceuticals online mexican border pharmacies shipping to usa buying from online mexican pharmacy

  37. Waynetar说道:

    mexico pharmacies prescription drugs: mexican pharmaceuticals online – mexican rx online

  38. DominicHOr说道:

    mexican border pharmacies shipping to usa: mexican rx online – purple pharmacy mexico price list

  39. NelsonSaIlk说道:

    mexican rx online: mexico pharmacies prescription drugs – buying from online mexican pharmacy

  40. Arnoldscava说道:

    mexican pharmacy mexico pharmacies prescription drugs mexican pharmacy

  41. Waynetar说道:

    medication from mexico pharmacy: mexican border pharmacies shipping to usa – buying prescription drugs in mexico online

  42. DominicHOr说道:

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

  43. NelsonSaIlk说道:

    mexican drugstore online: buying from online mexican pharmacy – buying prescription drugs in mexico

  44. Arnoldscava说道:

    buying from online mexican pharmacy mexico pharmacy buying from online mexican pharmacy

  45. Waynetar说道:

    best online pharmacies in mexico: medication from mexico pharmacy – mexico drug stores pharmacies

  46. DominicHOr说道:

    buying prescription drugs in mexico: pharmacies in mexico that ship to usa – purple pharmacy mexico price list

  47. NelsonSaIlk说道:

    medicine in mexico pharmacies: buying prescription drugs in mexico online – mexico drug stores pharmacies

  48. Arnoldscava说道:

    buying prescription drugs in mexico mexican drugstore online mexican mail order pharmacies

  49. Waynetar说道:

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

  50. DominicHOr说道:

    medicine in mexico pharmacies: medicine in mexico pharmacies – buying prescription drugs in mexico

发表回复

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