目录
要求
- 图的邻接表和邻接矩阵存储
- 建立下图的邻接表或邻接矩阵,并输出之;
- 思路:
- 通过遍历邻接矩阵,采用头插法即可构造邻接表。
- 图的各种遍历算法实现
- 以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();
}
Way cool! Some extremely valid points! I appreciate you writing this write-up and the rest of the site is also really good.
https://viagragenerico.site/# viagra pfizer 25mg prezzo
acquisto farmaci con ricetta: Avanafil compresse – farmacia online senza ricetta
Farmacia online miglior prezzo: Farmacie online sicure – top farmacia online
Everything is very open with a very clear clarification of the issues. It was definitely informative. Your site is useful. Thanks for sharing.
Farmacie on line spedizione gratuita: Farmacia online migliore – farmaci senza ricetta elenco
https://farmait.store/# farmacia online piГ№ conveniente
I was extremely pleased to discover this site. I wanted to thank you for your time for this particularly fantastic read!! I definitely savored every bit of it and i also have you book marked to look at new stuff on your website.
comprare farmaci online con ricetta: avanafil 100 mg prezzo – farmacia online senza ricetta
I couldn’t resist commenting. Well written.
farmacia online piГ№ conveniente: Cialis generico 5 mg prezzo – farmacie online affidabili
viagra prezzo farmacia 2023: viagra prezzo – viagra 50 mg prezzo in farmacia
I have to thank you for the efforts you have put in penning this blog. I’m hoping to view the same high-grade content from you later on as well. In fact, your creative writing abilities has inspired me to get my very own blog now 😉
Saved as a favorite, I like your site!
Can I just say what a relief to find somebody that genuinely knows what they’re talking about on the net. You certainly know how to bring a problem to light and make it important. More people need to read this and understand this side of your story. I can’t believe you’re not more popular because you most certainly have the gift.
This is a good tip particularly to those fresh to the blogosphere. Brief but very accurate information… Thank you for sharing this one. A must read post!
tamoxifen bone pain: tamoxifen and weight loss – tamoxifen estrogen
https://zithromaxbestprice.pro/# zithromax 250mg
You’ve made some decent points there. I checked on the web for more info about the issue and found most people will go along with your views on this site.
prednisone 10mg price in india: prednisone pack – where to get prednisone
This is a topic which is near to my heart… Best wishes! Where are your contact details though?
get propecia no prescription: buying generic propecia without prescription – cost of generic propecia for sale
Your style is so unique in comparison to other folks I have read stuff from. Many thanks for posting when you have the opportunity, Guess I’ll just bookmark this page.
An impressive share! I have just forwarded this onto a friend who has been doing a little homework on this. And he in fact bought me lunch because I discovered it for him… lol. So let me reword this…. Thanks for the meal!! But yeah, thanx for spending time to discuss this matter here on your blog.
https://prednisonebestprice.pro/# buy prednisone canada
nolvadex pills: does tamoxifen cause joint pain – nolvadex 10mg
You are so interesting! I don’t think I’ve read through a single thing like that before. So wonderful to discover someone with a few original thoughts on this subject. Really.. thanks for starting this up. This website is one thing that is needed on the web, someone with a bit of originality.
Your style is very unique compared to other people I’ve read stuff from. Thanks for posting when you have the opportunity, Guess I will just book mark this page.
It’s nearly impossible to find experienced people about this topic, however, you seem like you know what you’re talking about! Thanks
buy cheap zithromax online: can i buy zithromax over the counter – zithromax online usa no prescription
This is the perfect webpage for everyone who hopes to understand this topic. You understand so much its almost tough to argue with you (not that I actually will need to…HaHa). You definitely put a brand new spin on a topic that has been written about for many years. Wonderful stuff, just wonderful.
Very good info. Lucky me I found your website by accident (stumbleupon). I have book-marked it for later!
liquid tamoxifen: hysterectomy after breast cancer tamoxifen – tamoxifen side effects forum
Link pyramid, tier 1, tier 2, tier 3
Top – 500 hyperlinks with placement embedded in articles on content domains
Secondary – 3000 URL +Redirect hyperlinks
Tier 3 – 20000 connections mix, posts, entries
Using a link hierarchy is helpful for indexing systems.
Need:
One link to the site.
Key Phrases.
True when 1 query term from the page topic.
Observe the additional feature!
Vital! Top connections do not intersect with Secondary and Tier 3-rank hyperlinks
A link structure is a instrument for increasing the flow and backlink portfolio of a website or social media platform
ordering prednisone: prednisone brand name in usa – prednisone
buy cytotec pills online cheap Misoprostol 200 mg buy online buy cytotec online fast delivery
Greetings! Very helpful advice in this particular post! It is the little changes that produce the greatest changes. Many thanks for sharing!
cost generic propecia for sale: cost generic propecia tablets – order cheap propecia tablets
prednisone 10mg prices prednisone 5 mg tablet price prednisone 4mg tab
Reviewing and assessing risk management policies and procedures.
https://cytotecbestprice.pro/# order cytotec online
http://zithromaxbestprice.pro/# zithromax 1000 mg pills
tamoxifen and antidepressants: where to buy nolvadex – does tamoxifen cause joint pain
prednisone 10 mg coupon prednisone uk prednisone 20mg online without prescription
An outstanding share! I’ve just forwarded this onto a co-worker who has been doing a little homework on this. And he in fact bought me breakfast simply because I found it for him… lol. So allow me to reword this…. Thanks for the meal!! But yeah, thanx for spending some time to talk about this matter here on your web page.
Hi there! This blog post could not be written much better! Reading through this article reminds me of my previous roommate! He constantly kept preaching about this. I most certainly will forward this article to him. Pretty sure he will have a very good read. I appreciate you for sharing!
Others disagree and those with this viewpoint possess myriad methods and technologies which purportedly allow them to gain future price information.
http://nolvadexbestprice.pro/# nolvadex steroids
http://propeciabestprice.pro/# buy generic propecia
purchase cytotec: buy cytotec over the counter – Cytotec 200mcg price