A Prins's algorithm repeatedly adds the minimum one endpoint in T - - PDF document

a prins s algorithm
SMART_READER_LITE
LIVE PREVIEW

A Prins's algorithm repeatedly adds the minimum one endpoint in T - - PDF document

Minimum Spanning Trees Kent by Quanrud f EE Kkk G EYE Undirected graph Input f mn Ff IR E edge weights w A spanning tree G is tree in a containing all of V leg n t edges compute the Goal minimum weight abbr MST spanning tree


slide-1
SLIDE 1

Minimum Spanning Trees

by

Kent

Quanrud

f EE Kkk

slide-2
SLIDE 2

Input

Undirected graph

G EYE

fmn Ff

edge

weights

w

E

IR

A

spanning tree

is

a

tree

in

G

containing all of V

leg

n t edges

Goal compute the

minimum

weight

spanning tree

abbr MST in

G

weight of tree

sum of

edge weights

w

T

ee

wCe

if t.EE z

slide-3
SLIDE 3

Applications

Network design

Approximations

for harder

problems

like Traveling salesman

deep

connections

across

theory

comb OPT

THA

a

r

n

I

EE

EE

4 3

tl rE

f

E rEi

GOAL

Connect

town

w

minimum

am

  • ut
  • f

electrical

wire

slide-4
SLIDE 4

Preliminary

  • bs

min ST

WAH

w

max

ST

WHA

w

we

can

assume

CWLOG

that

all edgeweights

are distinct

by

breaking ties

consistently

e g

number

edges

es

ez

i

em

ei

weighs

less than

ej

is

nice since

  • r

nice

_Wcg

and

isj

slide-5
SLIDE 5

Outline

1

Describe

4

different algorithms

2

Prove

all of

their

correctness at

the

same

time

3

Discuss

data

structures

and pin down

the

running

time

Running example

A

slide-6
SLIDE 6

Prins's algorithm

repeatedly adds

the

minimum

weight edge

w

  • ne endpoint

in

T

PRIM

G

YE

W

E 7113

1

I

S

s

for

some vertex

SEV

2

while

St V

a e

min weight edge crossings

6

TL Tte

S

SU e3

see

e

Eu is

3

return

T

a

e

u u

UES

VES

S

Stv

11 Key

invariant

T

is

a

tree connecting S

ia

slide-7
SLIDE 7

i

slide-8
SLIDE 8

Kruskal's algorithm

repeatedly adds the

minimum weight

edge that

does not

create

a cycle

KRUSKAL

G YE

w

1

1

2

while T does not span all of

a e

min weight edge

in

F IT

set

Tte

is acyclic

6 T

Tt

e

3

return

T

Akey invariant

T

is

a

forest

gag

l

I

l

p

1

I

y

i

i

a

slide-9
SLIDE 9

xnxx.tn

i

in

IT

slide-10
SLIDE 10

Borivka

grow all connected components

w

min weight crossing edge

in parallel

Borivka

1

1

  • f

2

while T

is

not spanning A

U

B

for each component

SCV

Wlr H

T

i

e

min

weight edge

w

1

endpoint in S

A

IIIa

te

3

return

T

17

T

titties

r

e og

g

  • _0

to

slide-11
SLIDE 11

simulation

iii

slide-12
SLIDE 12

reverse

delete

repeatedly

removes max

weight

edge that

does

not

disconnect

graph

REVERSE GREEDY

G

YE

w

1

T E

2

while

E FO

A

e

max weight edge in

E

B

E

E

e

C

if

T

e

is

connected

i

1

T

e

3

return

T H key invariant

T

is

a connected

subgraph spanning

V

slide-13
SLIDE 13

z

E

Ex IIT

On

to

proofs

slide-14
SLIDE 14

4

E

  • V

T

y

Lemme

let

T

be aspanning Tree

ee

ETI Then

Tte

contains

a

unique cycle

which

contains

e

Proof

let

e

u r

since

T

is

a

spanning

there

is

a

unique path P

from

U

to

V

in

T

Pte

is

  • ur

cycle

Suppose

there

is

another

cykle

DE

Ite

id

e ED

D

e

is

a

path

in

T

P

is

the unique path

D

Pte

slide-15
SLIDE 15

Safeedges

An edge e is safe

if

there

is

a

set

  • f vertices

5 such that

e

is

the

min

weight edge

w

  • ne endpoint

in

S

s

p

Leming Any safe edge

e

is

in every

MST

Proof

let

e

be

a

safe edge whet Gay S

Let

T

be

an

MST

s.T.EE

T

in CTD

ICT

w

twee

w

T

slide-16
SLIDE 16

let

C

be the

unique

cycle

in

Tte

C

e

is

apath

starting

in

5

ending

Vhs

slide-17
SLIDE 17

Lemmas

Supposeedge weights

are

distinct Then

Primlkruskall Borurka

compute

spanning

trees

where

every edge

is safe

Proof

add

min weight

inspection

Cross

s

slide-18
SLIDE 18

theorem

suppose edge weights

are

distinct

There

are

exactly

n

l

safe edges and

they

form

the

unique

MST

Proof

first

Lemma

safe E

MST

E

n

I

safe

edges

safe Eh Z

Kruskal

Pri m's

zn i

safe

edges

slide-19
SLIDE 19

Corollary

Prim's

Kruskal's

Borivka's

algos

all

return

MST's

Proof

I

slide-20
SLIDE 20

Unsafeedgese

an edge

e

is

unsafe

if

there

is

a

cycle C

where

e

is

the

uniquely

maximum

weight edge

100

3

49

14

7

slide-21
SLIDE 21

Femina

suppose distinct edgeweights

All

edges

are

either safe

  • r

unsafe

Proot

suppose

e

is

not

safe

let

T

be the

MST

EET

let

C

be the

cycle

in

Tte

f

a 9eI

e

then

T

Ste

has smaller

weight

suppose

e

is safe

and

C

is

a cycle

containing

e

week wcf

slide-22
SLIDE 22

Lemmy

Let

T be

a connected subgraph

and EET the

max

weight edgett

Then

e

is

an

unsafe edge

T

e

is

still connected

Proof

since

T

e

is

connected

T

contains

a cycle

C containing

e

k

them

weight

  • n cycle

unsafe

corollary

Reverse greedy

works

slide-23
SLIDE 23

Implementation

Borivka

OCmlogn Kruskal

OCmloyn

Prim

Ocmtrilogn

slide-24
SLIDE 24

Borivka

grow all connected components

w

min weight crossing edge

in parallel

Boruovka

1

1

  • f

2

while T

is

not spanning A

U

  • f

B

for each component

SCV

wlrH

T

i

e

min

weight edge

w

1

endpoint in S

ii

create

C T

TO U

3

return

T

slide-25
SLIDE 25

Boruorkarunning

ime

l

Hadds edges crossing each component

in parallel

Each round halves connected

comp

Oclogn

rounds

Each

round

we

look

at each edge

pick out

  • ne edge per

component

0cm

per

round

0cm login

total

slide-26
SLIDE 26

Kruskal's algorithm

repeatedly adds the

minimum weight

edge that

does not

create

a cycle

KRUSKAL

G YE

w

1

1

2

while T does not span all of

a e

min weight edge

in

E T

st

Tte

is acyclic

6 T

Tt

e

3

return

T

H key invariant

T

is

a

forest

K

H

t

slide-27
SLIDE 27

Kruskal

refactored

2

T 2 for each

e

uv3 in increasing order of wce

if

u u are in

diff components

  • f T

1

Tt

e

3

return T

we need

to

a

maintain

connected

components

  • f

T

6 quickly decide

if

2 vertices

are

in

same

component

slide-28
SLIDE 28

Union

Finddatastructuref

maintains

collection

  • f disjoint sets

s.T

Union Lu v combine

the

set containing

u

and the

set containing

V

Together

yr

returns

True

iff

n

and

V are

in the

same

set

q

u v

0CdCnD

union

find

can

be implemented

very

fast

almost

04

amortized

per

  • p

Bottleneck

  • f

Kruskal

is sorting

0cm

log

n

slide-29
SLIDE 29

Prins's algorithm

repeatedly adds

the

minimum

weight edge

w

  • ne endpoint

in

T

PRIM

G

YE

W

E 7113

1

T

S

s

for

some vertex

SEV

2

while

St V

a e

min weight edge crossing S

b

T Tte

S

SU e3 3

return

T

H key

invariant

T

is

a

tree connecting S

9

D

I

I I

b

slide-30
SLIDE 30

Need

quickly identify

nearest

vertex

  • utside

the

tree

to

the

tree

Prioritygueuedatastructuref

insert CK p

insert key

K

w

priority p

decrease

K p

decrease

the priority

  • f

a key

k

already in the

queue

to

a

smaller

priority

p

extract

min

remove

and

return

the

key

w

the minimum

priority

slide-31
SLIDE 31

For Prim's algo

keys

vertices not

in

the

Tree

priority

min

weight

  • f

any edge from

vertex

to

Tree

Fibonacci Heap

Och

insertions

OCI 0cm

extract min

Ocloyn

OCm

decrease

keyOCDamortized

OCmtrilogn