Professional Documents
Culture Documents
Answer: G1, G2
Forest:
• What if there are no simple circuits but the graph is not connected?
• Each of the connected components is a tree
The collection is called a forest
Root Tree:
A rooted tree is a tree in which one vertex has been designed as the root and every edge is directed away
from the root.
Consider
• If v is a vertex of tree T other than the root, the parent of v is the unique vertex u such that there is a
directed edge from u to v.
• When u is the parent of v, v is called the child of u.
• If two vertices share the same parent, then they are called siblings.
• The ancestors of a vertex other than the root are the vertices in the path from the root to this vertex,
excluding the vertex itself and including the root.
• The descendants of a vertex v are those
vertices that have v as an ancestor
• A vertex with no children is called a leaf.
• Vertices with children are called internal vertices.
• A rooted tree is called an m-ary tree if every internal vertex has no more than m children.
• A tree is called a full m-ary tree if every internal vertex has exactly m children.
• An m-ary tree with m 2 is called a binary tree.
Q. What is the arity of this tree?
• Is this a full m-ary tree?
-------------------
• This is a 2-ary, or binary, tree.
• Yes, this is a full binary tree, since every internal vertex has exactly 2 children.
It is not a full-3-ary tree, since one internal node has only 2 children.
• An ordered rooted tree is one where the children of each internal vertex are ordered.
• In an ordered binary tree, if an internal vertex has two children, then they are called left child and
right child.
• The subtree rooted at the left child of a vertex is called the left subtree and subtree rooted at the right
child of a vertex is called the right subtree.
• The level of a vertex v in a rooted tree is the length of the unique path from the root to this vertex.
• What is the level of the root? 0
The height of a rooted tree is the maximum of the levels of the vertices
Properties of Trees:
• A tree with n vertices has n1 edges.
• An full m-ary tree with i internal vertices contains n = mi + 1 vertices.
• A rooted m-ary tree of height h is called balanced if all leaves are at levels h or h–1
Q. Is this tree balanced?
Distance in Graph:
In a connected graph G, The distance 𝑑(𝑣𝑖 , 𝑣𝑗 ) between two vertices 𝑣𝑖 and 𝑣𝑗 is the length of the shortest
path between them.
d(a, c) = d(c, a)
d(a, b) = d(b, a)
d(a, d) = d(d, a)
Eccentricity:
The eccentricity of a vertex 𝑣 (𝐸(𝑣)) in a graph G is the distance from vertex 𝑣 to the vertex farthest from 𝑣
in graph G.
𝐸(𝑣) = max 𝑑(𝑣, 𝑣𝑖 )
For vertex a,
d (a, b) = 1
d (a, c) = 2 = d (a, f)
d (a, d) = 3 = d (a, e)
E(a) = max {1, 2, 3, 3, 2}
=3
Centre of a Graph:
A vertex with minimum eccentricity in graph G is called a center of G.
Spanning Trees:
Definition: Let G be a simple graph. A spanning tree of G is a subgraph of G that is a tree containing every
vertex of G
Example 1 Find a spanning tree of G
Solution:
Example: Use Kruskal algorithm to find a minimum spanning tree of G
Solution:
Example: Use Prim’s and Kruskal’s algorithm for finding the minimum spanning tree from the
following weighted graphs