Thanks to visit codestin.com
Credit goes to www.scribd.com

0% found this document useful (0 votes)
3 views5 pages

Trees

The document discusses trees, spanning trees, and minimal spanning trees, focusing on their properties and algorithms for construction. It introduces Prim's algorithm for finding a minimal spanning tree in a weighted graph, emphasizing the greedy approach of making local optimal choices. Key concepts include the unique path in trees, the relationship between edges and bridges, and methods for counting spanning trees in connected graphs.

Uploaded by

nayip81861
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
3 views5 pages

Trees

The document discusses trees, spanning trees, and minimal spanning trees, focusing on their properties and algorithms for construction. It introduces Prim's algorithm for finding a minimal spanning tree in a weighted graph, emphasizing the greedy approach of making local optimal choices. Key concepts include the unique path in trees, the relationship between edges and bridges, and methods for counting spanning trees in connected graphs.

Uploaded by

nayip81861
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 5

LECTURE 8, 9 10: NOTES ON TREES, MINIMAL SPANNING TREES,PRIM’S

ALGORITHM
SEP. 28 , OCT. 3, & OCT. 5

1. T REES

1.1. For the next two weeks, we will talk about a very simple but important class of graphs called
trees. A graph T is a tree if it is connected and contains no cycle (i.e. there is no closed path in the
graph). Some pictures are below.
1.2. Perhaps the first thing to note about trees is the following. Recall that a bridge in a connected
graph is one such that its deletion leads to a disconnected graph.
Lemma. A connected graph is a tree if and only if every edge is a bridge.
Proof. Assume G is a tree and let e be an edge, with vertices p and q. If G − e is connected, there
is a path between p and q contained in G − e. Hence adding in e to this path, we get a cycle in G.
Conversely, assume that G is connected and that every edge is a bridge. We want to show that
G cannot contain a cycle. Assume it does have a cycle P. Then deleting any edge of the cycle still
keeps the graph connected. Indeed, the only two vertices disconnected by this deletion still remain
connected in the graph by a path going the ‘other way’ around the cycle.


1.3. Recall that we argued earlier than in a connected graph with n vertices, the smallest number
of edges the graph could have is n − 1. In fact this exactly characterises trees.
Proposition. Let G be a connected graph on n vertices. Then G is a tree if and only if it has exactly
n − 1 edges.
Proof. First suppose that G is a tree. If it has n = 1 vertices, then it certainly has to have 0 edges
to be a tree, so we may assume, by induction, that every tree with v vertices, v < n has v − 1 edges.
Assume then that T is a tree with n vertices (where we may assume n > 1). Pick some edge in T
(it has to exist otherwise T would be disconnected). Removing it we get two disjoint components,
and actually both are trees (since if there was a cycle in either, it would be a cycle in T as well)
with less than n vertices, say one has p vertices, call it Tp , and the other has q vertices, call it Tq .
Of course p + q = n. By induction Tp has p − 1 edge, and Tq has q − 1 edges, therefore the graph
T , which is the union of Tp , Tq and a single edge (the one we removed) has
p−1+q−1+1 = p+q−1 = n−1
edges.
Conversely, assume that G is a connected graph on n vertices with exactly n − 1 edges. We
would like to show that G is a tree. Indeed, this follows from what we proved earlier: the minimal
number of edges in a connected graph with n vertices is n − 1. So, if we remove any edge from G,
we would have a graph with n vertices and n − 2 edges, and it is therefore disconnected, i.e. every
edge of G is a bridge and therefore by Lemma 1.2, G must be a tree. 
1
1.4. Another useful property of a tree is the following.
Lemma. Let T be a tree and p, q disjoint vertices. Then there is a unique path from p to q in T .
Proof. If there were two different paths, following one and the (reverse) of the other would create
a cycle in T . 

1.5. A bit more arboric terminology for trees. The degree 1 vertices of a tree are called its leaves
or end-vertices. A disjoint union of trees is sometimes called a forest. You may wish to prove
for yourself the following.
Claim. If T is a tree with more than one vertex (and is finite), it has at least two leaves.
Proof. Writing as usual d(v) for the degree of each vertex, we know that ∑v∈V d(v) = 2n where n
is the number of edges. If there were not at least two vertices of degee 1, then there would be at
least n − 2 vertices of degree 2, hence

∑ d(v) > 2(n − 2)


v∈V

a contradiction. 

1.6. Given any connected, simple graph G, we shall call a spanning tree of G a tree T which is
a subgraph of G and which includes every vertex of G. See below for some examples– note that
such spanning trees are not unique by any means, though all such spanning trees have n − 1 edges.
Exercise: If G has n vertices and m edges, what is the difference between the number of edges
in any spanning tree for T .
1.6.1. Constructing spanning trees. — Does every simple, connected graph have a spanning tree?
Let G be such a graph. If G contains no cycle, it’s already a tree. So assume it contains a cycle, and
remove any edge from this cycle. Is the resulting graph a tree? If not, it contains (by definition) a
cycle. Remove any edge from that cycle. Keep going until you obtain a graph with no cycle, i.e. a
tree. Note that we have always maintained the connected property of our graph since if we delete
an edge from a cycle, the resulting graph is still connected.
1.7. So we know that spanning trees exist for any simple graph G. What happens if we add a loop
to G ? No spanning tree will contain it, so the graph with a loop and a graph without a loop will
have the same number of spanning trees. If a graph has multiple edges, the notion of spanning tree
(and its existence) also make sense. In general we write
τ(G) := the number of spanning trees in the connected graph G (1.1)
where G is no longer assumed simple (but it is connected).
1.8. Examples: how many spanning trees are in the following examples ?
1.9. In general, it becomes cumbersome to try to count ‘by hand’ the number of spanning trees in
a graph. Here is one useful technique for simplifying the problem– it is also a question from your
homework, so I will not completely write out the proof.
Let e be any edge in a connected (multi)-graph graphs G. Then we can form two different
graphs from G, namely
• G − e is just the graph obtained by removing the edge e from G.
2
• G \ e is the graph obtained by ‘contracting’ the edge e, i.e. we identify the two ends of
e. Said another way, suppose that the edge e is incident to vertices x and y. Then G \ e is
obtained by deleting both x and y and adding a new vertex z. If there was every an edge wx
or wy in the original graph, we add in an edge wz into G \ e. If there was an edge from x to
y it becomes a loop at the vertex z. Here is a picture.
Proposition. We have τ(G) = τ(G − e) + τ(G \ e) for any edge e of G.
Sketch. Every spanning tree of G either contains the edge e or it does not. Assume it does not, then
it is a spanning tree in G − e. Conversely, every spanning tree of G − e is also a spanning tree of G
which does not contain the edge e. In other words there is a bijection
spanning trees of G not containing e ↔ spanning trees of G − e, (1.1)
where there are exactly τ(G − e) of the latter.
So to prove the proposition, it suffices to exhibit a bijection between spanning trees of G which
contain e and spanning trees of the contracted graph G \ e. I will leave the details to the homework,
but here is an example to help you get started:


1.9.1. Replacing edges in spanning trees. — Let G = (V, E) be a simple connected graph and let T
be a spanning tree. If e ∈ E does not lie on T , the the graph T 0 := T ∪ e obtained by adding in e to
T will have a cycle passing through e. In fact, it has a unique such cycle C: if a, b are the endpoints
of e, by Lemma 1.4 there is a unique path in T from a to b, and the cycle C must be obtained from
this path by adding in the edge e. Now let f 6= e be any other edge along C (so of course f was an
edge of the original T ). We claim
T ∗ := (T ∪ e) − f = T 0 − f ,
the graph obtained from T by adding e and deleting f , is again a spanning tree. Indeed, it is again
a tree since any cycle must contain the new added edge e, but there is only one such cycle in T 0 and
it contained f . It is moreover a spanning tree since the number of edges is the same for T ∗ and T ,
and this determines the number of vertices in a tree. Summarizing we have shown the following.
Lemma. Let G = (V, E) be a graph with spanning tree T . Let e be any edge of G not in T , and f
any edge of the unique cycle in T ∪ e. Then the graph obtained from T by replacing e by f is again
a spanning tree for G.

2. M INIMAL S PANNING TREES

2.0.1. Spanning trees in weighted graphs, i.e. the minimum spanning tree problem.. — Assume
now that our graph G = (V, E) is simple, connected, and positively weighted by the function w :
E → R. For any spanning tree T = (ET ,VT ) of G we can associate to it a weight,
w(T ) := ∑ w(e), (2.1)
e∈ET
and ask, among all spanning trees in G, find one of minimal weight. Can you come up with a real
world scenario in which such a question might arise?
2.0.2. Prim’s algorithm. — There are several known algorithms to solve the minimum spanning
tree problem, and they are generally all examples of greedy algorithms. By this one means that
at each stage of the algorithm, one makes what looks like the best local or immediate choice for a
3
solution. Fortunately, the sum of all these local choices turns out to be the right global one in the
end !
To describe the algorithm, let me introduce some terminology. Let G = (V, E) be a simple,
connected graph with weight function w : E → R. Then for any collection of distinct edges E =
ej
{e1 , e2 , . . . , ek } with each e j indicent to vertices v j−1 and v j , i.e. v j−1 → v j , we denote by T(E ) the
path in the graph G
e e ej
T(E ) : v0 →
1 2
v1 → v2 → · · · → v j . (2.2)
Prim’s algorithm for finding a minimal spanning tree is then the following process.
(1) Pick any vertex v0 ∈ V. Define S0 = {v0 } and E0 = 0. / Examine the edges connecting
to v0 and choose the one e1 with lowest weight w(e). Define E1 := {e1 }, and denote
the other endpoint of e1 , call it v1 , to add it to the set S1 , i.e. S1 = S0 ∪ {v1 }.
(2) For k ≥ 1, assume there is an edge incident to vertices in Sk , but whose other endpoint
is not in Sk . Among all such edges, choose the one, say ek+1 with the lowest weight
and add its other endpoint, say vk+1 to define the set
Sk+1 = Sk ∪ {vk+1 } and Ek+1 = Ek ∪ {ek+1 }. (2.3)
If such an edge does not exist, terminate the algorithm and output S = Sk and E = Ek .
Otherwise, repeat this step for k + 1.

Proposition. The above process will terminate with a sequence of sets T(E ) a minimal spanning
tree for G.
Proof. Write S0 ⊂ S1 ⊂ S2 · · · ⊂ Sd and E1 ⊂ · · · ⊂ Ed for the outputs of the algorithm, which
terminates with S = Sd and E = Ed . We also keep the same notation as in the algorithm, so that
Sk = {v0 , . . . , vk } and each edge e j is incident to vertices v j−1 and v j .
We first observe that for each k, T(Ek ) is a always a tree of G. Indeed, we start the algorithm
with E1 = {e1 } so that T(E1 ) is clearly a tree. Assume k > 1 is the smallest k such that T(Ek−1 ) is
a tree, but T(Ek ) is not a tree. In other words, by adding the edge ek to T(Ek−1 ) we have introduced
a cycle into T(Ek ). Hence ek , which has endpoints vk and vk−1 , could not possibly be an edge of
minimal weight among those connecting vertices in Sk−1 to E \ Sk−1 , a contradiction. So T(Ek ) is
again a tree.
Why is it a spanning tree? Assume v is some vertex in G not in T(E ). Then as the algorithm
terminated at S, E , the vertex v is not incident to any vertex of S. However as G was connected,
there is some path P from v to some vertex in u ∈ S, say
P : v → x1 , → x2 → · · · → x p → u,
with u ∈ S. Say that all x j ∈ / S. Then x p → u is an edge with at least one vertex not in S, so the
algorithm could not have terminted at S.
Finally we need to argue that T(E ) is a minimal spanning tree. Assume now, so there exists a
spanning tree T ⊂ G with w(T ) < w(T(E )). We may assume T is such a counterexample with the
most number of edges in common with T(E ). If this number is n − 1, we have nothing to prove
(here n = |V |).
Pick an edge ek of T(E ) which does not lie in T . Say that k > 1 was the smallest such k. Recall
our notation is that ek is incidnet to vertices vk−1 and vk . Since T is also a spanning tree, it contains
a unique path from vk−1 to vk as well. Such a path must contain an edge joining some vertex from
Sk−1 = {v0 , . . . , vk−1 } to a vertex from V \ Sk−1 since it starts in Sk−1 and ends in V \ Sk−1 . Call
this edge f .
4
Now replacing T with T ∗ := (T ∪ ek ) − f we obtain a new spanning tree by Lemma 1.9.1.
However as ek was selected to have minimal weight among all edges between vertices in Sk−1 and
V \ Sk−1 , we must have w( f ) ≥ w(ek ). Therefore, we have
w(T ∗ ) ≤ w(T ),
and since we assumed T was a minimal spanning tree, we have w(T ∗ ) = T . So T ∗ is a minimal
spanning tree with weight less than that of T(S), but having even more edges in common with S,
so we are done.


You might also like