图的操作与实现

/ 5,171评论 / 22220阅读 / 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. 3634 株価说道:

    The most popular alternate options to 2.Nf3 are 2.f4 (the King’s Gambit), 2.Nc3 (the Vienna Sport), and 2.Bc4 (the Bishop’s Opening).

  2. In Star Wars Episode III: Revenge of the Sith, in the meantime, Palpatine claims that the darkish aspect gave the Sith lord Darth Plagueis energy over dying itself.

  3. Imitation jewellery is made up of of less useful supplies including base metals, glass, plastic, synthetic stones and so forth.

  4. It was perhaps that lack of exercise that value him when a shot fired in from Jake Moult was palmed back out into the goalmouth for former Heed man Rankine to head dwelling from six yards.

  5. In the Flagstaff space, layers of rock from the Paleozoic and Mesozoic eras accumulated up to 10,000 feet (3,000 m) deep, but most of this was eroded.

  6. 実用○案说道:

    From 1777 to 1778, Lieutenant Common Henry Clinton was providing meals for the Convention Military, however he finally decided to end his assistance and to place the full economic burden of offering for the prisoners on the US authorities.

  7. Anakin’s children, Leia, and Luke Skywalker would turn into key members of the Rebel Alliance to restore the Galactic Republic.

  8. In the end result, computer systems turned cheats: they were loaded with increasingly reminiscence of the perfect video games by the strongest masters and thus infringe the rules which prevent human masters from taking part in with an open chess e-book at their elbow.

  9. Persevering with to the northeast at EF2 power, the tornado struck the town of Pembroke straight, the place numerous giant bushes had been snapped or uprooted, and multiple homes sustained considerable roof damage, including two homes that had their roofs torn off alongside Mason Lane at the south edge of city.

  10. He obtained into each school he applied to but turned them all down.

  11. It was perhaps that lack of exercise that value him when a shot fired in from Jake Moult was palmed back out into the goalmouth for former Heed man Rankine to head dwelling from six yards.

  12. To have a novel and attractive wedding decoration, you need to rent the best marriage ceremony decorator in Bangalore.

  13. Bordentown Regional College District 2016 Report Card Narrative Archived December 1, 2017, on the Wayback Machine, New Jersey Division of Training.

  14. Frankdon说道:

    Amoxil Pharm Store: Amoxil Pharm Store – Amoxil Pharm Store

  15. The courses offered in the highest administration colleges of the world are meant to fit the needs of the students for training and knowledge, as well as the requirements of the tourism industry itself.

  16. Alternatively in Punjab the brides wear ivory and pink bangles which might be often known as chooda.

  17. The participant named first performs the white pieces.

  18. You possibly can attend as many lessons as you want, on Perth CBD, online.

  19. Survived by one son, James A Hersey, Wilbur, WA; 3 daughters, Mrs Elizabeth Martin, Spokane, Mrs Helen Blakesley, Federal Means, WA; Mrs Donna Sullivan, Davenport, WA; 2 brothers, W J Elledge, Boise, ID; J I Elledge, Nampa, ID; 2 sisters, Mrs Grace Bailey, Weiser, Idaho; Mrs Could Nyhart, Ontario, Oregon; 14 grandchildren, 2 great grandchildren.

  20. Scientific and excessive tech research and development operations are in the city, together with Lowell Observatory, Northern Arizona University, the United States Naval Observatory Flagstaff Station (NOFS) and the United States Geological Survey’s (USGS) Flagstaff campus.

  21. There was confusion as to why the objective was not allowed to face however Boshell removed any doubt as to the validity of the equaliser when he drilled in from the spot”. Information of our subsequent opponents comes from the Oxford Mail. It says that “Oxford United striker James Roberts scored in his first game back from compassionate leave on mortgage at Chester.

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

  23. He dueled Maul, Kanan Jarrus, Ezra Bridger, and Ahsoka Tano alongside his fellow Inquisitors, the Fifth Brother and the Seventh Sister, however the latter two had been in the end killed by Maul.

  24. We knew we would should wean gamers from traditional puzzle/solution considering and present them that Deus Ex was a game of problems (not puzzles!), all solvable in a variety of how.

  25. Is it better to cease the action while the player is in interface screens or to maintain the action going a la System Shock 2?

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

  27. スーモ 会社说道:

    Aerial Tram Journey – watching the wealthy vegetation and ecosystem above the trees is one nice adventure for the entire family.

  28. This is not difficult in nowadays because there are many amenities to perform this part of Umrah, however it was really tough at the time of Hazrat Ismail (AS) when He cries for water and his mother tried to find some water.

  29. She was preceded indeath by her husband, Leonard Hampson, who died July 22, 1973, and one son, Leonard L. Hampson, who died March 14, 1989.

  30. Boostaro说道:

    This article is wonderful. I discovered the information very useful and clear. Thanks for sharing such valuable information.

  31. 15 miles (24 km) to the east of Flagstaff is the city of Winona.

  32. Funeral providers have been within the Church of Christ, Lexington, on Saturday, Oct.

  33. Robertproke说道:

    http://semaglutidepharm.com/# Buy semaglutide pills

  34. Marc Allen, Marsha Elaine, Lori Ellen, and Mary Ann Stoner.

  35. The Monkey’s Bum first appeared in print five years later within the British Chess Journal.

  36. Boostaro说道:

    This is amazing! Packed with helpful insights and very clear. Many thanks for providing this.

  37. Fashion webpage. Since we also have an unique video buying service, you’ll be able to join with us easily by way of video name.

  38. HarrySteag说道:

    Ivermectin Pharm: Ivermectin Pharm Store – Ivermectin Pharm Store

  39. Frankdon说道:

    over the counter amoxicillin: amoxicillin for sale – AmoxilPharm

  40. Robertproke说道:

    http://paxlovid.ink/# Paxlovid over the counter

  41. Frankdon说道:

    Amoxil Pharm Store: AmoxilPharm – amoxicillin buy no prescription

  42. Robertproke说道:

    http://paxlovid.ink/# Paxlovid.ink

  43. discover this说道:

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

  44. Edwardhem说道:

    rybelsus Rybelsus 7mg buy semaglutide online

  45. Frankdon说道:

    Paxlovid.ink: paxlovid cost without insurance – Paxlovid.ink

  46. Robertproke说道:

    https://amoxilpharm.store/# Amoxil Pharm Store

  47. Spot on with this write-up, I actually believe this site needs far more attention. I’ll probably be back again to read through more, thanks for the info!

  48. ScottSunty说道:

    buying from online mexican pharmacy: MexicanPharmEasy – mexico drug stores pharmacies

  49. FrankAmurf说道:

    overcoming ed http://mexicanpharmeasy.com/# mexico pharmacies prescription drugs

发表回复

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