图的操作与实现

/ 3,804评论 / 18975阅读 / 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. VernonJaf说道:

    https://euapothekeohnerezept.shop/# gГјnstigste online apotheke

  2. RobertindUp说道:

    trouver un mГ©dicament en pharmacie pharmacie en ligne avec ordonnance pharmacie en ligne france pas cher

  3. RalphRef说道:

    farmacia online barcelona: farmacia online espaГ±a envГ­o internacional – farmacias online seguras

  4. Williamjes说道:

    farmacia barata: farmacia online 24 horas – farmacias online seguras en espaГ±a

  5. Antoniadat说道:

    acheter m̩dicament en ligne sans ordonnance: pharmacie en ligne Рpharmacie en ligne pas cher

  6. VernonJaf说道:

    https://eufarmaciaonline.com/# farmacia online envГ­o gratis

  7. Antoniadat说道:

    comprare farmaci online all’estero: farmacie online affidabili – Farmacie online sicure

  8. Williamjes说道:

    farmacia online envГ­o gratis: farmacia online barata y fiable – farmacia online 24 horas

  9. onlinem说道:

    Dictum – factum

  10. RobertindUp说道:

    farmacias online seguras farmacia barata farmacia online barata

  11. RobertindUp说道:

    pharmacie en ligne france pas cher pharmacie en ligne livraison europe pharmacie en ligne sans ordonnance

  12. Antoniadat说道:

    online apotheke deutschland: online apotheke rezept – günstige online apotheke

  13. Donaldfub说道:

    farmacia barata: farmacia barata – farmacia online envГ­o gratis

  14. Williamjes说道:

    farmacia online madrid: farmacia online madrid – farmacia online envГ­o gratis

  15. Antoniadat说道:

    farmacia online barata y fiable: farmacias direct – farmacia online barata y fiable

  16. Williamjes说道:

    п»їFarmacia online migliore: Farmacia online miglior prezzo – farmacie online sicure

  17. RobertindUp说道:

    pharmacie en ligne fiable pharmacie en ligne fiable trouver un mГ©dicament en pharmacie

  18. RobertindUp说道:

    Achat mГ©dicament en ligne fiable pharmacie en ligne livraison europe pharmacie en ligne fiable

  19. Donaldfub说道:

    farmacie online sicure: acquistare farmaci senza ricetta – farmacia online senza ricetta

  20. RalphRef说道:

    п»їfarmacia online espaГ±a: farmacia online barcelona – farmacias online seguras

  21. Antoniadat说道:

    acquistare farmaci senza ricetta: top farmacia online – farmacie online sicure

  22. VernonJaf说道:

    http://eufarmacieonline.com/# acquisto farmaci con ricetta

  23. Williamjes说道:

    pharmacie en ligne sans ordonnance: pharmacie en ligne france fiable – pharmacie en ligne

  24. Antoniadat说道:

    farmacia online madrid: farmacia online barata y fiable – farmacia online madrid

  25. RobertindUp说道:

    gГјnstigste online apotheke apotheke online online apotheke deutschland

  26. Williamjes说道:

    acquistare farmaci senza ricetta: Farmacie online sicure – comprare farmaci online all’estero

  27. RobertindUp说道:

    vente de mГ©dicament en ligne vente de mГ©dicament en ligne trouver un mГ©dicament en pharmacie

  28. VernonJaf说道:

    http://eufarmaciaonline.com/# farmacias online seguras en espaГ±a

  29. Psixolog说道:

    Евтушенко. Love story. и лучшие обзоры по психиатрии.

  30. RalphRef说道:

    vente de mГ©dicament en ligne: pharmacie en ligne sans ordonnance – trouver un mГ©dicament en pharmacie

  31. Antoniadat说道:

    online apotheke: günstige online apotheke – online apotheke deutschland

  32. Williamjes说道:

    farmacie online sicure: Farmacia online piГ№ conveniente – farmacia online piГ№ conveniente

  33. Antoniadat说道:

    Farmacia online migliore: comprare farmaci online con ricetta – farmacie online affidabili

  34. Williamjes说道:

    farmacias online seguras en espaГ±a: farmacia online envГ­o gratis – farmacia online madrid

  35. RobertindUp说道:

    farmacie online sicure acquistare farmaci senza ricetta Farmacie on line spedizione gratuita

  36. StevenDouri说道:

    http://36and6health.com/# pharmacy coupons

  37. Terrydex说道:

    buying from online mexican pharmacy: mexican online pharmacies prescription drugs – п»їbest mexican online pharmacies

  38. CharlesOveno说道:

    canadian world pharmacy cheapestcanada.com cross border pharmacy canada

  39. StevenDouri说道:

    http://cheapestandfast.com/# pharmacies without prescriptions

  40. Jimmieexake说道:

    https://cheapestcanada.shop/# canadian online pharmacy reviews

  41. CharlesOveno说道:

    buy prescription drugs from india top 10 pharmacies in india buy prescription drugs from india

  42. Terrydex说道:

    canadian prescription pharmacy: 36 and 6 health online pharmacy – cheapest pharmacy to get prescriptions filled

  43. Jimmieexake说道:

    https://cheapestandfast.com/# canadian pharmacy online no prescription

  44. StevenDouri说道:

    https://cheapestmexico.shop/# pharmacies in mexico that ship to usa

  45. StevenDouri说道:

    http://cheapestindia.com/# indian pharmacies safe

  46. StevenDouri说道:

    https://cheapestcanada.shop/# canadian pharmacy victoza

  47. StevenDouri说道:

    http://cheapestindia.com/# india online pharmacy

发表回复

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