目录
要求
- 图的邻接表和邻接矩阵存储
- 建立下图的邻接表或邻接矩阵,并输出之;
![](https://blog.coolight.cool/wp-content/uploads/2022/01/Snipaste_2022-01-06_10-31-59.png)
- 思路:
- 通过遍历邻接矩阵,采用头插法即可构造邻接表。
- 图的各种遍历算法实现
- 以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();
}
mexican online pharmacies prescription drugs: mexico drug stores pharmacies – pharmacies in mexico that ship to usa
buying from online mexican pharmacy mexican online pharmacies prescription drugs pharmacies in mexico that ship to usa
mexican border pharmacies shipping to usa: mexican pharmaceuticals online – buying prescription drugs in mexico online
mexican rx online: best online pharmacies in mexico – reputable mexican pharmacies online
mexican pharmaceuticals online: mexican online pharmacies prescription drugs – mexican mail order pharmacies
best online pharmacies in mexico medicine in mexico pharmacies buying from online mexican pharmacy
buying prescription drugs in mexico: purple pharmacy mexico price list – mexican rx online
reputable mexican pharmacies online: mexican border pharmacies shipping to usa – pharmacies in mexico that ship to usa
mexican pharmaceuticals online: medicine in mexico pharmacies – best online pharmacies in mexico
medication from mexico pharmacy medicine in mexico pharmacies mexican mail order pharmacies
Can I simply say what a comfort to uncover someone who truly understands what they are talking about on the internet. You definitely know how to bring an issue to light and make it important. More and more people ought to read this and understand this side of the story. It’s surprising you are not more popular because you definitely possess the gift.
mexican border pharmacies shipping to usa: mexico pharmacies prescription drugs – mexican drugstore online
purple pharmacy mexico price list: mexico pharmacies prescription drugs – mexican border pharmacies shipping to usa
Howdy! I could have sworn I’ve visited this blog before but after looking at many of the articles I realized it’s new to me. Regardless, I’m certainly pleased I found it and I’ll be bookmarking it and checking back often!
mexican pharmaceuticals online: buying prescription drugs in mexico online – mexican rx online
mexican pharmacy mexico drug stores pharmacies medication from mexico pharmacy
Wonderful article! We are linking to this particularly great content on our site. Keep up the good writing.
This site was… how do you say it? Relevant!! Finally I have found something that helped me. Thanks a lot.
Way cool! Some extremely valid points! I appreciate you penning this write-up plus the rest of the site is very good.
pharmacies in mexico that ship to usa: mexican pharmaceuticals online – medication from mexico pharmacy
medicine in mexico pharmacies mexican drugstore online mexico drug stores pharmacies
mexico drug stores pharmacies: mexican drugstore online – mexican mail order pharmacies
mexico pharmacies prescription drugs: mexican border pharmacies shipping to usa – pharmacies in mexico that ship to usa
Hi” best wishes to you and your very nice blog”
https://mexicandeliverypharma.online/# mexico drug stores pharmacies
п»їbest mexican online pharmacies: mexican online pharmacies prescription drugs – buying prescription drugs in mexico online
mexican mail order pharmacies mexico pharmacies prescription drugs pharmacies in mexico that ship to usa
mexican mail order pharmacies: buying prescription drugs in mexico online – п»їbest mexican online pharmacies
medication from mexico pharmacy: mexican mail order pharmacies – mexican mail order pharmacies
purple pharmacy mexico price list medication from mexico pharmacy reputable mexican pharmacies online
https://mexicandeliverypharma.online/# buying prescription drugs in mexico online
mexico drug stores pharmacies: medicine in mexico pharmacies – mexican border pharmacies shipping to usa
mexican border pharmacies shipping to usa: mexico pharmacies prescription drugs – best online pharmacies in mexico
buying from online mexican pharmacy medicine in mexico pharmacies medicine in mexico pharmacies
best online pharmacies in mexico: reputable mexican pharmacies online – buying prescription drugs in mexico
mexico pharmacies prescription drugs: best online pharmacies in mexico – mexico drug stores pharmacies
https://mexicandeliverypharma.com/# mexican border pharmacies shipping to usa
mexican pharmacy best online pharmacies in mexico medication from mexico pharmacy
Thus profit is made by selling one currency into another market.
With the advent of computers, backtesting can be performed on entire exchanges over decades of historic data in very short amounts of time.
Mountain U.S. 421 Scenic Byway Follows US 221 and US 421 from the Blue Ridge Parkway, in Deep Hole, to the South Fork New River, near Boone.
You have made some good points there. I checked on the net to learn more about the issue and found most people will go along with your views on this website.
When I originally commented I appear to have clicked on the -Notify me when new comments are added- checkbox and now each time a comment is added I get four emails with the exact same comment. There has to be a means you can remove me from that service? Appreciate it.
I love reading through a post that will make people think. Also, thank you for allowing for me to comment.
Great information. Lucky me I came across your site by accident (stumbleupon). I have book marked it for later!
This web site truly has all the information and facts I needed concerning this subject and didn’t know who to ask.
You have made some good points there. I checked on the internet for more information about the issue and found most people will go along with your views on this web site.
Everything is very open with a precise description of the challenges. It was truly informative. Your website is useful. Many thanks for sharing!
This is the right webpage for anybody who hopes to understand this topic. You realize so much its almost hard to argue with you (not that I actually will need to…HaHa). You definitely put a fresh spin on a topic that’s been written about for many years. Great stuff, just great.
Pretty! This has been an extremely wonderful post. Thank you for supplying this information.