目录
要求
- 图的邻接表和邻接矩阵存储
- 建立下图的邻接表或邻接矩阵,并输出之;
- 思路:
- 通过遍历邻接矩阵,采用头插法即可构造邻接表。
- 图的各种遍历算法实现
- 以0结点为起点实现上述图的深度优先和广度优先遍历算法;
- 思路:
- 用堆栈实现深度优先遍历,用队列实现广度优先遍历。
- 最小生成树的算法实现
- 利用普里姆(Prim)算法或克鲁斯卡尔(Kruskal)算法求上图的最小生成树,算法实现代码必需有注释。
- 思路:
- Prim:从0点出发每次取能到达的最小权重边,走完即为一颗最小生成树。
- 最短路径的算法实现
- 利用狄克斯特拉(Dijkstra)算法求上图中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();
}
mail order pharmacy india online shopping pharmacy india reputable indian online pharmacy
Good information. Lucky me I discovered your blog by accident (stumbleupon). I have saved as a favorite for later!
Greetings from Florida! I’m bored to death at college so I decided to check out your website on my free time during lunch break. I love the info you provide here. I’m wowed at how fast your site loaded … Anyhow, fantastic blog!
Если вы искали где отремонтировать сломаную технику, обратите внимание – техпрофи
pharmacy website india: top 10 online pharmacy in india – Online medicine order
indian pharmacy paypal top 10 pharmacies in india indianpharmacy com
I’m pretty pleased to uncover this great site. I wanted to thank you for your time for this particularly fantastic read!! I definitely liked every part of it and I have you bookmarked to look at new stuff in your web site.
mexican online pharmacies prescription drugs: reputable mexican pharmacies online – mexican rx online
http://pharmbig24.com/# viagra dubai pharmacy
Your analysis is spot-on.오피
mexican drugstore online: п»їbest mexican online pharmacies – buying prescription drugs in mexico
herbals best ed pills donepezil online pharmacy
Spot on with this write-up, I honestly believe this amazing site needs a lot more attention. I’ll probably be returning to read more, thanks for the information!
Если вы искали где отремонтировать сломаную технику, обратите внимание – техпрофи
Normally I do not learn article on blogs, however I wish to say that this write-up very compelled me to try and do so! Your writing taste has been surprised me. Thank you, quite nice post.
http://indianpharmacy.company/# mail order pharmacy india
In December 2018, the Australian Prudential Regulation Authority (APRA) moved to disqualify five high IOOF executives accusing them of breaching the Superannuation Business Supervision (SIS) Act and failing to fulfill prudential requirements.
Organisers subsequently run an alternative occasion referred to as Big Weekend UK 2020, with acts showing on certainly one of 5 virtual levels and performed from their homes; the occasion also features previous performances from earlier Massive Weekend events.
Hayes, Dade; Chmielewski, Dawn (June 20, 2018).
Tunnel boring machines 2 April 2008: “This acquisition is Caterpillar’s entry into the rapidly increasing tunnel boring machine enterprise, and it represents a superb strategic match for our firms and the purchasers we serve around the globe,” – Stu Levenick, Caterpillar group president.
mexico pharmacies prescription drugs purple pharmacy mexico price list mexican drugstore online
YouTube was an app that was launched with the release of the iPhone in iPhone OS 1 which allowed customers to find, search, and watch YouTube movies.
The European Medical health insurance Card (EHIC) is issued free of cost to anyone who is insured by or coated by a statutory social security scheme of the EEA nations or Switzerland and certain residents and residents of the United Kingdom.
Floor and underground mining tools Transaction closed with out issuing new fairness on July 8, 2011, in agency’s largest acquisition ever, valued at $8.8 billion.
Employee incentives are designed to highlight those individuals, to allow them to know they’re particular, and to inspire them to sustain the nice work.
Content h as be en generat ed with GSA Conte nt Gen erator DEMO!
Quinn, Kevin (November 8, 1983).
п»їlegitimate online pharmacies india: indian pharmacy paypal – indianpharmacy com
Your insights have given me a new perspective.오피
indian pharmacy paypal: best online pharmacy india – indian pharmacies safe
mexican rx online reputable mexican pharmacies online п»їbest mexican online pharmacies
https://indianpharmacy.company/# online shopping pharmacy india
I blog frequently and I really appreciate your information. This great article has truly peaked my interest. I’m going to book mark your website and keep checking for new details about once a week. I opted in for your Feed too.
Профессиональный сервисный центр по ремонту бытовой техники с выездом на дом.
Мы предлагаем: сервисные центры по ремонту техники в казани
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
Профессиональный сервисный центр по ремонту стиральных машин с выездом на дом по Москве.
Мы предлагаем: ремонт стиральных машин
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
med rx pharmacy: target pharmacy lexapro – pharmacy supply store near me
Hi my friend! I wish to say that this article is awesome, nice written and include almost all vital infos. I’d like to see more posts like this.
buy medicines online in india online pharmacy india top 10 pharmacies in india
india online pharmacy: cheapest online pharmacy india – п»їlegitimate online pharmacies india
Если вы искали где отремонтировать сломаную технику, обратите внимание – ремонт бытовой техники
https://indianpharmacy.company/# reputable indian pharmacies
mexico drug stores pharmacies: mexican drugstore online – medicine in mexico pharmacies
wellness rx pharmacy rx pharmacy services lexapro indian pharmacy
acyclovir cream online pharmacy: generic viagra online pharmacy reviews – thrifty drug store
Если вы искали где отремонтировать сломаную технику, обратите внимание – профи нижний новгород
safeway pharmacy online prescription refill: klonopin online pharmacy reviews – viagra pharmacy uk
Профессиональный сервисный центр по ремонту бытовой техники с выездом на дом.
Мы предлагаем: ремонт крупногабаритной техники в москве
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
https://indianpharmacy.company/# india pharmacy
buy prescription drugs from india indian pharmacy online online pharmacy india
Если вы искали где отремонтировать сломаную технику, обратите внимание – ремонт бытовой техники в красноярске