算法导论 第23章 最小生成树

这篇博客介绍了最小生成树问题,详细讲解了Kruskal算法和Prim算法。在Kruskal算法中,添加的安全边是连接不同组件的最小权重边。Prim算法中,安全边连接树与不在树中的顶点。文章还提到了使用斐波那契堆实现Prim算法的挑战,以及在程序实现中遇到的问题,如顶点与斐波那契堆节点的对应关系。同时,列出了23.1Growing a minimum spanning tree的相关练习题。
摘要由CSDN通过智能技术生成

一、综述

1.minimum-spanning-tree problem

2.Kruskal's algorithm

In Kruskal's algorithm, the set A is a forest. The safe edge added to A is always a least-weight edge in the graph that connects two distinct components.

3.Prim's algorithm

In Prim's algorithm, the set A forms a single tree. The safe edge added to A is always a least-weight edge connecting the tree to a vertex not in the tree.

二、程序

1.Kruskal算法

#include <iostream>
#include <algorithm>
#include "UnionFindSet.h"
using namespace std;

#define N 14
#define M 9
//边
struct Edge
{
	int start;
评论 2
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值