目录
要求
- 图的邻接表和邻接矩阵存储
- 建立下图的邻接表或邻接矩阵,并输出之;
- 思路:
- 通过遍历邻接矩阵,采用头插法即可构造邻接表。
- 图的各种遍历算法实现
- 以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();
}
Откройте дверь к улучшенной версии себя –
перейдите по линку на :~:text=%D0%A1%D0%B5%D1%80%D0%B3%D0%B5%D0%B9%20%D0%9A%D0%BE%D1%80%D0%BE%D1%82%D0%BA%D0%BE%D0%B2.%20%D0%9E%D0%BF%D1%81%D1%83%D0%B8%D0%BC%D0%BE%D0%BB%D0%BE%D0%B3%20%D0%BE%D0%BD%D0%BB%D0%B0%D0%B9%D0%BD
You’ve made some decent points there. I checked on the net to learn more about the issue and found most
individuals will go along with your views on this site.
medication from mexico pharmacy: mexican pharmacy northern doctors – buying from online mexican pharmacy
It has taken me forever to find your blog. Thank goodness. This is just the information I was after.
An impressive share, I recently given this onto a colleague who has been conducting a small analysis on this. And that he in truth bought me breakfast since I stumbled upon it for him.. smile. So well then, i’ll reword that: Thnx for your treat! But yeah Thnkx for spending the time to discuss this, I am strongly over it and love reading regarding this topic. If you can, as you grow expertise, would you mind updating your site with increased details? It can be extremely useful for me. Huge thumb up in this writing!
https://northern-doctors.org/# mexican online pharmacies prescription drugs
mexico pharmacies prescription drugs: reputable mexican pharmacies online – mexican rx online
puppies and dogs are very cute, i always love to play with them during my spare time.
buying from online mexican pharmacy: mexican pharmacy – pharmacies in mexico that ship to usa
http://northern-doctors.org/# mexican rx online
Yay google is my king helped me to find this great web site ! .
mexican rx online: northern doctors – buying prescription drugs in mexico online
You ought to actually think about engaged on creating this blog into a significant authority on this market. You evidently have a grasp handle of the topics everyone seems to be trying to find on this website in any case and you could actually even earn a buck or two off of some advertisements. Id discover following latest subjects and raising the quantity of write ups you place up and I guarantee you’d begin seeing some amazing targeted traffic within the close to future. Only a thought, good luck in no matter you do!
purple pharmacy mexico price list northern doctors buying prescription drugs in mexico
mexican online pharmacies prescription drugs: Mexico pharmacy that ship to usa – п»їbest mexican online pharmacies
https://northern-doctors.org/# mexican online pharmacies prescription drugs
mexican border pharmacies shipping to usa: mexican pharmacy northern doctors – reputable mexican pharmacies online
https://northern-doctors.org/# mexico pharmacy
purple pharmacy mexico price list: mexican northern doctors – buying from online mexican pharmacy
mexican online pharmacies prescription drugs: Mexico pharmacy that ship to usa – mexico drug stores pharmacies
https://northern-doctors.org/# reputable mexican pharmacies online
buying prescription drugs in mexico: mexican pharmacy northern doctors – mexican border pharmacies shipping to usa
https://northern-doctors.org/# п»їbest mexican online pharmacies
mexican online pharmacies prescription drugs medicine in mexico pharmacies best online pharmacies in mexico
medication from mexico pharmacy: mexican northern doctors – mexico drug stores pharmacies
Hello there, have you ever in your life thought about to publish regarding Nintendo or PSP?
Simply no Baloney and also well crafted, I appreciate for the post
It is a really amazing powerful resource that you’re offering and you just provide it away cost-free!! I really like discovering websites of which are aware of the particular property value providing you with beautiful learning resource for zero cost. We truly dearly loved examining this page. Be thankful!
The great things about News became valuable to most of people.
Very informative blog. I especially appreciate content that has to do with beauty and fitness, so it’s of particular interest to me to see what you have here. Keep it up! facial exercises
A powerful share, I simply given this onto a colleague who was doing a bit of analysis on this. And he the truth is purchased me breakfast as a result of I found it for him.. smile. So let me reword that: Thnx for the treat! However yeah Thnkx for spending the time to debate this, I really feel strongly about it and love reading more on this topic. If potential, as you change into expertise, would you mind updating your weblog with more particulars? It’s extremely useful for me. Big thumb up for this weblog post!
best online pharmacies canada
http://northern-doctors.org/# mexican pharmaceuticals online
The next occasion Someone said a blog, Lets hope it doesnt disappoint me as much as this place. I am talking about, I know it was my method to read, but I actually thought youd have some thing fascinating to say. All I hear is actually a few whining about something that you could fix if you werent too busy interested in attention.
A polite letter is important addressed to the magazine’s Fiction Editor, introducing yourself and attaching your story, with double spaced text and having big margins on both sides. This really for ease of use by the magazine staff and is essential. Pages ought to each be numbered.
I should examine with you here. Which is not something I often do! I get pleasure from reading a publish that can make folks think. Also, thanks for permitting me to remark!
business management can make or break the success of a company that is why it is very very critical~
purple pharmacy mexico price list mexican pharmacy northern doctors mexican border pharmacies shipping to usa
mexican border pharmacies shipping to usa: mexican pharmacy online – mexican border pharmacies shipping to usa
After i open up your own Feed it offers myself with many different garbled text message, could be the concern on my small conclusion?
I was suggested this website by my cousin. I am now not sure whether this put up is written by way of him as no one else understand such distinct approximately my problem. You’re incredible! Thanks!
https://northern-doctors.org/# mexican drugstore online
Deference to author , some fantastic information .
I’m writing to make you know of the fabulous encounter my wife’s child undergone going through the blog. She realized a good number of things, not to mention what it’s like to have an excellent giving spirit to make certain people just learn certain extremely tough subject areas. You undoubtedly surpassed readers’ desires. Many thanks for presenting the useful, trustworthy, revealing and as well as easy tips about this topic to Sandra.
reputable mexican pharmacies online: mexican northern doctors – mexico drug stores pharmacies
Can I recently say such a relief to get someone that really knows what theyre referring to on the net. You certainly have learned to bring a problem to light and earn it critical. More and more people should check out this and see why side from the story. I cant think youre no more well-known as you certainly develop the gift.
Thanks for the article! Just browsing around online I get into some cool stuff. Anyways, back to school work…
I simply needed to thank you very much all over again. I’m not certain the things I might have made to happen without the creative concepts shown by you over my topic. It has been a very scary case in my opinion, however , noticing this specialised strategy you treated the issue forced me to jump for joy. Now i’m grateful for this information and even expect you find out what a powerful job you were putting in educating others with the aid of your web blog. I am sure you haven’t encountered any of us.
Come find the best workout supplements at the cheapest prices online. Get ready for those muscle and strength gains you have been looking for.
mexico drug stores pharmacies: Mexico pharmacy that ship to usa – mexican mail order pharmacies