06.09.2021 Views

Discrete Mathematics- An Open Introduction - 3rd Edition, 2016a

Discrete Mathematics- An Open Introduction - 3rd Edition, 2016a

Discrete Mathematics- An Open Introduction - 3rd Edition, 2016a

SHOW MORE
SHOW LESS

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

4.2. Trees 253<br />

are adjacent (they are siblings), so we are good so far. Now put<br />

into A every child of every vertex in B (i.e., every grandchild of the<br />

root). Keep going until all vertices have been assigned one of the<br />

sets, alternating between A and B every “generation.” That is, a<br />

vertex is in set B if and only if it is the child of a vertex in set A.<br />

The key to how we partitioned the tree in the example was to know<br />

which vertex to assign to a set next. We chose to visit all vertices in the<br />

same generation before any vertices of the next generation. This is usually<br />

called a breadth first search (we say “search” because you often traverse a<br />

tree looking for vertices with certain properties).<br />

In contrast, we could also have partitioned the tree in a different order.<br />

Start with the root, put it in A. Then look for one child of the root to put in<br />

B. Then find a child of that vertex, into A, and then find its child, into B,<br />

and so on. When you get to a vertex with no children, retreat to its parent<br />

and see if the parent has any other children. So we travel as far from the<br />

root as fast as possible, then backtrack until we can move forward again.<br />

This is called depth first search.<br />

These algorithmic explanations can serve as a proof that every tree is<br />

bipartite, although care needs to be spent to prove that the algorithms<br />

are correct. <strong>An</strong>other approach to prove that all trees are bipartite, using<br />

induction, is requested in the exercises.<br />

Spanning Trees<br />

One of the advantages of trees is that they give us a few simple ways to<br />

travel through the vertices. If a connected graph is not a tree, then we can<br />

still use these traversal algorithms if we identify a subgraph that is a tree.<br />

First we should consider if this even makes sense. Given any connected<br />

graph G, will there always be a subgraph that is a tree? Well, that is<br />

actually too easy: you could just take a single vertex of G. If we want to<br />

use this subgraph to tell us how to visit all vertices, then we want our<br />

subgraph to include all of the vertices. We call such a tree a spanning tree.<br />

It turns out that every connected graph has one (and usually many).<br />

Spanning tree.<br />

Given a connected graph G, a spanning tree of G is a subgraph of<br />

G which is a tree and includes all the vertices of G.<br />

Every connected graph has a spanning tree.<br />

How do we know? We can give an algorithm for finding a spanning<br />

tree! Start with a connected graph G. If there is no cycle, then G is already<br />

a tree and we are done. If there is a cycle, let e be any edge in that cycle

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!