Unit - 5
Graphs and Trees
Q1) Prove that the sum of the degrees of the vertices of any finite graph is even.
A1)
Each edge ends at two vertices. If we begin with just the vertices and no edges, every vertex has degree zero, so the sum of those degrees is zero, an even number. Now add edges one at a time, each of which connects one vertex to another, or connects a vertex to itself (if you allow that). Either the degree of two vertices is increased by one (for a total of two) or one vertex’s degree is increased by two. In either case, the sum of the degrees is increased by two, so the sum remains even.
Q2) Show that every simple graph has two vertices of the same degree.
A2)
This can be shown using the pigeon hole principle. Assume that the graph has n vertices. Each of those vertices is connected to either 0, 1, 2, . . . , n − 1 other vertices. If any of the vertices is connected to n − 1 vertices, then it is connected to all the others, so there cannot be a vertex connected to 0 others. Thus it is impossible to have a graph with n vertices where one is vertex has degree 0 and another has degree n − 1. Thus the vertices can have at most n − 1 different degrees, but since there are n vertices, at least two must have the same degree.
Q3) Show that if n people attend a party and some shake hands with others (but not with themselves), then at the end, there are at least two people who have shaken hands with the same number of people.
A3)
See problem 2. Each person is a vertex, and a handshake with another person is an edge to that person. 4. Prove that a complete graph with n vertices contains n(n − 1)/2 edges. Proof: This is easy to prove by induction. If n = 1, zero edges are required, and 1(1 − 0)/2 = 0. Assume that a complete graph with k vertices has k(k − 1)/2. When we add the (k + 1)st vertex, we need to connect it to the k original vertices, requiring k additional edges. We will then have k(k − 1)/2 + k = (k + 1)((k + 1) − 1)/2 vertices, and we are done.
Q4) Prove that a complete graph with n vertices contains n(n − 1)/2 edges.
A4)
This is easy to prove by induction. If n = 1, zero edges are required, and 1(1 − 0)/2 = 0. Assume that a complete graph with k vertices has k(k − 1)/2. When we add the (k + 1)st vertex, we need to connect it to the k original vertices, requiring k additional edges. We will then have k(k − 1)/2 + k = (k + 1)((k + 1) − 1)/2 vertices, and we are done.
Q5) Prove that a finite graph is bipartite if and only if it contains no cycles of odd length.
A5)
To show that a graph is bipartite, we need to show that we can divide its vertices into two subsets A and B such that every edge in the graph connects a vertex in set A to a vertex in set B. Proceed as follows: Choose any vertex from the graph and put it in set A. Follow every edge from that vertex and put all vertices at the other end in set B. Erase all the vertices you used. Now for every vertex in B, follow all edges from each and put the vertices on the other end in A, erasing all the vertices you used. Alternate back and forth in this manner until you cannot proceed. This process cannot encounter a vertex that is already in one set that needs to be moved to the other, since if it did, that would represent an odd number of steps from it to itself, so there would be a cycle of odd length. If the graph is not connected, there may still be vertices that have not been assigned. Repeat the process in the previous paragraph until all vertices are assigned either to set A or to set B. 3 There is no reason that the graph has to be finite for this argument to work, but the proof does have to be modified slightly, and probably requires the axiom of choice to prove: divide the graph into connected components and select a vertex from each component and put it in set A. Then use the same process as above. The “select a vertex from each component” requires the axiom of choice.
Q4) Show that if every component of a graph is bipartite, then the graph is bipartite.
A6)
If the components are divided into sets A1 and B1, A2 and B2, et cetera, then let A = ∪iAi and B = ∪iBi .
Q5) Prove that if u is a vertex of odd degree in a graph, then there exists a path from u to another vertex v of the graph where v also has odd degree.
A7)
We will build a path that does not reuse any edges. As we build the path, imagine erasing the edge we used to leave so that we will not use it again. Begin at vertex u and select an arbitrary path away from it. This will be the first component of the path. If, at any point, the path reaches a vertex of odd degree, we will be done, but each time we arrive at a vertex of even degree, we are guaranteed that there is another vertex out, and, having left, we effectively erase two edges from that meet at the vertex. Since the vertex originally was of even degree, coming in and going out reduces its degree by two, so it remains even. In this way, there is always a way to continue when we arrive at a vertex of even degree. Since there are only a finite number of edges, the tour must end eventually, and the only way it can end is if we arrive at a vertex of odd degree.
Q8) If the distance d(u, v) between two vertices u and v that can be connected by a path in a graph is defined to be the length of the shortest path connecting them, then prove that the distance function satisfies the triangle inequality: d(u, v) + d(v, w) ≥ d(u, w).
A8)
If you simply connect the paths from u to v to the path connecting v to w you will have a valid path of length d(u, v) + d(v, w). Since we are looking for the path of minimal length, if there is a shorter path it will be shorter than this one, so the triangle inequality will be satisfied.
Q6) Show that any graph where the degree of every vertex is even has an Eulerian cycle. Show that if there are exactly two vertices a and b of odd degree, there is an Eulerian path from a to b. Show that if there are more than two vertices of odd degree, it is impossible to construct an Eulerian path.
A9)
One way to prove this is by induction on the number of vertices. We will first solve the problem in the case that there are two vertices of odd degree. (If all vertices have even degree, temporarily remove some edge in the graph between vertices a and b and then a and b will have odd degree. Find the path from a to b which we will show how to do below, and then follow the removed edge from b back to a to make a cycle.) Suppose the odd-degree vertices are a and b. Begin at a and follow edges from one vertex to the next, crossing off edges so that you won’t use them again until you arrive at vertex b and you have used all the vertices into b. Why is it certain that you will eventually arrive at b? Well, suppose that you don’t. How could this happen? After you leave a, if you arrive at a vertex that is not b, there were, before you arrived, an even number of unused edges leading into it. That means that when you arrive, there is guaranteed to be an unused path away from that vertex, so you can continue your route. After entering and leaving a vertex, you reduce the number of edges by 2, so the vertex remains one with an even number (possibly zero) 4 of unused paths. So, if you have not yet arrived at vertex b, you can never get stuck at any other vertex, since there’s always a way out. Since the graph is finite, you cannot continue forever, so eventually you will have to arrive at vertex b. (And it has to be possible to get to vertex b since the graph is connected.) Note that a similar argument can be used to show that you can wait until you have used all the edges connecting to b. If b has more than one edge, leave each time you arrive until you get stuck at b. Now you have a path something like this: (a, a1, a2, . . . , an, b) leading from a to b. If all the edges are used in this path, you are done. If not, imagine that you have erased all the edges that you used. What remains will be a number of components of the graph (perhaps only one) where all the members of each component have even degree. Since b will not be in any of the components, all of them must have fewer vertices than the original graph.
Q7) Show that in a directed graph where every vertex has the same number of incoming as outgoing paths there exists an Eulerian path for the graph.
A10)
The proof above works basically without change. Note that each time a vertex is visited, one incoming and one outgoing node is used, so the equality of incoming and outgoing edges is preserved.
Q8) Show that a tree with n vertices has exactly n − 1 edges.
A11)
We can prove this by induction. If n = 1, the graph cannot have any edges or there would be a loop, with the vertex connecting to itself, so there must be n − 1 = 0 edges. Suppose that every tree with k vertices has precisely k−1 edges. If the tree T contains k+1 vertices, we will show that it contains a vertex with a single edge connected to it. If not, start at any vertex, and start following edges marking each vertex as we pass it. If we ever come to a marked vertex, there is a loop in the edges which is impossible. But since each vertex is assumed to have more than one vertex coming out, there is never a reason that we have to stop at one, so we much eventually encounter a marked vertex, which is a contradiction. Take the vertex with a single edge connecting to it, and delete it and its edge from the tree T. The new graph T 0 will have k vertices. It must be connected, since the only thing we lopped off was a vertex that was not connected to anything else, and all other vertices must be connected. If there were no loops before, removing an edge certainly cannot produce a loop, so T 0 is a tree. By the induction hypothesis, T 0 has k − 1 edges. But to convert T 0 to T we need to add one edge and one vertex, so T also satisfies the formula.
Q9) If u and v are two vertices of a tree, show that there is a unique path connecting them
A12)
If u and v are two vertices of a tree, show that there is a unique path connecting them. Since it’s a tree, it is connected, and therefore there has to be at least one path connecting u and v. Suppose there are two different paths P and Q connecting u to v. Reverse Q to make a path Q0 leading from v to u, and the path made by concatenating P and Q0 leads from u back to itself. Now this path PQ0 is not necessarily be a loop, since it may use some of the same edges in both directions, but we did assume that there are some differences between P and Q We can, from PQ0, generate a simple loop. Begin at u and continue back one node at a time until the paths P and Q0 differ. (Of course, they may differ right away.) At this point, the paths bifurcate. Continue along both paths of the bifurcation until they join again for the first time, and this must occur eventually, since we know they are joined at the end. The two fragments of P and Q0 form a (possibly) smaller circuit in the tree, which is impossible.
Q10) Show that any tree with at least two vertices is bipartite.
A13)
This is a trivial consequence of problem A tree has no cycles, so it certainly does not contain any cycles of odd length.