目录
要求
- 图的邻接表和邻接矩阵存储
- 建立下图的邻接表或邻接矩阵,并输出之;
- 思路:
- 通过遍历邻接矩阵,采用头插法即可构造邻接表。
- 图的各种遍历算法实现
- 以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();
}
During a falling economy, these aspects can disrupt the continuity and stability of your firm’s supply chain.
Therefore, for beginners in the investment world need to know what a mutual fund is and how it works from the mutual fund itself.
The Associated General Contractors of America, a United States trade association, provides some information for their members on these bonds.
Although the U.S. federal government was in surplus at the end of the Clinton administration, the Republican Party-led Nassau County government faced possible insolvency by 2000.
Oh my goodness! Incredible article dude! Thanks, However I am encountering troubles with your RSS. I don’t know why I can’t join it. Is there anyone else having similar RSS issues? Anybody who knows the solution can you kindly respond? Thanx!!
This conte nt has been done by G SA Content Generator Demoversion.
Firms seek similar market infrastructure and trade support services across markets.
The next time I read a blog, Hopefully it won’t disappoint me just as much as this one. I mean, I know it was my choice to read, however I actually thought you’d have something interesting to talk about. All I hear is a bunch of crying about something that you could fix if you weren’t too busy searching for attention.
The full name of the Army’s robot project within FCS is quite a mouthful: Future Combat Systems (FCS), Brigade Combat Team (BCT), Unmanned Ground Vehicle (UGV), Integrated Product Team (IPT), or FCS (BCT) UGV IPT for short.
I was more than happy to uncover this page. I need to to thank you for your time just for this fantastic read!! I definitely loved every little bit of it and i also have you saved to fav to see new information in your web site.
Профессиональный сервисный центр по ремонту квадрокоптеров и радиоуправляемых дронов.
Мы предлагаем:ремонт камеры дрона
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
You’re so cool! I don’t think I have read a single thing like that before. So nice to discover another person with unique thoughts on this subject. Seriously.. thanks for starting this up. This site is one thing that’s needed on the internet, someone with a bit of originality.
Good information. Lucky me I ran across your blog by accident (stumbleupon). I’ve book marked it for later.
Spot on with this write-up, I really feel this website needs a lot more attention. I’ll probably be returning to see more, thanks for the info!
casino slot siteleri: slot kumar siteleri – oyun siteleri slot
http://slotsiteleri.bid/# yasal slot siteleri
Great info. Lucky me I recently found your website by accident (stumbleupon). I have saved it for later.
sweet bonanza slot demo: sweet bonanza hilesi – guncel sweet bonanza
Профессиональный сервисный центр по ремонту сотовых телефонов, смартфонов и мобильных устройств.
Мы предлагаем: ближайшая мастерская по ремонту телефонов
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
Good information. Lucky me I ran across your website by chance (stumbleupon). I have saved it for later.
Профессиональный сервисный центр по ремонту сотовых телефонов, смартфонов и мобильных устройств.
Мы предлагаем: ремонт смартфонов
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
They are deemed to be exotic instruments.
Online medicine home delivery: pharmacy website india – п»їlegitimate online pharmacies india
And how can you plan ahead to make the most out of your time on campus?
It’s hard to come by educated people in this particular topic, but you sound like you know what you’re talking about! Thanks
п»їlegitimate online pharmacies india: indian pharmacy paypal – Online medicine order
Thomas Griesser Kym: “Helvetia geht auf Chefsuche”, Toggenburger Tagblatt, 26 October 2022, p.
http://easyrxindia.com/# cheapest online pharmacy india
In a direct problem to the Western powers, Japan proclaimed the Amau doctrine, which said that Japan alone held accountability for sustaining order in East Asia.
It is always better to do your own research to select the stocks.
Asian Business & Management.
The penny stock market has little liquidity, so holders of shares in penny stock companies often find it difficult to cash out of positions.
Preferred share represents some degree of ownership in a company but usually doesn’t come with the same voting rights (this may vary depending on the company).
https://easyrxindia.shop/# indian pharmacy
Great information. Lucky me I found your website by chance (stumbleupon). I have saved it for later!
On 12 September 2001, KOSPI had its largest one-day percentage drop of 12.02 (64.97 points) just after 9/11.
By being aware of these memory factors, officers can avoid unintentional suggestive behavior during lineup administration.
As an example, if they expect a stock to rise 100 in 3 days, they set a stop-loss at some extent the value falls from third.
The more curved the price function of the bond is, the more inaccurate duration is as a measure of the interest rate sensitivity.
Can I simply say what a relief to uncover a person that genuinely understands what they are talking about on the web. You actually know how to bring an issue to light and make it important. More people ought to read this and understand this side of the story. It’s surprising you are not more popular since you certainly possess the gift.
cheapest pharmacy canada: canadian pharmacy checker – trustworthy canadian pharmacy
I really love your blog.. Pleasant colors & theme. Did you develop this website yourself? Please reply back as I’m planning to create my own site and would like to learn where you got this from or what the theme is named. Kudos.
mexican pharmaceuticals online: reputable mexican pharmacies online – mexico drug stores pharmacies
http://easyrxindia.com/# indian pharmacies safe
Hello! I just would like to give you a big thumbs up for the excellent info you have got right here on this post. I am returning to your web site for more soon.
Spot on with this write-up, I honestly believe this website needs far more attention. I’ll probably be returning to see more, thanks for the information!
https://easyrxcanada.online/# canadian 24 hour pharmacy
real canadian pharmacy: safe canadian pharmacy – canadian pharmacy world
It’s difficult to find knowledgeable people about this subject, however, you seem like you know what you’re talking about! Thanks
Howdy! This post couldn’t be written much better! Going through this article reminds me of my previous roommate! He continually kept preaching about this. I’ll send this article to him. Fairly certain he’ll have a very good read. I appreciate you for sharing!