目录
要求
- 图的邻接表和邻接矩阵存储
- 建立下图的邻接表或邻接矩阵,并输出之;
- 思路:
- 通过遍历邻接矩阵,采用头插法即可构造邻接表。
- 图的各种遍历算法实现
- 以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();
}
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).
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.
Imitation jewellery is made up of of less useful supplies including base metals, glass, plastic, synthetic stones and so forth.
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.
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.
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.
Anakin’s children, Leia, and Luke Skywalker would turn into key members of the Rebel Alliance to restore the Galactic Republic.
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.
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.
He obtained into each school he applied to but turned them all down.
September 30, 2016: Tickets go on sale.
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.
To have a novel and attractive wedding decoration, you need to rent the best marriage ceremony decorator in Bangalore.
Bordentown Regional College District 2016 Report Card Narrative Archived December 1, 2017, on the Wayback Machine, New Jersey Division of Training.
Amoxil Pharm Store: Amoxil Pharm Store – Amoxil Pharm Store
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.
Alternatively in Punjab the brides wear ivory and pink bangles which might be often known as chooda.
The participant named first performs the white pieces.
You possibly can attend as many lessons as you want, on Perth CBD, online.
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.
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.
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.
Предлагаем услуги профессиональных инженеров офицальной мастерской.
Еслли вы искали ремонт телевизоров xiaomi адреса, можете посмотреть на сайте: ремонт телевизоров xiaomi цены
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
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.
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.
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?
Предлагаем услуги профессиональных инженеров офицальной мастерской.
Еслли вы искали ремонт телевизоров xiaomi цены, можете посмотреть на сайте: ремонт телевизоров xiaomi рядом
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
Aerial Tram Journey – watching the wealthy vegetation and ecosystem above the trees is one nice adventure for the entire family.
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.
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.
This article is wonderful. I discovered the information very useful and clear. Thanks for sharing such valuable information.
15 miles (24 km) to the east of Flagstaff is the city of Winona.
Funeral providers have been within the Church of Christ, Lexington, on Saturday, Oct.
http://semaglutidepharm.com/# Buy semaglutide pills
Marc Allen, Marsha Elaine, Lori Ellen, and Mary Ann Stoner.
The Monkey’s Bum first appeared in print five years later within the British Chess Journal.
This is amazing! Packed with helpful insights and very clear. Many thanks for providing this.
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.
Ivermectin Pharm: Ivermectin Pharm Store – Ivermectin Pharm Store
over the counter amoxicillin: amoxicillin for sale – AmoxilPharm
http://paxlovid.ink/# Paxlovid over the counter
Amoxil Pharm Store: AmoxilPharm – amoxicillin buy no prescription
http://paxlovid.ink/# Paxlovid.ink
I used to be able to find good info from your content.
rybelsus Rybelsus 7mg buy semaglutide online
Paxlovid.ink: paxlovid cost without insurance – Paxlovid.ink
https://amoxilpharm.store/# Amoxil Pharm Store
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!
buying from online mexican pharmacy: MexicanPharmEasy – mexico drug stores pharmacies
overcoming ed http://mexicanpharmeasy.com/# mexico pharmacies prescription drugs