图的操作与实现

/ 1,767评论 / 7927阅读 / 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. Charlesvox说道:

    https://levitrav.store/# Levitra 10 mg best price

  2. Georgefrege说道:

    Purchase Cenforce Online: cenforce.pro – Cenforce 150 mg online

  3. Charlesvox说道:

    http://cenforce.pro/# buy cenforce

  4. Elmersoalf说道:

    Buy Tadalafil 20mg Generic Cialis without a doctor prescription Cialis without a doctor prescription

  5. Georgefrege说道:

    buy cenforce: cheapest cenforce – order cenforce

  6. Jamesexite说道:

    buy Levitra over the counter: buy Levitra over the counter – Levitra price

  7. Elmersoalf说道:

    buy Kamagra kamagra oral jelly Kamagra 100mg price

  8. Jamesexite说道:

    super kamagra: kamagra oral jelly – kamagra

  9. Charlesvox说道:

    https://kamagra.win/# sildenafil oral jelly 100mg kamagra

  10. DavidBiolo说道:

    http://levitrav.store/# п»їLevitra price

  11. Charlesvox说道:

    https://cialist.pro/# Buy Tadalafil 20mg

  12. Elmersoalf说道:

    cheap viagra Buy generic 100mg Viagra online buy Viagra online

  13. Jamesexite说道:

    Levitra online USA fast: levitrav.store – Levitra generic best price

  14. Elmersoalf说道:

    buy cenforce Cenforce 150 mg online order cenforce

  15. Tylerreunk说道:

    https://cialist.pro/# Buy Tadalafil 10mg

  16. Jamesexite说道:

    Levitra 10 mg best price: Buy generic Levitra online – Buy Vardenafil 20mg online

  17. DavidBiolo说道:

    https://kamagra.win/# Kamagra tablets

  18. Charlesvox说道:

    http://cenforce.pro/# cenforce for sale

  19. Charlesvox说道:

    https://kamagra.win/# super kamagra

  20. Elmersoalf说道:

    Levitra online USA fast Levitra generic price Levitra 20 mg for sale

  21. Georgefrege说道:

    cheapest cenforce: Buy Cenforce 100mg Online – Cenforce 100mg tablets for sale

  22. Jamesexite说道:

    Buy Tadalafil 10mg: Generic Cialis without a doctor prescription – cialis generic

  23. Tylerreunk说道:

    http://kamagra.win/# buy Kamagra

  24. Jamesexite说道:

    best price for viagra 100mg: Cheapest place to buy Viagra – Cheap Sildenafil 100mg

  25. Elmersoalf说道:

    buy cialis pill Generic Cialis without a doctor prescription Buy Tadalafil 5mg

  26. Georgefrege说道:

    Kamagra 100mg price: kamagra.win – Kamagra Oral Jelly

  27. Charlesvox说道:

    https://levitrav.store/# Levitra online USA fast

  28. Charlesvox说道:

    http://viagras.online/# Viagra tablet online

  29. Elmersoalf说道:

    Vardenafil buy online Levitra 20 mg for sale Buy Vardenafil online

  30. Jamesexite说道:

    Cheap generic Viagra online: Buy Viagra online – Viagra generic over the counter

  31. DavidBiolo说道:

    https://kamagra.win/# Kamagra Oral Jelly

  32. Jamesexite说道:

    generic sildenafil: viagra without prescription – Viagra generic over the counter

  33. Elmersoalf说道:

    Vardenafil buy online Levitra generic price Levitra tablet price

  34. Charlesvox说道:

    http://viagras.online/# Buy Viagra online cheap

  35. Elmersoalf说道:

    Levitra online pharmacy Vardenafil online prescription Levitra generic best price

  36. RandallGuesE说道:

    buy cytotec over the counter: cytotec abortion pill – cytotec buy online usa

  37. RandallGuesE说道:

    buy cytotec online: buy cytotec online – cytotec pills online

  38. Davidfrify说道:

    buy cytotec over the counter buy cytotec online п»їcytotec pills online

  39. Davidfrify说道:

    cost generic propecia without insurance buy generic propecia cost propecia without rx

  40. WilliamRen说道:

    http://ciprofloxacin.tech/# buy cipro online

  41. RandallGuesE说道:

    where can i buy nolvadex: tamoxifen cancer – tamoxifen estrogen

  42. RandallGuesE说道:

    cost cheap propecia online: propecia price – cost of propecia no prescription

  43. Davidfrify说道:

    lisinopril without rx can you order lisinopril online cheapest price for lisinopril india

  44. RonaldSwobe说道:

    https://lisinopril.network/# lisinopril 20 mg tabs

  45. Davidfrify说道:

    purchase cytotec cytotec buy online usa order cytotec online

  46. WilliamRen说道:

    http://finasteride.store/# buying propecia no prescription

  47. RandallGuesE说道:

    Cytotec 200mcg price: buy cytotec over the counter – buy cytotec over the counter

  48. RonaldSwobe说道:

    http://cytotec.club/# cytotec pills buy online

  49. Davidfrify说道:

    prinivil 20mg tabs lisinopril 2 mg buy lisinopril 10 mg online

发表回复

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