• No se han encontrado resultados

Las condiciones sociales (económicas, políticas y culturales), ambientales y

In document INSTITUTO DE LA PAZ Y LOS CONFLICTOS (página 65-71)

Capítulo II. HISTORIA DEL PROGRAMA DESARROLLO PARA LA PAZ –

II.1. Las condiciones sociales (económicas, políticas y culturales), ambientales y

Imagine a map of your favorite region of countryside with some 30–40 villages. Some pairs of villages are connected by gravel roads, in such a way that each village can be reached from any other along these

5.4 The minimum spanning tree problem 171 roads. The county’s council decides to modernize some of these roads to highways suitable for fast car driving, but it wants to invest as little money as possible under the condition that it will be possible to travel between any two villages along a highway. In this way, we arrive at a fundamental problem called the minimum spanning tree problem. This section is devoted to its solution.

Of course, you may object that your favorite part of the countryside was full of first-class expressways a long time ago. So you may consider some less advanced country, or find another natural formulation of the underlying mathematical problem.

We also assume that the existing roads have no branchings outside the villages, and that the new roads can only be built along the old ones (because of proprietary rights, say). Otherwise, it may be cheaper for instance to connect four places like this

instead of like this

If we allowed the former kind of connection, we would arrive at a differ-ent algorithmic problem (called the Steiner tree problem), which turns out to be much less tractable than the minimum spanning tree problem.

A mathematical formulation of the minimum spanning tree prob-lem requires that the notion of graph is enriched a bit: we will con-sider graphs with weighted edges. This means that for every edge e∈ E we are given a number w(e), called the weight of the edge e.

The weight of an edge is usually a nonnegative integer or real num-ber. A graph G = (V, E) together with a weight function w on its edges, w : E → R, is sometimes called a network.

Let us formulate the above road-building problem in graph-theoretic terms:

Problem. Given a connected graph G = (V, E) with a nonnegative weight function w on the edges, find a spanning connected subgraph (V, E) such that the sum

w(E) = 

e∈E

w(e) (5.1)

has the minimum possible value.

It is easy to see that there is always at least one spanning tree of G among the solutions of this problem. If the weights are strictly positive, each solution must be a spanning tree. For instance, if all edges have weight 1, then the solutions of the problem are exactly the spanning trees of the graph, and the expression (5.1) has minimum value|V | − 1.

Hence, it suffices to deal with the following problem:

5.4.1 Problem (Minimum spanning tree problem). For a con-nected graph G = (V, E) with a weight function w on the edges, find a spanning tree T = (V, E) of the graph G with the smallest possible value of w(E).

An attentive reader might have observed that here we do not assume nonnegativity of the weights. Indeed, the algorithms we are going to dis-cuss solve even this more general problem with arbitrary weights. There is more to this remark than meets the eye: many graph problems that are easy for nonnegative weights turn into algorithmically intractable problems if we admit weights with arbitrary signs. An example of such a problem is finding the shortest path in a network, where the length of a path is measured as the sum of the edge weights.

A given graph may have very many spanning trees (see Chapter 8) and it may seem difficult to find the best one. It is not really so difficult, and nowadays it can be done by an easy modification of the algorithms from the previous section. We present several algorithms.

A simple and very popular one is the following:

5.4.2 Algorithm (Kruskal’s or the ‘‘greedy’’ algorithm). The input is a connected graph G = (V, E) with edge weight function w.

Let us denote the edges by e1, e2, . . . , em in such a way that w(e1)≤ w(e2)≤ · · · ≤ w(en).

For this ordering of edges, execute Algorithm 5.3.2.

Before proving the correctness of Kruskal’s algorithm, which is not completely easy, let us illustrate the algorithm with a small example.

5.4 The minimum spanning tree problem 173 Example. Let us apply Kruskal’s algorithm for the following network:

1

1 3

2 2

4 3

4

One possible execution of the algorithm is shown in the next diagram:

5.4.3 Proposition (Correctness of Kruskal’s algorithm). Alg-orithm 5.4.2 solves the minimum spanning tree problem.

Proof. This proof is not really deep but it seems to require concen-trated attention, for otherwise it is very easy to make a mistake in it (both the authors have a rich experience of it by presenting it in lectures).

Let T be the spanning tree found by the algorithm, and let ˇT be any other spanning tree of the graph G = (V, E). We need to show that w(E(T )) ≤ w(E( ˇT )). Let us denote the edges of T by e1, e2, . . . , en−1 in such a way that w(e1) ≤ w(e2) ≤ · · · ≤ w(en−1) (the edge ei has been denoted by some ej in the algorithm, so that it now has two names!). Similarly let ˇe1, . . . , ˇen−1 be the edges of ˇT ordered increasingly by weights.

We show that for i = 1, . . . , n− 1, we even have

w(ei)≤ w(ˇei). (5.2) This of course shows that T is a minimum spanning tree. For contra-diction, let us assume that (5.2) is not true, and let i be the smallest index for which it is violated, i.e. w(ei) > w(ˇei). We consider the sets

E = {e1, . . . , ei−1}, E =ˇ {ˇe1, . . . , ˇei}.

The graphs (V, E) and (V, ˇE) contain no cycles and, moreover,

|E| = i − 1, | ˇE| = i.

For the desired contradiction it suffices to show that there exists an edge e ∈ ˇE for which the graph (V, E ∪ {e}) contains no cycle.

Then we obtain w(e) ≤ w(ˇei) < w(ei) and this means that at the moment the edge e was considered in the algorithm we made a mis-take. There was no reason to reject e, and we should have selected it instead of the edge ei or earlier.

Therefore it is enough to show the following: If E, ˇE V

2

 are two sets of edges, such that the graph (V, ˇE) has no cycle and|E| <

| ˇE|, then some edge e ∈ ˇE connects vertices of distinct components of the graph (V, E). This can be done by a simple counting argument.

Let V1, . . . , Vs be the vertex sets of the components of the graph (V, E). We have

E

Vj 2

 ≥ |Vj| − 1,

and by summing these inequalities over j we get |E| ≥ n − s. On the other hand, since ˇE has no cycles, we get

 ˇE ∩ Vj

2

 ≤ |Vj| − 1,

and therefore at most n− s edges of ˇE are contained in some of the components Vj. But since we assumed | ˇE| > |E|, there is an edge e∈ ˇE going between two distinct components. 2 Kruskal’s algorithm is a prototype of the so-called greedy algorithm.

At every step, it selects the cheapest possible edge among those allowed by the restrictions of the problem (here “the graph should contain no cycle”). In general, “greedy algorithm” is a term for a strategy trying to gain as much as possible at any given moment, never contemplating the possible disadvantages such a choice may bring in the future.3 For numerous problems, this short-sighted strategy may fail completely. For instance, a greedy strategy applied for a chess game would mean (in the simplest form) that a player would always take a piece whenever possible, and always the most valuable one. And by following such a naive play he would lose very soon.

3In the minimum spanning tree problem, a “parsimonious algorithm” would perhaps be a more appropriate name, since we always take the cheapest possible edge. But “greedy algorithm” is a universally accepted name. It is derived from situations where one tries to maximize something by grabbing as much as possible in each step. Since the minimizing and maximizing problems aren’t conceptually very different, it seems better to stick to the single term “greedy algorithm” in both situations.

5.4 The minimum spanning tree problem 175 In this context, it seems somewhat surprising that the greedy alg-orithm finds a minimum spanning tree correctly. The greedy strategy may be useful also for many other problems (especially if we have no better idea). Often it at least yields a good approximate solution. Prob-lems for which the greedy algorithm always finds an optimal solution are studied in the so-called matroid theory. The reader can learn about it in Oxley [26], for instance.

Exercises

1. Analogously to the minimum spanning tree problem, define the max-imum spanning tree problem. Formulate a greedy algorithm for this problem and show that it always finds an optimal solution.

2. Prove that if T = (V, E) is a spanning tree of a graph G = (V, E) then the graph T + e, where e is an arbitrary edge of E\ E, contains exactly one cycle.

3. Prove that if T is a spanning tree of a graph G then for every e E(G)\ E(T ) there exists an e ∈ E(T ) such that (T − e) + e is a spanning tree of G again.

4. Let G be a connected graph with a weight function w on the edges, and assume that w is injective. Prove that the minimum spanning tree of G is determined uniquely.

5. Let G be a connected graph with a weight function w on the edges.

Prove that for each minimum spanning tree T of G, there is an initial ordering of the edges in Kruskal’s algorithm such that the algorithm outputs the tree T .

6. Let w and w be two weight functions on the edges of a graph G = (V, E). Suppose that w(e1) < w(e2) holds if and only if w(e1) <

w(e2), for any two edges e1, e2∈ E. Prove that (V, E) is a minimum spanning tree of G for the weight function w if and only if (V, E) is a minimum spanning tree of G for the weight function w. (This means:

the solution to the minimum spanning tree problem only depends on the ordering of edge weights.)

7. CS Using the discussion of Algorithm 5.3.2 in the preceding section, design the details of Kruskal’s algorithm in such a way that its time complexity is O((n + m) log n).

8. Consider an n-point set V in the plane. We define a weight function on the edge set of the complete graph on V : the weight of an edge{x, y}

is the distance of the points x and y.

(a)Show that no minimum spanning tree for this network has a vertex of degree 7 or higher.

(b)Show that there exists a minimum spanning tree whose edges do not cross.

9. Let V be a set of n > 1 points in the unit square in the plane. Let T be a minimum spanning tree for V (i.e. for the complete graph with edge weights given by distances as in Exercise 8). Show that the total length of the edges of T is at most 10

n. (The constant 10 can be improved significantly; the best known estimate is about 1.4

n + O(1).) 10. Let G = (V, E) be a graph and let w be a nonnegative weight function

on its edges.

(a)Each set E⊆ E of pairwise disjoint edges (i.e. sharing no vertices) is called a matching in the graph G. Let νw(G) denote the maximum possible value of w(E) for a matching E ⊆ E. A greedy algorithm for finding a maximum matching works similar to Kruskal’s algorithm for a maximum spanning tree, i.e. it considers edges one by one in the order of decreasing weights, and it selects an edge if it has no common vertex with the previously selected edges. Show that this algorithm always finds a matching with weight at least 12νw(G).

(b) Show that the bound in (a) cannot be improved; that is, for any constant α > 12 there exists an input for which the greedy algorithm finds a matching with weight smaller than α νw(G).

11. A set C ⊆ E in a graph G = (V, E) is called an edge cover if each vertex v∈ V is contained in at least one edge e ∈ C. Let us look for a small edge cover by a greedy algorithm: if there is an edge containing 2 uncovered vertices take an arbitrary such edge, otherwise take any edge covering some yet uncovered vertex, and repeat until all is covered.

Show that the number of edges in a cover thus found is (a) at most twice the size of the smallest possible cover,

(b)∗∗and (even) at most 32 of the size of the smallest possible cover.

12. A set D ⊆ V in a graph G = (V, E) is called a dominating set if

e∈E : e∩D =∅e = V . Let us look for a small dominating set by a greedy algorithm: we always select a vertex connected to the maximum pos-sible number of yet uncovered vertices. Show that for any number C there exists a graph for which |DG| ≥ C|DM|, where DG is a domi-nating set selected by the greedy algorithm and DM is a dominating set of the smallest possible size. (Start by finding examples for small specific values of C.)

In document INSTITUTO DE LA PAZ Y LOS CONFLICTOS (página 65-71)