Graph and Tree-2021
Graph and Tree-2021
In this section we present the basic concepts related to graphs and trees such as the degree of a vertex,
connectedness, Euler and Hamiltonian circuits, isomorphisms of graphs, rooted and spanning trees.
Graphs, Paths, and Circuits
- An undirected graph consists of a set of vertices and a set of edges such that each edge is
associated with an unordered pair of vertices, called its endpoints.
- A directed graph or digraph G consists of a set of vertices and a set of edges such that each edge
is associated with an ordered pair of vertices.
- We denote a graph by ).
- Two vertices are said to be adjacent if there is an edge connecting the two vertices. Two edges associated
to the same vertices are called parallel.
- An edge incident to a single vertex is called a loop. A vertex that is not incident on any edge is called an
isolated vertex.
- A graph with neither loops nor parallel edges is called a simple graph.
Example: Consider the following graph
a. Find and .
b. List the isolated vertices.
c. List the loops.
d. List the parallel edges.
e. List the vertices adjacent to .
f. Find all edges incident on .
Solution:
a. { } and { }.
b. There is only one isolated vertex, .
c. There is only one loop, .
d. { }. e. { }. f. { }
Example: Which one of the following graphs is simple.
Solution:
a. is not simple since it has a loop and parallel edges. b. is simple.
- A complete graph on vertices, denoted by , is the simple graph that contains exactly one edge between
each pair of distinct vertices.
Example: Draw and .
Solution:
{ }, { } { }, { }
{ } { }
{ } { }
{ }
- The degree of a vertex in an undirected graph, in symbol ; is the number of edges incident on it.
By definition, a loop at a vertex contributes twice to the degree of that vertex.
- The total degree of is the sum of the degrees of all the vertices of .
Theorem:
For any graph , we have
| | ∑
Proof:
Suppose that { } and | | . Let . If is a loop then it contributes 2 to the total
degree of . If is not a loop then let and denote the endpoints of . Then e contributes 1 to and
contributes 1 to the . Therefore, contributes 2 to the total degree of G. Since was chosen arbitrarily,
this shows that each edge of G contributes 2 to the total degree of G. Thus,
| | ∑
(a) (b)
Solution:
a. Connected.
b. Disconnected since there is no path connecting the vertices and .
- A simple path that contains all edges of a graph is called an Euler path. If this path is also a circuit, it is
called an Euler circuit.
Theorem:
If a graph has an Euler circuit then every vertex of the graph has even degree.
Proof:
Let be a graph with an Euler circuit. Start at some vertex on the circuit and follow the circuit from vertex to
vertex, erasing each edge as you go along it. When you go through a vertex you erase one edge going in and one
edge going out, or else you erase a loop. Either way, the erasure reduces the degree of the vertex by 2.
Eventually every edge gets erased and all the vertices have degree 0. So all vertices must have had even degree
to begin with.
It follows from the above theorem that if a graph has a vertex with odd degree then the graph can not have an
Euler circuit.
The following provides a converse to the above theorem.
- A path is called a Hamiltonian path if it visits every vertex of the graph exactly once. A circuit that visits
every vertex exactly once except for the last vertex which duplicates the first one is called a Hamiltonian
circuit.
Example: Find a Hamiltonian circuit in the graph
Solution:
vwxyzv
Example:
Show that the following graph has a Hamiltonian path but no Hamiltonian circuit.
Solution: vwxyz is a Hamiltonian path. There is no Hamiltonian circuit since no cycle goes through v.
Solution:
The first graph satisfies the definition of a tree. The second and third graphs do not satisfy the conclusion of
Theorem2 and therefore they are not trees.
The second major theorem about trees is the following theorem whose proof is omitted.
Theorem3:
Any connected graph with vertices and edges is a tree.
Example: A forest is a simple graph with no circuits. Which of the following graphs is a forest?
3) Find the level of each vertex and the height of the following rooted tree.