[
next
] [
prev
] [
prev-tail
] [
tail
] [
up
]
1.10.3
spanning tree
BFS and DFS will produce spanning tree.
The minimum spanning tree can be obtained in polynomial time:
Kruskal’s algorithm
Prim’s algorithm
Sollin’s algorithm
Kruskal algorithm:
KRUSKAL
(
G
):
A
=
empty
foreach
v
in
G
.
V
:
MAKE
-
SET
(
v
)
foreach
(
u
,
v
)
ordered
by
weight
(
u
,
v
),
increasing
:
if
FIND
-
SET
(
u
)
âĽă
FIND
-
SET
(
v
):
A
=
A
{(
u
,
v
)}
UNION
(
u
,
v
)
return
A
[
next
] [
prev
] [
prev-tail
] [
front
] [
up
]