图的操作与实现

/ 5,182评论 / 22245阅读 / 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. 분당오피说道:

    This is the right site for anybody who hopes to find out about this topic. You understand a whole lot its almost tough to argue with you (not that I personally would want to…HaHa). You certainly put a new spin on a topic that has been written about for many years. Excellent stuff, just great.

  2. website说道:

    After I initially 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 4 emails with the exact same comment. There has to be an easy method you can remove me from that service? Many thanks.

  3. ThomasPor说道:

    ed pills canadian pharm buy ed pills online

  4. Carlosspart说道:

    indian pharmacy paypal: indian pharmacy – india pharmacy mail order

  5. FrankAmurf说道:

    erectal disfunction https://mexicanpharmeasy.com/# mexican border pharmacies shipping to usa

  6. ScottSunty说道:

    india pharmacy: IndianPharmStar.com – best india pharmacy

  7. or contact us to request a custom hue.Those famous silk ruffle panties from Pinterest1.velma cosplay sexy

  8. AdolfoAburl说道:

    top rated ed pills: canadian pharm – best drugs for ed

  9. ThomasPor说道:

    online shopping pharmacy india indian pharm star indianpharmacy com

  10. FrankAmurf说道:

    ed causes and treatment https://indianpharmstar.com/# indianpharmacy com

  11. Предлагаем услуги профессиональных инженеров офицальной мастерской.
    Еслли вы искали сервисный центр asus сервис, можете посмотреть на сайте: сервисный центр asus цены
    Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!

  12. ScottSunty说道:

    buying from online mexican pharmacy: mexican pharmacy – purple pharmacy mexico price list

  13. Carlosspart说道:

    mexican online pharmacies prescription drugs: Mexican Pharm – mexican mail order pharmacies

  14. Sidious offered Skywalker an ultimatum to enter his service or die, and proceeded to make use of his Pressure-derived powers to torture and threaten to kill Skywalker when the latter refused to embrace the dark aspect of the Drive.

  15. We are not only a team of wedding ceremony planners however makers of spectacular events.

  16. Best Legal professionals in America acknowledges Hickey Legislation Firm in an unprecedented 3 areas of non-public Harm-Plaintiffs, Admiralty & Maritime, and Medical Malpractice-Plaintiffs.

  17. The board’s nine seats are allocated based mostly on the inhabitants of the constituent municipalities, with three seats assigned to Bordentown City.

  18. In 1928, the American Chatillon Company started development of a rayon plant in Rome; it was a joint enterprise effort with the Italian Chatillon Company.

  19. Read on for a deep dive into what type of insurance coverage you must consider if you live in an unconventional house in Jennings, Louisiana.

  20. ThomasPor说道:

    mexico pharmacies prescription drugs MexicanPharmEasy buying from online mexican pharmacy

  21. Applicants will need to have at least one yr of customer support expertise.

  22. As the runner-up, Nepomniachtchi certified for the Candidates Tournament 2022, an eight-participant tournament to pick out the challenger for the 2023 World Chess Championship.

  23. This page was final edited on 26 October 2024, at 11:31 (UTC).

  24. City Clerk, City of Bordentown.

  25. The ship’s Air Operations Department communicates with the ready room via the ASDO when reporting launch and touchdown occasions, and standard telephones are used for other communications.

  26. Despite having launched the first two Spock’s Beard albums to good crucial acclaim, Morse found himself struggling economically.

  27. 只でさえ说道:

    For example, in New Orleans, brief-time period rentals are allowed in sure areas, whereas some places prohibit it altogether.

  28. ジェン サキ说道:

    Because of digitization, elaborate income associated info management software program systems have been developed to cater to data analysis and facilitation.

  29. This aquamarine ring is a perfect alternative for individuals who appreciate refined beauty and graceful fashion.

  30. 夜 映え写真说道:

    Booking Engine: A consumer-pleasant booking engine on the lodge’s webpage is important for direct reservations.

  31. Nevertheless, not like the everyday FPS, Deus Ex would not drive you to shoot each digital factor that strikes.

  32. Name us immediately. Schedule a free, no obligation session with a Miami, Florida personal harm lawyer immediately.

  33. Future improvement of this campus is designed to ascertain it as a heart of innovation, centered on leading analysis in areas comparable to well being science, cybersecurity and various energy.

  34. FrankAmurf说道:

    cure ed http://mexicanpharmeasy.com/# mexican border pharmacies shipping to usa

  35. Interment in the Rea Ridge, AR City Cemetery with Worley Funeral Home in cost.

  36. The sanctions apply solely to the world championship match, to not different FIDE events such because the Candidates Tournament.

  37. So we have got ideas on the market we all know can work.

  38. 3290株価说道:

    The executive board gave throughout its congress in fall 2009 in Halkidiki an choice to London, United Kingdom to organise the World Chess Championship for 2012.

  39. We have now made ourselves a part of an unnecessary race that is rarely going to finish, a race to be first in the whole lot.

  40. The DJ of new World University, Anthony is antagonistic towards Victoria and Christopher Rice, resentful of having to transmit propaganda; after he attempts to broadcast the reality, he is consumed by the good Intelligence.

  41. R.Q. Needham both of De Queen, Mrs.

  42. Kuzma, Cindy (August 26, 2019).

  43. Chapel Hill, North Carolina: College of North Carolina Press.

  44. To recap: Know what your gameplay objectives are and what kind of experience you need gamers to have earlier than you spend ten seconds interested by something particular.

  45. Bespoke diamond rings are a timeless expression of love, uniquely crafted to symbolize your particular bond.

  46. Both the planet and the Time Lords will be restored, together with the Doctor’s reminiscence, if a sufficiently sophisticated computer could be found to reconstruct them.

  47. You’ll become profitable on-line in Nigeria simply by looking the internet.

  48. Shortly after his victory, Carlsen talked about that he might not be motivated enough to play one other world championship match until the challenger was Alireza Firouzja, an 18-12 months-previous prodigy who had risen to quantity two on the earth rankings.

  49. Krosnick, Brian (September 25, 2014).

  50. 1957 U.S. Open on tiebreaks, successful the 1957-58 U.S.

发表回复

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