目录
要求
- 图的邻接表和邻接矩阵存储
- 建立下图的邻接表或邻接矩阵,并输出之;
- 思路:
- 通过遍历邻接矩阵,采用头插法即可构造邻接表。
- 图的各种遍历算法实现
- 以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();
}
https://northern-doctors.org/# п»їbest mexican online pharmacies
well of course, everyone loves to get rich but not everyone would love to do hard work“
I have to agree with the blogger above. You need to get rid of this spam!
purple pharmacy mexico price list: mexican pharmaceuticals online – mexican online pharmacies prescription drugs
hi there and thank you for your info – I have certainly picked up something new from right here. I did however expertise a few technical points using this site, since I experienced to reload the website lots of times previous to I could get it to load properly. I had been wondering if your web hosting is OK? Not that I’m complaining, but sluggish loading instances times will often affect your placement in google and could damage your quality score if advertising and marketing with Adwords. Anyway I’m adding this RSS to my e-mail and could look out for much more of your respective intriguing content. Ensure that you update this again soon..
Good aftie” i am a blogger too” and i can see that you are a nice blogger too.
http://northern-doctors.org/# pharmacies in mexico that ship to usa
This web page is known as a stroll-by for all the information you wished about this and didn’t know who to ask. Glimpse right here, and you’ll positively discover it.
Aw, this was a really nice post. In thought I would like to put in writing like this additionally ?taking time and precise effort to make an excellent article?but what can I say?I procrastinate alot and not at all appear to get something done.
buying from online mexican pharmacy: mexican northern doctors – mexico pharmacies prescription drugs
medication from mexico pharmacy mexican pharmacy pharmacies in mexico that ship to usa
mexican rx online: northern doctors – best online pharmacies in mexico
http://northern-doctors.org/# purple pharmacy mexico price list
mexican mail order pharmacies: mexican pharmacy – mexican border pharmacies shipping to usa
https://northern-doctors.org/# mexican pharmaceuticals online
best online pharmacies in mexico: best online pharmacies in mexico – buying from online mexican pharmacy
you could have an ideal blog right here! would you prefer to make some invite posts on my weblog?
I like the efforts you have put in this, regards for all the great articles .
mexican online pharmacies prescription drugs: northern doctors – mexican border pharmacies shipping to usa
Fortunate we discovered this excellent website, One other good website is Dbol will be certain to save this in order to check-out regularly.
Pretty section of content. I just stumbled upon your website and in accession capital to assert that I get actually enjoyed account your blog posts. Anyway I will be subscribing to your feeds and even I achievement you access consistently quickly.
http://northern-doctors.org/# best online pharmacies in mexico
mexican pharmaceuticals online mexican pharmacy northern doctors medication from mexico pharmacy
After study several of the blog articles on your own site now, and I genuinely as if your technique of blogging. I bookmarked it to my bookmark website list and are checking back soon. Pls check out my site also and inform me what you think.
when i was younger, i always love the tune of alternative music compared to pop music;
п»їbest mexican online pharmacies: mexican northern doctors – mexican online pharmacies prescription drugs
very nice post, i surely enjoy this internet web page, carry on it
Good Post, I am a big believer in placing comments on weblogs to let the blog writers know that they’ve added something advantageous to the world wide web!
Heya i would really love to subscribe and read your blog posts .!
I request more people would write sites like this that are as a matter of fact constructive to read. With all the fluff floating almost on the web, it is rare to look over a position like yours instead.
http://northern-doctors.org/# п»їbest mexican online pharmacies
buying prescription drugs in mexico: mexican pharmacy online – pharmacies in mexico that ship to usa
Have you already setup a fan page on Facebook ?;-~:,
You made some nice points there. I did a hunt on the theme and found mainly persons will accept as true with your blog.
Companion, this web site will be fabolous, i merely like it
I am constantly browsing online for content articles that can benefit me personally. Thanks!
http://northern-doctors.org/# mexican mail order pharmacies
Throughout the awesome scheme of things you secure a B+ with regard to hard work. Where exactly you lost everybody was in your facts. As as the maxim goes, the devil is in the details… And it couldn’t be much more correct in this article. Having said that, let me say to you just what did work. The authoring is certainly quite persuasive and this is probably the reason why I am taking the effort to comment. I do not make it a regular habit of doing that. Next, even though I can easily see a leaps in reasoning you come up with, I am not really certain of exactly how you seem to unite your points which inturn produce the actual conclusion. For the moment I will, no doubt yield to your point but wish in the future you actually link the dots much better.
buying prescription drugs in mexico online: mexican pharmacy – pharmacies in mexico that ship to usa
seafoods are great because they are really tasty, i think that almost all seafoods are super duper tasty,,
You’re making a lot of great points during this blog post however it is very hard in my opinion to concentrate on this article on the complicated page design.
buying from online mexican pharmacy northern doctors mexican mail order pharmacies
You ought to take part in a contest for one of the greatest blogs on the web. I am going to recommend this website!
Undeniably believe that which you stated. Your favorite justification seemed to be on the net the simplest thing to be aware of. I say to you, I certainly get irked while people think about worries that they plainly don’t know about. You managed to hit the nail upon the top as well as defined out the whole thing without having side-effects , people could take a signal. Will probably be back to get more. Thanks
bike racks could really help you secure your bike when you leave it –
You got a very wonderful website, Sword lily I found it through yahoo.
Hey. Cool article. There’s a problem with your site in chrome, and you may want to check this… The browser is the market leader and a huge component of other people will omit your wonderful writing because of this problem.
Thanks for the information, I rarely find what I’m looking for… finally an exception!
Активируйте дверь к улучшенной версии себя – перейдите
по ссылке на психология научные статьи
Hi there just wanted to give you a brief heads up and let you know a few
of the images aren’t loading correctly. I’m not sure why
but I think its a linking issue. I’ve tried it in two different web browsers and both show the same outcome.