• Aucun résultat trouvé

Minimum spanning tree

N/A
N/A
Protected

Academic year: 2022

Partager "Minimum spanning tree"

Copied!
30
0
0

Texte intégral

(1)

Minimum spanning tree

Jean Cousty MorphoGraph and Imagery

2011

(2)

Outline of the lecture

1 Minimum spanning tree

2 Cut theorem for MST

3 Kruskal algorithm

(3)

Minimum spanning tree

Edge weighted graph

G denotes a connected undirected graph (E,Γ)

W denotes a map from Γ into R

W(u) is called the weight (or value) of u (∀u ∈Γ) The pair (G,W) is called an(edge-) weighted graph

(4)

Minimum spanning tree

Edge weighted graph

G denotes a connected undirected graph (E,Γ) W denotes a map from Γ into R

W(u) is called the weight (or value) of u (∀u ∈Γ)

The pair (G,W) is called an(edge-) weighted graph

(5)

Minimum spanning tree

Edge weighted graph

G denotes a connected undirected graph (E,Γ) W denotes a map from Γ into R

W(u) is called the weight (or value) of u (∀u ∈Γ) The pair (G,W) is called an(edge-) weighted graph

(6)

Minimum spanning tree

Spanning subgraph

Definition

A spanning subgraph ofG is a graph(E,Γ0) such thatΓ0 ⊆Γ

(7)

Minimum spanning tree

Weight of a subgraph

Definition

Let G0 = (E,Γ0) be a spanning subgraph of G

The weight ofG0, denoted by W(G0), is the sum of the weights of the edges that belong to Γ0

W(G) =P

{W(u)|uΓ0}

(8)

Minimum spanning tree

Minimum spanning tree (MST)

Definition

A minimum spanning tree (for (G,W))is a connected spanning subgraph G0= (E,Γ0) of G whose weight is minimum:

for any connected spanning subgraph G00of G , if W(G00)W(G0) then W(G00) =W(G0)

Property

If G0 is an MST, then G0 is a tree

(9)

Minimum spanning tree

Minimum spanning tree (MST)

Definition

A minimum spanning tree (for (G,W))is a connected spanning subgraph G0= (E,Γ0) of G whose weight is minimum:

for any connected spanning subgraph G00of G , if W(G00)W(G0) then W(G00) =W(G0)

Property

If G0 is an MST, then G0 is a tree

(10)

Minimum spanning tree

Illustration

(11)

Minimum spanning tree

Maximum spanning tree (MaxST)

Definition

A maximum spanning tree (for (G,W))is a spanning tree(E,Γ0) of maximum weight:

for any spanning tree G00, if W(G00)W(G0) then W(G00) =W(G0)

Property

G0 is a MaxST of(G,W)if and only if G0 is a MST of (G,−W)

(12)

Minimum spanning tree

Maximum spanning tree (MaxST)

Definition

A maximum spanning tree (for (G,W))is a spanning tree(E,Γ0) of maximum weight:

for any spanning tree G00, if W(G00)W(G0) then W(G00) =W(G0)

Property

G0 is a MaxST of(G,W)if and only if G0 is a MST of (G,−W)

(13)

Minimum spanning tree

MST algorithm and safe edges

Generic MST Algorithm ( Data: (E,Γ,W) ;

Result: Γ0 such that (E,Γ0) is an MST)

n :=|E|; Γ0:=∅ ;k := 0 ; While k <n−1do

Find an edgeuthat issafefor Γ0 Γ0 := Γ0∪ {u}

Definition

Let(E,Γ0) be a subgraph of a MST Let u∈Γ\Γ0

u issafe forΓ0 if(E,Γ0∪ {u}) is also a subgraph of an MST

(14)

Minimum spanning tree

MST algorithm and safe edges

Generic MST Algorithm ( Data: (E,Γ,W) ;

Result: Γ0 such that (E,Γ0) is an MST)

n :=|E|; Γ0:=∅ ;k := 0 ; While k <n−1do

Find an edgeuthat issafefor Γ0 Γ0 := Γ0∪ {u}

Definition

Let (E,Γ0) be a subgraph of a MST Let u ∈Γ\Γ0

(15)

Cut theorem for MST

Cut and MST

Question

How to efficiency detect an edge that is safe?

(16)

Cut theorem for MST

Cut

Definition

Let Γ0 ⊆Γ

The cut induced by Γ0 is the subset of Γthat contains the edges that link two distinct connected components of the graph (E,Γ0)

A subset C ofΓ is a cutif there existsΓ0⊆Γsuch that C is the cut induced byΓ0

(17)

Cut theorem for MST

Cut

Definition

Let Γ0 ⊆Γ

The cut induced by Γ0 is the subset of Γthat contains the edges that link two distinct connected components of the graph (E,Γ0) A subset C ofΓ is a cutif there existsΓ0⊆Γsuch that C is the cut induced by Γ0

(18)

Cut theorem for MST

Cut theorem for MST

Theorem

Let (E,Γ0) be a subgraph of an MST

Let C be a cut that is a subset of the cut induced byΓ0 Let u∈C be an edge of minimum weight in C (i.e.,∀v ∈C , W(u)≤W(v))

Then, u is safe forΓ0

(19)

Cut theorem for MST

Cut theorem for MST

Theorem

Let (E,Γ0) be a subgraph of an MST

Let C be a cut that is a subset of the cut induced by Γ0

Let u∈C be an edge of minimum weight in C (i.e.,∀v ∈C , W(u)≤W(v))

Then, u is safe forΓ0

(20)

Cut theorem for MST

Cut theorem for MST

Theorem

Let (E,Γ0) be a subgraph of an MST

Let C be a cut that is a subset of the cut induced by Γ0 Let u ∈C be an edge of minimum weight in C (i.e.,∀v ∈C , W(u)≤W(v))

Then, u is safe forΓ0

(21)

Cut theorem for MST

Cut theorem for MST

Theorem

Let (E,Γ0) be a subgraph of an MST

Let C be a cut that is a subset of the cut induced by Γ0 Let u ∈C be an edge of minimum weight in C (i.e.,∀v ∈C , W(u)≤W(v))

Then, u is safe for Γ0

(22)

Kruskal algorithm

MST computation

KRUSKAL Algorithm ( Data: a connected graph (E,Γ,W) ; Result: Γ0 such that (E,Γ0) is an MST)

n :=|E|; Γ0:=∅ ;k := 0 ;i := 1;

Sort the edges in Γ in increasing order of weight:

Find the sequence (u1, . . . ,um) such that Γ ={u1, . . . ,um} and W(ui−1)≤W(ui),∀i ∈ {2, . . . ,m}

While k <n−1Do {xi,yi}:=ui ;

Ifxi / the connected component containingyi in (E,Γ0)Then Γ0:= Γ0∪ {ui};

k:=k+ 1;

(23)

Kruskal algorithm

Execution example

(24)

Kruskal algorithm

Proof of the algorithm

When the testIf is positive, the edgeu is safe for Γ0

This can be proved by the cut theorem applied to the cut induced by Γ0

(25)

Kruskal algorithm

Complexity of Kruskal Algorithm

Complexity

Complexity of a sort (O(mlog(m))for quick sort)

Complexity of theWhile loop: O(m)

Complexity of theIf test: O(m×n)(connected component algorithm seen in the course)

Overall complexity: O(m×n+mlog(m))

The complexity of theIftest can be reduced to quasi linear time using Tarjan’s union of disjoint set algorithm

(26)

Kruskal algorithm

Complexity of Kruskal Algorithm

Complexity

Complexity of a sort (O(mlog(m))for quick sort) Complexity of the While loop: O(m)

Complexity of theIf test: O(m×n)(connected component algorithm seen in the course)

Overall complexity: O(m×n+mlog(m))

The complexity of theIftest can be reduced to quasi linear time using Tarjan’s union of disjoint set algorithm

(27)

Kruskal algorithm

Complexity of Kruskal Algorithm

Complexity

Complexity of a sort (O(mlog(m))for quick sort) Complexity of the While loop: O(m)

Complexity of the If test: O(m×n)(connected component algorithm seen in the course)

Overall complexity: O(m×n+mlog(m))

The complexity of theIftest can be reduced to quasi linear time using Tarjan’s union of disjoint set algorithm

(28)

Kruskal algorithm

Complexity of Kruskal Algorithm

Complexity

Complexity of a sort (O(mlog(m))for quick sort) Complexity of the While loop: O(m)

Complexity of the If test: O(m×n)(connected component algorithm seen in the course)

Overall complexity: O(m×n+mlog(m))

The complexity of theIftest can be reduced to quasi linear time using Tarjan’s union of disjoint set algorithm

(29)

Kruskal algorithm

Complexity of Kruskal Algorithm

Complexity

Complexity of a sort (O(mlog(m))for quick sort) Complexity of the While loop: O(m)

Complexity of the If test: O(m×n)(connected component algorithm seen in the course)

Overall complexity: O(m×n+mlog(m))

The complexity of the Iftest can be reduced to quasi linear time using Tarjan’s union of disjoint set algorithm

(30)

Kruskal algorithm

Prim and Boruvka Algorithm

These are other algorithms for computing an MST Also a version of the generic algorithm

Their invariants also rely on the cut theorem

Read http://www.ics.uci.edu/˜eppstein/161/960206.html

Références

Documents relatifs

Given an undirected labeled connected graph (i.e., with a label or color for each edge), the minimum labeling spanning tree problem seeks a spanning tree whose edges have the smallest

Consider the graph in Figure 2 where the weights on the edges represent the fiability of the corresponding communication link (where 0 is the minimum and 1 is the maximum fiability

• If there is no outgoing edge, that means that the maximum degree of this spanning tree cannot be improved, this node send a message ”stop” to its parents.. The ”stop” message

The first stage is a uniform randomized stabilizing unique naming protocol, and the second stage is a stabilizing MDST protocol, designed as a fair composition of

In this paper, we propose a distributed version of Fischer’s ap- proximation algorithm that computes a minimum weight spanning tree of de- gree at most b∆ ∗ + ⌈log b n⌉, for

Le protocole spanning tree utilise les BPDU pour élire le commutateur root et le port root pour le réseau commuté, aussi bien que le port root et le port désigné pour chaque

In conclusion, the composition of these four layers provides us a self-stabilizing algorithm for centers computation or minimum diameter spanning tree construc- tion under

Keywords: ost sharing, fairness, minimum ost spanning tree game, Bird rule..