目录
要求
- 图的邻接表和邻接矩阵存储
- 建立下图的邻接表或邻接矩阵,并输出之;
- 思路:
- 通过遍历邻接矩阵,采用头插法即可构造邻接表。
- 图的各种遍历算法实现
- 以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();
}
This is the right site for anybody who hopes to find out about this topic. You understand a whole lot its almost tough to argue with you (not that I personally would want to…HaHa). You certainly put a new spin on a topic that has been written about for many years. Excellent stuff, just great.
After I initially 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 4 emails with the exact same comment. There has to be an easy method you can remove me from that service? Many thanks.
ed pills canadian pharm buy ed pills online
indian pharmacy paypal: indian pharmacy – india pharmacy mail order
erectal disfunction https://mexicanpharmeasy.com/# mexican border pharmacies shipping to usa
india pharmacy: IndianPharmStar.com – best india pharmacy
or contact us to request a custom hue.Those famous silk ruffle panties from Pinterest1.velma cosplay sexy
top rated ed pills: canadian pharm – best drugs for ed
online shopping pharmacy india indian pharm star indianpharmacy com
ed causes and treatment https://indianpharmstar.com/# indianpharmacy com
Предлагаем услуги профессиональных инженеров офицальной мастерской.
Еслли вы искали сервисный центр asus сервис, можете посмотреть на сайте: сервисный центр asus цены
Наши мастера оперативно устранят неисправности вашего устройства в сервисе или с выездом на дом!
buying from online mexican pharmacy: mexican pharmacy – purple pharmacy mexico price list
mexican online pharmacies prescription drugs: Mexican Pharm – mexican mail order pharmacies
Sidious offered Skywalker an ultimatum to enter his service or die, and proceeded to make use of his Pressure-derived powers to torture and threaten to kill Skywalker when the latter refused to embrace the dark aspect of the Drive.
We are not only a team of wedding ceremony planners however makers of spectacular events.
Best Legal professionals in America acknowledges Hickey Legislation Firm in an unprecedented 3 areas of non-public Harm-Plaintiffs, Admiralty & Maritime, and Medical Malpractice-Plaintiffs.
The board’s nine seats are allocated based mostly on the inhabitants of the constituent municipalities, with three seats assigned to Bordentown City.
In 1928, the American Chatillon Company started development of a rayon plant in Rome; it was a joint enterprise effort with the Italian Chatillon Company.
Read on for a deep dive into what type of insurance coverage you must consider if you live in an unconventional house in Jennings, Louisiana.
mexico pharmacies prescription drugs MexicanPharmEasy buying from online mexican pharmacy
Applicants will need to have at least one yr of customer support expertise.
As the runner-up, Nepomniachtchi certified for the Candidates Tournament 2022, an eight-participant tournament to pick out the challenger for the 2023 World Chess Championship.
This page was final edited on 26 October 2024, at 11:31 (UTC).
City Clerk, City of Bordentown.
The ship’s Air Operations Department communicates with the ready room via the ASDO when reporting launch and touchdown occasions, and standard telephones are used for other communications.
Despite having launched the first two Spock’s Beard albums to good crucial acclaim, Morse found himself struggling economically.
For example, in New Orleans, brief-time period rentals are allowed in sure areas, whereas some places prohibit it altogether.
Because of digitization, elaborate income associated info management software program systems have been developed to cater to data analysis and facilitation.
This aquamarine ring is a perfect alternative for individuals who appreciate refined beauty and graceful fashion.
Booking Engine: A consumer-pleasant booking engine on the lodge’s webpage is important for direct reservations.
Nevertheless, not like the everyday FPS, Deus Ex would not drive you to shoot each digital factor that strikes.
Name us immediately. Schedule a free, no obligation session with a Miami, Florida personal harm lawyer immediately.
Future improvement of this campus is designed to ascertain it as a heart of innovation, centered on leading analysis in areas comparable to well being science, cybersecurity and various energy.
cure ed http://mexicanpharmeasy.com/# mexican border pharmacies shipping to usa
Interment in the Rea Ridge, AR City Cemetery with Worley Funeral Home in cost.
The sanctions apply solely to the world championship match, to not different FIDE events such because the Candidates Tournament.
So we have got ideas on the market we all know can work.
The executive board gave throughout its congress in fall 2009 in Halkidiki an choice to London, United Kingdom to organise the World Chess Championship for 2012.
We have now made ourselves a part of an unnecessary race that is rarely going to finish, a race to be first in the whole lot.
The DJ of new World University, Anthony is antagonistic towards Victoria and Christopher Rice, resentful of having to transmit propaganda; after he attempts to broadcast the reality, he is consumed by the good Intelligence.
R.Q. Needham both of De Queen, Mrs.
Kuzma, Cindy (August 26, 2019).
Chapel Hill, North Carolina: College of North Carolina Press.
To recap: Know what your gameplay objectives are and what kind of experience you need gamers to have earlier than you spend ten seconds interested by something particular.
Bespoke diamond rings are a timeless expression of love, uniquely crafted to symbolize your particular bond.
Both the planet and the Time Lords will be restored, together with the Doctor’s reminiscence, if a sufficiently sophisticated computer could be found to reconstruct them.
You’ll become profitable on-line in Nigeria simply by looking the internet.
Shortly after his victory, Carlsen talked about that he might not be motivated enough to play one other world championship match until the challenger was Alireza Firouzja, an 18-12 months-previous prodigy who had risen to quantity two on the earth rankings.
Krosnick, Brian (September 25, 2014).
1957 U.S. Open on tiebreaks, successful the 1957-58 U.S.