图的操作与实现

/ 3,803评论 / 18973阅读 / 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. Williamjes说道:

    п»їfarmacia online espaГ±a: farmacia online 24 horas – farmacia online madrid

  2. RalphRef说道:

    gГјnstige online apotheke: п»їshop apotheke gutschein – ohne rezept apotheke

  3. Antoniadat说道:

    Farmacia online più conveniente: farmaci senza ricetta elenco – Farmacia online più conveniente

  4. VernonJaf说道:

    http://eumedicamentenligne.com/# pharmacie en ligne france fiable

  5. RobertindUp说道:

    farmacia online 24 horas farmacias online seguras farmacia online barata

  6. Donaldfub说道:

    pharmacie en ligne france livraison internationale: pharmacie en ligne – п»їpharmacie en ligne france

  7. Williamjes说道:

    acheter mГ©dicament en ligne sans ordonnance: Achat mГ©dicament en ligne fiable – Achat mГ©dicament en ligne fiable

  8. RobertindUp说道:

    farmacias online baratas farmacias online seguras farmacia online envГ­o gratis

  9. VernonJaf说道:

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

  10. Williamjes说道:

    pharmacie en ligne livraison europe: acheter mГ©dicament en ligne sans ordonnance – Pharmacie Internationale en ligne

  11. RalphRef说道:

    Pharmacie Internationale en ligne: pharmacie en ligne france pas cher – pharmacie en ligne france livraison internationale

  12. Donaldfub说道:

    beste online-apotheke ohne rezept: online apotheke gГјnstig – online apotheke gГјnstig

  13. Antoniadat说道:

    internet apotheke: medikamente rezeptfrei – eu apotheke ohne rezept

  14. Williamjes说道:

    beste online-apotheke ohne rezept: eu apotheke ohne rezept – online apotheke gГјnstig

  15. Antoniadat说道:

    pharmacie en ligne sans ordonnance: pharmacie en ligne avec ordonnance Рtrouver un m̩dicament en pharmacie

  16. RobertindUp说道:

    farmacia online 24 horas farmacia online espaГ±a envГ­o internacional farmacia online barata y fiable

  17. RobertindUp说道:

    ohne rezept apotheke beste online-apotheke ohne rezept online apotheke rezept

  18. Williamjes说道:

    farmacie online autorizzate elenco: Farmacie on line spedizione gratuita – farmacia online piГ№ conveniente

  19. Antoniadat说道:

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

  20. Williamjes说道:

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

  21. RobertindUp说道:

    online apotheke rezept internet apotheke internet apotheke

  22. RobertindUp说道:

    beste online-apotheke ohne rezept online apotheke internet apotheke

  23. RalphRef说道:

    pharmacie en ligne livraison europe: pharmacie en ligne – pharmacie en ligne france pas cher

  24. VernonJaf说道:

    https://eumedicamentenligne.shop/# pharmacie en ligne livraison europe

  25. Williamjes说道:

    farmacias online seguras en espaГ±a: farmacias online seguras en espaГ±a – farmacia online barcelona

  26. Antoniadat说道:

    acquistare farmaci senza ricetta: farmacie online autorizzate elenco – migliori farmacie online 2024

  27. Antoniadat说道:

    Farmacia online miglior prezzo: farmaci senza ricetta elenco – farmacie online autorizzate elenco

  28. Williamjes说道:

    Pharmacie Internationale en ligne: pharmacie en ligne livraison europe – pharmacie en ligne

  29. RobertindUp说道:

    pharmacie en ligne france pas cher pharmacie en ligne france pas cher pharmacie en ligne avec ordonnance

  30. RalphRef说道:

    п»їFarmacia online migliore: farmaci senza ricetta elenco – farmacie online autorizzate elenco

  31. kinov说道:

    Смотреть фильм 100 лет тому вперед 2024. Смотреть фильм 100 лет тому вперед 2024.

  32. VernonJaf说道:

    http://eufarmaciaonline.com/# п»їfarmacia online espaГ±a

  33. RobertindUp说道:

    farmacia online 24 horas farmacia online envГ­o gratis п»їfarmacia online espaГ±a

  34. Donaldfub说道:

    vente de mГ©dicament en ligne: pharmacie en ligne pas cher – pharmacie en ligne

  35. Williamjes说道:

    online apotheke versandkostenfrei: eu apotheke ohne rezept – online apotheke

  36. Antoniadat说道:

    migliori farmacie online 2024: acquistare farmaci senza ricetta – farmaci senza ricetta elenco

  37. Antoniadat说道:

    farmacias online baratas: farmacias direct – farmacia online españa

  38. Williamjes说道:

    Farmacie online sicure: farmacia online – farmacie online autorizzate elenco

  39. RobertindUp说道:

    farmaci senza ricetta elenco Farmacie online sicure farmacie online sicure

  40. Donaldfub说道:

    ohne rezept apotheke: online apotheke versandkostenfrei – ohne rezept apotheke

  41. RobertindUp说道:

    ohne rezept apotheke apotheke online europa apotheke

  42. RalphRef说道:

    п»їFarmacia online migliore: comprare farmaci online con ricetta – farmacie online autorizzate elenco

  43. smotretu说道:

    Per aspera ad astra

  44. Williamjes说道:

    Farmacie on line spedizione gratuita: farmacie online sicure – farmacia online senza ricetta

  45. Antoniadat说道:

    pharmacie en ligne pas cher: vente de m̩dicament en ligne Рpharmacie en ligne livraison europe

  46. Antoniadat说道:

    farmacia online envío gratis: farmacias direct – farmacia online españa

  47. Williamjes说道:

    farmacia online madrid: farmacia online barcelona – farmacia en casa online descuento

  48. RobertindUp说道:

    acquisto farmaci con ricetta farmacie online affidabili farmacia online

发表回复

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